-
-
Notifications
You must be signed in to change notification settings - Fork 867
fix(formatter): incorrect printing of class binding trailing comments #16234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,10 @@ | ||||||
| export class Cls /* YES */ { | ||||||
| // class body comment | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| export class Mutliline /* Y | ||||||
|
||||||
| export class Mutliline /* Y | |
| export class Multiline /* Y |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| --- | ||
| source: crates/oxc_formatter/tests/fixtures/mod.rs | ||
| --- | ||
| ==================== Input ==================== | ||
| export class Cls /* YES */ { | ||
| // class body comment | ||
| } | ||
|
|
||
|
|
||
| export class Mutliline /* Y | ||
|
||
| E | ||
| S */ { | ||
| // class body comment | ||
| } | ||
|
|
||
| ==================== Output ==================== | ||
| ------------------ | ||
| { printWidth: 80 } | ||
| ------------------ | ||
| export class Cls /* YES */ { | ||
| // class body comment | ||
| } | ||
|
|
||
| export class Mutliline /* Y | ||
|
||
| E | ||
| S */ { | ||
| // class body comment | ||
| } | ||
|
|
||
| ------------------- | ||
| { printWidth: 100 } | ||
| ------------------- | ||
| export class Cls /* YES */ { | ||
| // class body comment | ||
| } | ||
|
|
||
| export class Mutliline /* Y | ||
|
||
| E | ||
| S */ { | ||
| // class body comment | ||
| } | ||
|
|
||
| ===================== End ===================== | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition checks if there are any block comments (
!c.is_line()), but then formats ALL leading comments, including line comments. This seems inconsistent - either filter to only format block comments, or change the condition to check if there are any comments at all.Consider one of these approaches:
write!(f, FormatLeadingComments::Comments(&leading_comments.iter().filter(|c| !c.is_line()).collect::<Vec<_>>()));if !leading_comments.is_empty() { ... }