Skip to content

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

Closed

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.

Activity

  1. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Jul 24, 2024
  2. added this to the v3.94.0 milestone on Jul 24, 2024
  3. changed the title [-]Formatting a selection with trailing whitespace after a comment doesn't work[/-] [+]Formatting a selection with trailing whitespace in a comment doesn't work[/+] on Jul 24, 2024
  4. DanTup commented on Jul 25, 2024

    @DanTup
    MemberAuthor

    Fixed by dart-lang/sdk@b8c5f81, ships in a future Dart/Flutter SDK.

  5. added
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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