[Bug] Vertical editor navigation loses the visual column after wide Unicode characters #1419
Lauritz-Timm
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Affected area
Terminal UI prompt editor
What happened?
Moving the cursor vertically between prompt lines does not preserve the terminal column when the source line contains a wide Unicode character.
For example, a cursor immediately after the CJK character
你is displayed at visual column 2. Pressing Down to move to an ASCII line places it at string offset 1 instead of visual column 2. Subsequent input is inserted one terminal column too far to the left.Steps to reproduce
On a source checkout, run:
Current output:
The cursor is visually two columns from the start before Down, so inserting
Xafter moving to the second line should place it afterb, not aftera.Expected behavior
Vertical Up and Down movement should preserve the displayed terminal column across lines. In this example, Down should move to column 2 of
abcd, and the resulting text after insertingXshould be"你a\nabXcd".Prime Agent version
Current
mainat97b994c3d7c45ca1ae635190e91e9e58ddf2577cEnvironment
Fedora Linux x86_64, Node.js v22.23.1
Additional context
The editor stores cursor positions and visual-line segment boundaries as UTF-16 string offsets.
moveToVisualLine()derives its preferred “visual” column by subtracting those offsets, so a width-2 grapheme is counted as one column. Combining graphemes can produce the inverse mismatch.I can add a focused editor regression and a narrow fix if maintainers want this behavior changed and invite the implementation.
All reactions