Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,15 @@ public async Task<ImmutableArray<TextChange>> ExecuteAsync(FormattingContext con

// We make an optimistic attempt at fixing corner cases.
var cleanupChanges = CleanupDocument(changedContext, linePositionSpanAfterFormatting);
var cleanedText = formattedText.WithChanges(cleanupChanges);
context.Logger?.LogSourceText("AfterCleanupDocument", cleanedText);
var cleanedText = formattedText;

changedContext = await changedContext.WithTextAsync(cleanedText, cancellationToken).ConfigureAwait(false);
if (!cleanupChanges.IsEmpty)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Should probably move this a couple of lines higher, and just set cleanedText to formattedText if the changes are empty. There is no point calling WithChanges or logging the same content again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 2. I did consider originally doing that, but the WithChanges call short circuits if the IA is empty and I wasn't certain whether we wanted the logging call to always happen.

{
cleanedText = formattedText.WithChanges(cleanupChanges);
context.Logger?.LogSourceText("AfterCleanupDocument", cleanedText);

changedContext = await changedContext.WithTextAsync(cleanedText, cancellationToken).ConfigureAwait(false);
}

// At this point we should have applied all edits that adds/removes newlines.
// Let's now ensure the indentation of each of those lines is correct.
Expand Down