Skip to content

Formatting does not produce minimal edits when empty collections are unwrapped onto a single line #5198

@DanTup

Description

@DanTup

Splitting this from #5169 as there are two issues.

  • "Format Selection" can format the entire file #5169 will deal with Format Selection incorrectly formatting the entire document (this should never happen, regardless of whether or not we can minimize the format edits)
  • The formatter unwrapping [\n] should not result in us failing to compute minimal edits

With just the first issue fixed, we'll produce no edits instead of formatting the entire document. However, we should really produce an edit just for unwrapping the empty collection.

Example:

var a = <String>[
];
var b = '';

Should format to:

var a = <String>[];
var b = '';

...without falling back to full-document formats.

Currently it fails because the start code gets two tokens (an open bracket and a close bracket) but the end code gets a single simpletoken that is [].

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