feat(core): add opt-in smartPunctuation (double-space period) to Textarea#1178
Open
helgeu wants to merge 1 commit into
Open
feat(core): add opt-in smartPunctuation (double-space period) to Textarea#1178helgeu wants to merge 1 commit into
helgeu wants to merge 1 commit into
Conversation
Add a `smartPunctuation` option (default false) to TextareaRenderable that mirrors the native macOS/iOS "Add period with double-space" behavior: typing two spaces after a letter or digit inserts ". " instead of " ". Pressing backspace immediately after reverts to two spaces. The conversion is context-gated (no keystroke timing), matching how editor input-rule systems and Apple's implementation work; timing-based gating is non-deterministic and unsupported elsewhere. Refs anomalyco#1177
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.
Summary
Adds an opt-in
smartPunctuationoption toTextareaRenderablethat mirrors the native macOS/iOS "Add period with double-space" behavior: when enabled, typing two spaces after a word inserts". "instead of" ". Pressing Backspace immediately after reverts it back to two spaces.Implements the design discussed in #1177.
Why this belongs in the widget
Downstream consumers (e.g. opencode's prompt) can't implement this cleanly, because individual space keystrokes are handled inside
Textarea.handleKeyPressand never surface to the host app — the conversion has to live here.Behavior
smartPunctuationdefaults tofalse; existing behavior is unchanged. Also exposed as a runtime getter/setter.".. "on a third space.Why no keystroke timing
Per the research in #1177: Apple's implementation and every editor input-rule system (ProseMirror, CodeMirror, VS Code, etc.) gate this purely on preceding-character context, never on keystroke timing. Timing-based gating is non-deterministic, breaks paste/fast typists, and has no precedent for content transforms. (Android/AOSP is the lone exception with a loose 1100ms window, but it still relies on the same context gates + backspace-revert.)
Tests
New
Textarea.smart-punctuation.test.ts(8 cases): default-off, convert after letter, convert after digit, no-op at line start, no-op after punctuation, no triple-space stacking, backspace-revert, and runtime toggle.oxfmt+oxlint: cleanCloses #1177