Skip to content

Formatting a selection with trailing whitespace in a comment doesn't work #5200

@DanTup

Description

@DanTup

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions