[Feature]: Show selected character and word count in the editor
- Dominant language
- TypeScript
- Stars
- 71.3k
- Forks
- 4.7k
- Avg merge
- 17h 8m
- Merged PRs (30d)
- 475
Description
## Problem or use case
When I select text in Orca's editor, there is no quick way to see how much text I've highlighted. Editors like VS Code show a small "X characters, Y words selected" indicator, which is handy for checking snippet length, verifying a paste, counting words in prose/markdown, or trimming a selection to a size limit. Today Orca gives no live feedback about the size of the current selection.
## Proposed solution
Show a small, unobtrusive indicator with the **selected character count and word count** while text is selected in the editor. It should appear only when the selection is non-empty and disappear when the selection is cleared.
Suggested behavior:
- Format: `123 chars, 20 words selected` (or the VS Code-style `Sel 123` / `20 words`).
- Character count = length of the selected text; word count = whitespace-delimited tokens of the selected text.
- Live-updates as the selection changes.
Two placement options (either is fine — I'd defer to maintainers):
1. **Bottom-right badge inside the editor pane.** The Monaco editor container in `src/renderer/src/components/editor/MonacoEditor.tsx` is already a `relative` element (`editorContainerRef`) that hosts an absolutely-positioned floating widget (the "add note on selection" button, `orca-diff-comment-add-btn`). A bottom-right count badge could reuse that exact overlay pattern, positioned with `bottom`/`right`.
2. **A segment in the global status bar** (`src/renderer/src/components/status-bar/StatusBar.tsx`, mounted app-wide in `App.tsx`). This is closer to true VS Code parity but requires bridging selection stats up from the editor (e.g. via the store or a `file-search-selection`-style provider registry), since the status bar is app-global while the editor is nested.
Implementation notes (from a quick look at the code):
- Monaco already exposes selection via `onDidChangeCursorSelection`, and selected text via `model.getValueInRange(selection)` (used today in `MonacoEditor.tsx` and `monaco-markdown-selection-annotation.ts`). A small pure helper `getSelectionStats(model, selection) -> { chars, words }` could live next to `monaco-markdown-selection-annotation.ts`.
- The existing selection subscription in `MonacoEditor.tsx` is currently gated behind markdown-annotation logic; the counter would need an always-on subscription (or to widen that gate).
- Optionally extend the same behavior to the diff view (`DiffViewer.tsx`) on the modified sub-editor, which does not currently track selection.
Cross-platform / SSH notes: this is pure renderer UI driven by the in-memory Monaco model, so it has no OS-, remote-, or agent-specific behavior — it should work identically on macOS/Linux/Windows and over SSH.
## Alternatives or additional context
- **Do nothing / rely on external tools** — copy the text elsewhere to count it; poor UX for a quick check.
- **Show it only on demand** (e.g. tooltip or command) instead of a live indicator — less discoverable.
- Prior art: VS Code's status bar shows selection char/word counts; most code editors offer this.
Relevant files for reference:
- `src/renderer/src/components/editor/MonacoEditor.tsx`
- `src/renderer/src/components/editor/monaco-markdown-selection-annotation.ts`
- `src/renderer/src/components/editor/DiffViewer.tsx`
- `src/renderer/src/components/status-bar/StatusBar.tsx`
Happy to implement this if it sounds good.
Contributor guide
Assessment
This issue has not been assessed yet.