Fix formatting of mixed indentation in VS Code#12418
Merged
davidwengier merged 9 commits intodotnet:mainfrom Oct 31, 2025
Merged
Fix formatting of mixed indentation in VS Code#12418davidwengier merged 9 commits intodotnet:mainfrom
davidwengier merged 9 commits intodotnet:mainfrom
Conversation
Revert Apply suggestions from code review Compute a word diff at the start of Html formatting
ToddGrun
reviewed
Oct 30, 2025
|
|
||
| var length = oldWord.Length; | ||
|
|
||
| // Copy the text into char arrays for comparison. Note: To avoid allocation, |
Contributor
Member
Author
There was a problem hiding this comment.
Yeah, this and LineDiffer are very similar other than the creation of the arrays, and the types within, but CharDiffer is quite different. Will move as much down as reasonable.
Member
Author
There was a problem hiding this comment.
Actually, this is a bit annoying, and ends up having stuff in the base class that makes no sense to be there. What would be nicer is if both Word and Line differs were both TextSpanDiffers, with different create methods, but I'll do that in a separate PR.
Member
Author
There was a problem hiding this comment.
Actually, I take that back, creating TextSpanDiffer is actually pretty simple.
ToddGrun
reviewed
Oct 30, 2025
|
|
||
| if (changes.Length > 0) | ||
| { | ||
| // There is a lot of uncertainty when we're dealing with edits that come from the Html formatter |
Contributor
ToddGrun
reviewed
Oct 30, 2025
| // or slashes, so we can keep it simple and just capture a "word" when the classification of | ||
| // the current character changes. | ||
| var index = 1; | ||
| while (index < text.Length) |
Contributor
This was referenced Oct 31, 2025
This was referenced Nov 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12416, reported by @Peter-Juhasz on Discord
When a file has mixed indentation, VS Code sends across edits that include changes to content, presumably for brevity, but the Html formatter doesn't know about C#, and so changing content breaks it. To fix it, we run the edits through our source text differ, doing a diff at the word level so movements of C# (which Html sees as either tildes or a comment) end up being identical, and therefore the edits can be safely discarded.