Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

fix(core): correct deletion index calculation for char indices#668

Merged
morgante merged 3 commits intobiomejs:mainfrom
caiuswang:bugfix/error-check-index-range
Dec 1, 2025
Merged

fix(core): correct deletion index calculation for char indices#668
morgante merged 3 commits intobiomejs:mainfrom
caiuswang:bugfix/error-check-index-range

Conversation

@caiuswang
Copy link
Contributor

@caiuswang caiuswang commented Nov 23, 2025

Which problem is this PR solving?

Short description of the changes

  • error code is below:
image

Change

  • Don't compare char index with byte index—just use char_indices to get the actual byte index instead.

How to verify that this has the expected result

add test:

  • rewrite_pattern_correct_with_utf8_content
  • rewrite_pattern_remove_dangling_comma_with_utf8_content

Update get_deletion_indices to use byte indices instead of char indices
when checking deletion ranges. This ensures accurate handling of Unicode
characters and prevents off-by-one errors during range checks.
@caiuswang caiuswang force-pushed the bugfix/error-check-index-range branch from 3b69346 to e8993dc Compare November 23, 2025 06:55
@caiuswang caiuswang force-pushed the bugfix/error-check-index-range branch from 2b1b47c to 40b72f6 Compare November 23, 2025 09:25
Copy link
Collaborator

@morgante morgante left a comment

Choose a reason for hiding this comment

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

@caiuswang caiuswang requested a review from morgante December 1, 2025 04:26
@morgante morgante merged commit f279bb1 into biomejs:main Dec 1, 2025
5 checks passed
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