Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the static error test updater not write comments at column zero.
The old formatter had a special rule that if a line comment as at the left edge of the page, it would stay there regardless of the surrounding indentation. So if you had: ``` class C { m() { // comment } } ``` After formatting, the comment would still be there instead of being indented. The intent of that was to not shift over code that had been commented out. But all of the IDEs I tested don't actually work that way. When they comment out code, they tend to put the `//` at the indentation of the surrounding code. So the new formatter doesn't have this special rule and always indents line comments following the surrounding indentation. This is good because it also means that code generators that don't write any leading whitespace will still get nicely formatted comments. However, the static error test updater took advantage of this rule and would write static error marker comments at column zero if needed to get the carets to align with the code on the previous line and assume that the formatter wouldn't move the comment. This fixes the static error test updater. It always writes comments using indentation from the previous line of code and if the caret doesn't fit that way, it uses an explicit column marker. Fix #57042. Change-Id: I40fd7cd19d08dc228b6a6797e6a26965d1343d32 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394363 Reviewed-by: Nate Bosch <[email protected]> Auto-Submit: Bob Nystrom <[email protected]> Commit-Queue: Nate Bosch <[email protected]>
- Loading branch information