-
Notifications
You must be signed in to change notification settings - Fork 130
Description
Dart-format should remove unnecessary trailing whitespace, also if it's the first line of a multiline string literal.
The syntax allows whitespace, and backslash-preceded whitespace, to be ignored if it's the only thing on the first line of a multiline string literal. The trailing newline of that line is also ignored, but that's probably wanted to preserve formatting,
but the backslash/whitespace characters have no effect other than be ignored.
Example:
// Source of string literal contains: space, backslash, space, tab, backslash, tab, backslash, newline, z
var string = """ \ \ \
z""";
print(string.length); // 1 - only the `z` counts.
All the whitespace, and backslash-preceded whitespace (I don't want to call it "escaped", because it isn't, it works in raw strings too), is ignored, and the string has the same behavior and formatting without it. It is really just "trailing whitespace," and therefore I think Dart Format should remove it.
(It's a very specific exception that leading/trailing (so, only) whitespace is ignored on only the first line, but any trailing whitespace on the following lines is included. It makes sense only because it leads up to a newline which is also ignored, and allowing the string proper to begin on the next line is a good feature. But the extra allowed whitespace is just noise and can safely be removed.)