gh-142162: Make PyREPL navigate and edit by grapheme cluster#145332
Open
kovan wants to merge 2 commits intopython:mainfrom
Open
gh-142162: Make PyREPL navigate and edit by grapheme cluster#145332kovan wants to merge 2 commits intopython:mainfrom
kovan wants to merge 2 commits intopython:mainfrom
Conversation
Backspace, delete, and arrow keys now operate on grapheme clusters (e.g. base character + combining accents) rather than individual Unicode codepoints. This uses unicodedata.iter_graphemes() (new in 3.15) to find cluster boundaries, so one keypress deletes or skips an entire visual character like é (e + U+0301). Changes: - Add prev_grapheme_boundary/next_grapheme_boundary helpers to Reader - Update left, right, backspace, delete commands in commands.py - Update backspace_dedent in readline.py for the non-dedent case Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The iter_graphemes API is new in 3.15 and not yet in mypy's typeshed stubs, so mypy reports attr-defined and no-any-return errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
e+ U+0301).prev_grapheme_boundary()/next_grapheme_boundary()helpers toReader, usingunicodedata.iter_graphemes()(new in 3.15) to find cluster boundaries.left,right,backspace,deleteincommands.pyandbackspace_dedentinreadline.py.Test plan
test_reader.pycovering combining characters, multi-codepoint grapheme clusters, and ASCII regressionpython -m test test_pyreplpasses (253 tests, 0 failures)🤖 Generated with Claude Code