Skip to content

Don't create overlapping changes when doing additional formatting#11413

Merged
davidwengier merged 4 commits intodotnet:mainfrom
davidwengier:StopOverlappingRangesInFormatting
Jan 24, 2025
Merged

Don't create overlapping changes when doing additional formatting#11413
davidwengier merged 4 commits intodotnet:mainfrom
davidwengier:StopOverlappingRangesInFormatting

Conversation

@davidwengier
Copy link
Copy Markdown
Member

@davidwengier davidwengier commented Jan 24, 2025

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2347107

First commit fixes the bug in the new formatting engine where we sometimes create overlapping edits, and instead now we drop those edits on the floor, so at least most of the file will format correctly.
Second commit then fixes the actual formatting issue with the code in hand, which means we no longer have overlapping edits in the first place.

@davidwengier davidwengier requested a review from a team as a code owner January 24, 2025 00:52
}

if (closeBraceNode.TryGetLinePositionSpanWithoutWhitespace(source, out var closeBraceRange) &&
if (closeBraceNode.Span.Length > 0 &&
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Without this line, the test on the syntactically invalid document failed, because the compiler apparently adds an empty node at position 0 for the close brace on an invalid document.

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