Improve word count: real-time updates, better perf, and formatted display#1484
Open
SushrutDhakal wants to merge 2 commits into0x7c13:masterfrom
Open
Improve word count: real-time updates, better perf, and formatted display#1484SushrutDhakal wants to merge 2 commits into0x7c13:masterfrom
SushrutDhakal wants to merge 2 commits into0x7c13:masterfrom
Conversation
Display a running word count in the status bar that shows the total number of words in the document. When text is selected/highlighted, the indicator also shows the number of selected words alongside the total (e.g. 5/120 words).
…play - Propagate TextChanging event through INotepadsCore/NotepadsCore so word count updates in real time as the user types, deletes, or pastes text - Replace string.Split word counting with O(n) char iteration to avoid intermediate allocations on every keystroke for large files - Format display as Words: 1,245 and Words: 1,245 | Selected: 132 with locale-aware thousand separators Co-authored-by: Cursor <cursoragent@cursor.com>
be9849b to
d91e5d3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a real-time word count indicator to the status bar that displays the total word count of the document and the selected word count when text is highlighted.
Words: 1,245when no text is selectedWords: 1,245 | Selected: 132when text is highlightedPR Type
What kind of change does this PR introduce?
What is the current behavior?
The status bar displays line/column position, encoding, line ending, and font zoom, but has no word count information.
What is the new behavior?
A word count indicator is displayed in the status bar (between line/column and font zoom indicators) that:
Files changed
ITextEditor.cs- AddedGetSelectedText()to the interfaceTextEditor.xaml.cs- ImplementedGetSelectedText()INotepadsCore.cs/NotepadsCore.cs- AddedTextEditorTextChangingevent propagationNotepadsMainPage.xaml- AddedWordCountIndicatorTextBlock to the status bar gridNotepadsMainPage.xaml.cs- WiredTextEditorTextChangingto update word countNotepadsMainPage.StatusBar.cs- AddedUpdateWordCountIndicator()and efficientCountWords()using char iterationOther information
A word is defined as a contiguous sequence of non-whitespace characters, consistent with standard text editor behavior. The feature is modular and can be extended (e.g. character count, reading time) without changes to existing code.