Skip to content

fix: correct logical keys, cleared text edits, and highlight ranges - #106

Open
leoafarias wants to merge 2 commits into
mainfrom
cursor/input-text-editing-correctness-6750
Open

leoafarias wants to merge 2 commits into
mainfrom
cursor/input-text-editing-correctness-6750

Conversation

@leoafarias

@leoafarias leoafarias commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

LogicalKeyboardKey.forCharacter

Non-BMP characters were folded through a 29-bit hash, so U+1F600 and U+1F9E1 compared equal and a Shortcuts trigger could match the wrong key.

Repro: packages/noir/test/core/logical_keyboard_key_test.dart. It failed on the hashed id (0x200000000 + 0x1b0d63 for both emoji) and on two multi-scalar strings that share that hash.

Fix: one Unicode scalar uses 0x200000000 + scalar, above the named-key range. == and hashCode include keyLabel, so a multi-scalar string is identified by its text as well as the hashed id.

Lines: input.dart +19/−3, test +28/−0.

TextEditingController

A fresh controller’s selection is collapsed(-1). insert and deleteForward threw RangeError, deleteBack returned false, and moveCursorRight skipped offset 0.

Repro: packages/noir/test/foundation/text_editing_controller_test.dart. It failed with RangeError from String.replaceRange.

Fix: edits return false and movement returns until selectionWithinText.

Lines: text_editing_controller.dart +11/−0, test +31/−0.

TextHighlight

The range check was only an assert, so release mode accepted a reversed or negative span.

Fix: RenderParagraph’s constructor and setter call _validatedSelection, which throws ArgumentError. The const assert stays.

No test. Every invalid range throws from that assert before the setter can see it, and the release-only path needed a subprocess probe. That probe is removed.

Lines: paragraph.dart +19/−3.

Open in Web Open in Cursor 

Give one Unicode scalar a direct logical-key id so distinct emoji do not
compare equal, ignore text edits and cursor movement while the selection
is cleared, and reject reversed TextHighlight ranges in release mode.

Co-authored-by: Leo Farias <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T15:11:06.498210Z 389d700 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

The const assert rejects the same ranges, so an in-process test cannot
reach the release check. Keep the ArgumentError in RenderParagraph.

Co-authored-by: Leo Farias <[email protected]>

This branch has not been deployed

No deployments
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