Skip to content

Fix full-width character alignment#1593

Open
Selina-0017 wants to merge 1 commit into
lark-parser:masterfrom
Selina-0017:fix-fullwidth-error-location
Open

Fix full-width character alignment#1593
Selina-0017 wants to merge 1 commit into
lark-parser:masterfrom
Selina-0017:fix-fullwidth-error-location

Conversation

@Selina-0017
Copy link
Copy Markdown

Summary

Fix incorrect caret alignment in error context rendering when input contains full-width Unicode characters (e.g. Chinese characters).

Previously, caret positioning used character length (len()), which does not reflect terminal display width for full-width characters.

This caused misaligned error indicators in UnexpectedInput.get_context().

Changes

  • Replace naive character-count spacing with display-width-aware computation
  • Add regression test for full-width Unicode input

Testing

  • Added test covering full-width character alignment
  • All existing tests pass

Notes

No external dependencies added. Uses Python standard library only.

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.

1 participant