-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Indentation fix for multi-line call expression #3179
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
Indentation fix for multi-line call expression #3179
Conversation
Hey @saschanaz, thanks for the PR - could you take a look at this as well @vladima? |
case SyntaxKind.ArrowFunction: | ||
case SyntaxKind.FunctionExpression: | ||
case SyntaxKind.ArrayLiteralExpression: | ||
case SyntaxKind.ObjectLiteralExpression: |
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.
getContainingList
already covers all these cases. Perhaps the logic should be moved into there.
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.
You're right, I'll think about this more.
I tried some generalization. |
} | ||
return Value.Unknown; | ||
|
||
function getStartingExpression(expression: CallExpression) { |
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.
argument type should really be a union of PropertyAccessExpression | CallExpression | ElementAccessExpression
. Now it works by chance because all these types have similarly named property expression
.
@saschanaz Hey, sorry for the delay, thanks for reporting this issue and submitting the fix proposal! The idea of the fix (take actual indentation if |
It seems I need some help to make a decision, as my latest commit breaks var ig: ig;
ig.module(
'mything'
).requires(
'otherstuff'
).defines(/*0*//*1*/
}); Inserting newline on 1 gives the line an indentation and so this becomes: var ig: ig;
ig.module(
'mything'
).requires(
'otherstuff'
).defines(/*0*/ // (indented)
/*1*/ // Problem: Test expects 4 spaces here but now there are 8.
}); It now gets 8-space indentation because the previous line already have 4 spaces. Should I just fix the test value and move on? Post it as a separate issue? Or should I fix the indentation? PS: Oh, now there is a post for this. #3436 |
Let's just fix the test as there is no other opinion. |
Sorry for the delay @saschanaz, sometimes it's easy for us to lose track. @vladima has been especially busy on certain critical bugs, but I'll see if I can discuss it with him tomorrow. |
@saschanaz sorry for the delay. @vladima is the best one to review this change. he has been heads down on some perf and memory issues and he should be back online early next week. sorry again for the delay. |
return Value.Unknown; | ||
|
||
function getStartingExpression(expression: PropertyAccessExpression | CallExpression | ElementAccessExpression) { | ||
while (expression.expression) |
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.
wrap loop body in curlies and add a check that Node.kind
is equal to PropertyAccess
/ ElementAccess
/ CallExpression
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.
add tests for that will touch all codepaths
Thanks @saschanaz! and sorry for the long delay. between release-1.5 stabilization and issues, and release-1.6 planning and feature work thing just fell through. hopefully future PRs would not have to wait that long. thanks again. |
Thanks @saschanaz ! |
Great! Should I PR some more changes as @vladima commented? |
I took care of the comments as I manually merged it. |
(Related to #1888)
I don't know how to name them, but this fixes a remaining indenting problem with array/function/object literals. This problem is not covered by #3001.