DanTup · GitHub

Reported at #5169 (comment) by @p0mmy:

const a = 0; // a comment without a trailing space
const b = 0; // a comment with a trailing space -> 
void f() {
}

Selecting the second line here and running "Format Selection" results in the function f also being formatted. Like #5169 + #5198 part of the issue here is that we're not minimizing the format edits properly, and the other part is that we fall back to the full document.

The fix for #5169 (https://dart-review.googlesource.com/c/sdk/+/377422) will prevent the full document being formatted, but doesn't address the real issue, which is that the selection also wouldn't be formatted. This is likely another hole in the algorithm for minimizing edits.

Read the original on github.com ↗