Fix eol handling on the last token in a file when formatting code actions#79602
Fix eol handling on the last token in a file when formatting code actions#79602CyrusNajmabadi merged 14 commits intodotnet:mainfrom
Conversation
| /// or follows, then we expand to consume at least the full span of the <paramref name="firstToken"/> and | ||
| /// <paramref name="lastToken"/> so that we at least will try to format any trivia on them. | ||
| /// </summary> | ||
| internal static TextSpan GetSpanIncludingPreviousAndNextTokens(SyntaxToken firstToken, SyntaxToken lastToken) |
There was a problem hiding this comment.
the thing we're fixing is that we injected a final } into the file with an elastic-cr-lf (this is good).
However, the formatting engine wasn't ever fixing up that elastic-cr-lf because the code below effectively said "only format up to the exact end of the }, no further". This was happening because we normally try to find the 'next' token after the last touched token and format through that. But in this case, there is no next token (it's the last token in the file). So the fix is in that case to consider up through the full end of the token (which includes the trailing trivia) so we will update that properly.
| throw new System.NotImplementedException(); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Is this because we are handling InsertFinalNewLine correctly now?
| } | ||
| } | ||
| </Document> | ||
| </Document> |
There was a problem hiding this comment.
What caused this indentation change?
There was a problem hiding this comment.
The doc is getting formatted, and tha tcleans up the errant final whitespace we weren't touching before.
Fixes #79584