-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Trim trailing whitespace #5023
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
Trim trailing whitespace #5023
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 |
---|---|---|
|
@@ -53,3 +53,4 @@ internal/ | |
.settings | ||
.vscode/* | ||
!.vscode/tasks.json | ||
.idea/* | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -833,6 +833,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi | |
} | ||
|
||
for (let i = 0; i < count; i++) { | ||
let node = nodes[start + i]; | ||
|
||
if (multiLine) { | ||
if (i || leadingComma) { | ||
write(","); | ||
|
@@ -841,10 +843,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi | |
} | ||
else { | ||
if (i || leadingComma) { | ||
write(", "); | ||
write(","); | ||
|
||
let comments = getLeadingCommentsToEmit(node); | ||
|
||
if (!comments || !comments[0].hasTrailingNewLine) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you not just check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe @yuit could weigh in on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the variable |
||
write(" "); | ||
} | ||
} | ||
} | ||
let node = nodes[start + i]; | ||
// This emitting is to make sure we emit following comment properly | ||
// ...(x, /*comment1*/ y)... | ||
// ^ => node.pos | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,6 @@ foo(/*c3*/ function () { }, /*d2*/ function () { }, /*e2*/ a + b); | |
foo(/*c3*/ function () { }, /*d3*/ function () { }, /*e3*/ (a + b)); | ||
foo( | ||
/*c4*/ function () { }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the original issue seems more specific - #4629 Fixing all trailing spaces in all scenarios seems like much larger effort than the tag "easy" suggests... ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yuit: Anyway, yes, there is a trailing space. I'll have a look if I can fix it. (Tomorrow) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Edit : I accidentally delete my original comment. @MartyIX yes fixing all trailing spaces in all scenario are harder problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After looking through I find the reason of this behavior so foo(
/*c4*/ function () { },
/*d4*/() => { },-> /*d4*/ is a leading comment with hasTrailingNewLine false
/*e4*/
/*e5*/ "hello"); -> /*e4*/ is a leading comment with hasTrailingNewLine true (as your change check the first comment |
||
/*d4*/ function () { }, | ||
/*d4*/ function () { }, | ||
/*e4*/ | ||
/*e5*/ "hello"); |
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.
Is this for WebStorm?
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.
Yes, it is actually for the family of IDEs from JetBrains - PhpStorm, WebStorm, etc.