-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Wrong indentation in argument of method when followed by chained method (promises) #1651
Comments
This is an interesting problem. Note, the following works as one would expect: new Promise((resolve, reject) => {
setTimeout(resolve, 100);
}).then(() => {}); The newline between the Technically, the expression is continuing across multiple lines, so the indenting as it stands makes sense. But I can also see where adding a newline after the I'd forgotten, but back in #621 someone requested something similar to this. The more common request is: new Promise((resolve, reject) => {
setTimeout(resolve, 100);
})
.then(() => {}); I'd expect new Promise((resolve, reject) => {
setTimeout(resolve, 100);
})
.then(() => {}); |
@HanabishiRecca said:
Yes, there is a general bug but it is a little hard to nail down. Let's expand this slightly. Similar to what I said above this remains unchanged: getNum(() => {
return 15;
}) + getNum(() => {
return 10;
}) - 5; So does this: getNum(() => {
return 15;
}) + getNum(() => {
return 10;
}) - (
5
); But (for the same reason as in this issue) the following indents: // A1
getNum(() => {
return 15;
}) + getNum(() => {
return 10;
}) -
5; The is because the Statement To be clear, the argument for the following indentation also has validity: // A2
getNum(() => {
return 15;
}) + getNum(() => {
return 10;
}) -
5; But i don't see how this is valid: // A3
getNum(() => {
return 15;
}) + getNum(() => {
return 10;
}) -
5; What should this look like? // B1
getNum(() => {
return 15;
}) + getNum(() => {
return 10;
}) -
getNum(() => {
return 15;
}) + getNum(() => {
return 10;
}) -
5;
// B2 ?
getNum(() => {
return 15;
}) + getNum(() => {
return 10;
}) -
getNum(() => {
return 15;
}) + getNum(() => {
return 10;
}) -
5; |
I can just suggest variants: |
Similar if not duplicate of #886. |
Description
When dealing with chaining there are a lot of opinions. But I, and the folks on Gitter, think that this is a bug.
Input
The code looked like this before beautification:
Expected Output
The code should have looked like this after beautification (unchanged):
Actual Output
The code actually looked like this after beautification (extra indentation on line 2 & 3):
Steps to Reproduce
Run Beautify on the code above
Environment
OS: Windows 10
Runtime env: VSCode
Settings
The text was updated successfully, but these errors were encountered: