Skip to content

fix: use utf8.DecodeLastRuneInString to correctly handle multi-byte runes in setLastNonTriviaPosition - #3712

Merged
Gabriela Araujo Britto (gabritto) merged 1 commit into
microsoft:mainfrom
a-tarasyuk:fix/3700_decode-last-rune-in-string
May 5, 2026
Merged

fix: use utf8.DecodeLastRuneInString to correctly handle multi-byte runes in setLastNonTriviaPosition#3712
Gabriela Araujo Britto (gabritto) merged 1 commit into
microsoft:mainfrom
a-tarasyuk:fix/3700_decode-last-rune-in-string

Conversation

@a-tarasyuk

@a-tarasyuk Oleksandr Tarasiuk (a-tarasyuk) commented May 5, 2026

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings May 5, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect tracking of the last non-trivia text position when emitted text ends with a multi-byte whitespace rune (previously treated byte-by-byte), improving correctness of position assignment for printed nodes.

Changes:

  • Update setLastNonTriviaPosition to trim trailing whitespace using utf8.DecodeLastRuneInString instead of indexing bytes.
  • Adjust position delta calculation to subtract the correct number of bytes removed.

Comment thread internal/printer/changetrackerwriter.go
Merged via the queue into microsoft:main with commit 2a41760 May 5, 2026
24 of 25 checks passed
Jake Bailey (jakebailey) pushed a commit to jakebailey/TypeScript that referenced this pull request Aug 13, 2026
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.

3 participants