Skip to content

feat: show selected word count in status bar - #20

Open
willwang93 wants to merge 1 commit into
starc007:mainfrom
willwang93:feat/selected-word-count
Open

willwang93 wants to merge 1 commit into
starc007:mainfrom
willwang93:feat/selected-word-count

Conversation

@willwang93

Copy link
Copy Markdown

Summary

Displays real-time word count for highlighted/selected text in the status bar.

Details

  • When text is highlighted in either the rich-text editor or Markdown source mode, the counter dynamically displays X of Y words (e.g. 14 of 350 words).
  • When the selection is cleared or empty, it smoothly reverts back to the standard Y words count.
  • Resets selection state cleanly when switching notes.
  • Tested: bunx tsc --noEmit passes cleanly and all 59 Rust tests in cargo test pass.

@starc007

Copy link
Copy Markdown
Owner

Reviewed 357f47e. Found two issues to address:

  1. Selected and total word counts use different rules. In rich-text mode, selecting all of # Hello world shows 2 of 3 words: the selection counts rendered text, but the total includes Markdown syntax. In source mode, selecting all of ---\ntitle: Example\n---\nHello world counts the YAML too, showing 6 of 2 words. Please use consistent counting rules for the selected text and the total, including how frontmatter is handled.

  2. Switching to source mode can leave a stale selection count. Select text in a plain-text note, then switch to source mode. CodeMirror starts with an empty selection, but its callback only runs after a selection or document change, so the previous rich-text selection count can remain visible. Please report the initial selection on mount or reset the count when switching modes.

Validation: typecheck and all 37 frontend tests pass. I reproduced the count discrepancies programmatically; the mode-switch issue was traced through the code, not tested in the UI.

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.

2 participants