Skip to content

fix formatting for chained callbacks #3001

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

Merged
merged 3 commits into from
May 4, 2015
Merged

Conversation

vladima
Copy link
Contributor

@vladima vladima commented May 2, 2015

fixes #1917, #1888

foo
    .bar(() = {
     })

in cases like this nodes are processed in order: CallExpresson -> PropertyAccess and its child nodes -> ParameterList and its child nodes. Fact that indentation was inserted before the '.' during processing of PropertyAccess should be respected later when we return back to CallExpression and dive into ParameterList however this is something that was missed.

In this PR when token is indented we record line/indentation and later when computing indentation for the node check if current line was already indented and if yes - use actual indentation.

@@ -416,7 +419,7 @@ module ts.formatting {
// if node is located on the same line with the parent
// - inherit indentation from the parent
// - push children if either parent of node itself has non-zero delta
indentation = parentDynamicIndentation.getIndentation();
indentation = startLine === lastIndentedLine ? indentationOnLastIndentedLine : parentDynamicIndentation.getIndentation();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split into multiple lines

@@ -416,7 +419,9 @@ module ts.formatting {
// if node is located on the same line with the parent
// - inherit indentation from the parent
// - push children if either parent of node itself has non-zero delta
indentation = parentDynamicIndentation.getIndentation();
indentation = startLine === lastIndentedLine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray space after =

@vladima
Copy link
Contributor Author

vladima commented May 4, 2015

@DanielRosenwasser any other notes?

@mhegazy
Copy link
Contributor

mhegazy commented May 4, 2015

👍

vladima added a commit that referenced this pull request May 4, 2015
@vladima vladima merged commit bd47ae4 into master May 4, 2015
@vladima vladima deleted the formattingOnChainedCallbacks branch May 4, 2015 19:46
@ghost
Copy link

ghost commented May 4, 2015

👍

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeScript 1.4 indentation issue on chained function calls
4 participants