Skip to content

Improve word count: real-time updates, better perf, and formatted display#1484

Open
SushrutDhakal wants to merge 2 commits into0x7c13:masterfrom
SushrutDhakal:feature/word-count-indicator
Open

Improve word count: real-time updates, better perf, and formatted display#1484
SushrutDhakal wants to merge 2 commits into0x7c13:masterfrom
SushrutDhakal:feature/word-count-indicator

Conversation

@SushrutDhakal
Copy link

@SushrutDhakal SushrutDhakal commented Feb 8, 2026

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.

  • Shows Words: 1,245 when no text is selected
  • Shows Words: 1,245 | Selected: 132 when text is highlighted
  • Updates in real time as the user types, deletes, pastes, or changes selection
  • Uses O(n) character iteration for word counting to avoid allocations on large files
  • Number formatting uses locale-aware thousand separators

PR Type

What kind of change does this PR introduce?

  • Feature

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:

  • Always shows the total word count of the entire document
  • Additionally shows the selected word count when text is highlighted
  • Updates instantly on text changes and selection changes

Files changed

  • ITextEditor.cs - Added GetSelectedText() to the interface
  • TextEditor.xaml.cs - Implemented GetSelectedText()
  • INotepadsCore.cs / NotepadsCore.cs - Added TextEditorTextChanging event propagation
  • NotepadsMainPage.xaml - Added WordCountIndicator TextBlock to the status bar grid
  • NotepadsMainPage.xaml.cs - Wired TextEditorTextChanging to update word count
  • NotepadsMainPage.StatusBar.cs - Added UpdateWordCountIndicator() and efficient CountWords() using char iteration

Other 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.

SushrutDhakal and others added 2 commits February 8, 2026 17:21
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>
@SushrutDhakal SushrutDhakal force-pushed the feature/word-count-indicator branch from be9849b to d91e5d3 Compare February 8, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant