It seems that the formatter chooses to count the length of a comment on the same line as code towards the total line length for formatting purposes?
I would expect the formatter to leave the comment as is, if the line of code preceding it is equal to or shorter than the configured page width.
Given the example below, where the comma at the end of the line of code is at 36 characters,
but the entire line, including the period at the end of the comment is 111 characters.
What input code did you provide to the formatter?
void main() {
final knownCrossImports = [];
test(
skip: knownCrossImports.isEmpty, // [intended]: No message is needed when there are no known cross imports.
);
}
void test({required bool skip}) {}
What output did the formatter produce?
void main() {
final knownCrossImports = [];
test(
skip: knownCrossImports
.isEmpty, // [intended]: No message is needed when there are no known cross imports.
);
}
void test({required bool skip}) {}
What output did you expect or want the formatter to produce?
Describe how you expected the formatter to format the code, ideally by showing what you had in mind as code.
void main() {
final knownCrossImports = [];
test(
skip: knownCrossImports.isEmpty, // [intended]: No message is needed when there are no known cross imports.
);
}
void test({required bool skip}) {}
Anything else we should know?
This came up in flutter/flutter#185493 due to the formatter chopping off the [intended] comment, which caused the skip test validation to fail.
The page width in flutter/flutter is set to 100.
This reproduces on 3.13.0-93.0.dev
It seems that the formatter chooses to count the length of a comment on the same line as code towards the total line length for formatting purposes?
I would expect the formatter to leave the comment as is, if the line of code preceding it is equal to or shorter than the configured page width.
Given the example below, where the comma at the end of the line of code is at 36 characters,
but the entire line, including the period at the end of the comment is 111 characters.
What input code did you provide to the formatter?
What output did the formatter produce?
What output did you expect or want the formatter to produce?
Describe how you expected the formatter to format the code, ideally by showing what you had in mind as code.
Anything else we should know?
This came up in flutter/flutter#185493 due to the formatter chopping off the
[intended]comment, which caused the skip test validation to fail.The page width in flutter/flutter is set to 100.
This reproduces on 3.13.0-93.0.dev