fix: normalize dead-key grave input in composer#3236
Conversation
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved Straightforward bug fix that normalizes dead-key grave characters to backticks in the composer input. Changes are self-contained to event handling logic in one component with clear intent and limited scope. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: Codex <codex@openai.com>
Summary
Root cause
Some keyboard layouts emit grave-like Unicode characters (
ˋ,‵,`) throughinsertCompositionTextafter a dead-key press. The composer accepted those literal characters, so Markdown inline-code delimiters were not recognized.Impact
Dead-key grave input now produces ASCII backticks only at the input boundary. Pasted text and non-dead-key Unicode content are left unchanged.
Validation
PATH="$HOME/.vite-plus/bin:$PATH" vp checkPATH="$HOME/.vite-plus/bin:$PATH" vp run typecheckvp checkreports the repository's existing unrelated warnings and no errors.Closes #3142
Note
Low Risk
Localized Lexical input-handling in the composer editor; no auth, data, or API changes.
Overview
Dead-key grave input on some keyboard layouts was inserting Unicode lookalikes (
ˋ,‵,`) instead of ASCII backticks, so inline-code surround and Markdown delimiters broke.ComposerSurroundSelectionPluginnow records plainDeadkeydowns in a 1s window. WheninsertCompositionTextdelivers one of those lookalikes shortly after, it is handled as a backtick: existing surround-selected-text behavior runs when applicable, otherwise a single`is inserted, and the lookalike is suppressed viapreventDefault/ propagation stops.Modifier handling is centralized in
hasCommandModifier(meta/ctrl). The dead-key tracking ref is cleared on other composition paths and normal surround handling so unrelated input is unchanged; paste and non-dead-key Unicode are not rewritten.Reviewed by Cursor Bugbot for commit 6e83d9e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Normalize dead-key grave input to backtick in composer surround-selection plugin
On macOS, pressing a dead-key grave (
`) followed by a space produces a Unicode grave-lookalike character instead of a literal backtick, breaking the surround-selection feature in ComposerPromptEditor.Deadkeydown inrecentDeadKeyDownRefto create a 1-second detection window.onBeforeInput, interceptsinsertCompositionTextevents where the data is a grave-accent lookalike character and a recent dead-key was recorded, then substitutes a literal`and applies surround insertion if a selection is pending.preventDefaultandstopImmediatePropagation.hasCommandModifierandhasRecentDeadKeyDownhelpers to unify modifier checks and dead-key age tests.Macroscope summarized 6e83d9e.