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 [].