Skip to content

fix: correctly count tabs for first patch line#373

Merged
Muscraft merged 2 commits intorust-lang:mainfrom
scrabsha:fix-371
Mar 4, 2026
Merged

fix: correctly count tabs for first patch line#373
Muscraft merged 2 commits intorust-lang:mainfrom
scrabsha:fix-371

Conversation

@scrabsha
Copy link
Copy Markdown
Contributor

@scrabsha scrabsha commented Feb 28, 2026

Fixes a bug introduced in #357 (reported in #371).

When computing the indent of the first line of a patch, we must be careful and consider all the line, including the characters preceding the patch itself. Not doing this results in shifted highlighting for the first line of the snippet.

First commit adds the repro described in the issue. Second commit is the fix.

@scrabsha scrabsha force-pushed the fix-371 branch 2 times, most recently from c53533a to 231f16c Compare February 28, 2026 16:18
@scrabsha scrabsha changed the title take leading characters into account when computing first snippet line indent fix: correctly count tabs for first patch line Feb 28, 2026
Copy link
Copy Markdown
Member

@Muscraft Muscraft left a comment

Choose a reason for hiding this comment

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

These types of bugs can be tricky to find and fix, so thank you for working on this! I also want to thank you for making me take another look at this part of the codebase, as it helped me find a few other bugs that I missed when reviewing #357.

@Muscraft Muscraft merged commit 972df9c into rust-lang:main Mar 4, 2026
16 checks passed
@scrabsha scrabsha deleted the fix-371 branch March 4, 2026 07:09
@scrabsha
Copy link
Copy Markdown
Contributor Author

scrabsha commented Mar 4, 2026

hehe, thank you for your work! i'm having a ton of fun poking at the codebase and learning so many things :) if you find bugs in the future and don't have the time to fix them, let me know: i'd love to help :D

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