TypeScript
TypeScript copied to clipboard
Fix to aggressive indentation for ternary operator #3676
Fixes #3676
- This PR provides a solution to the aggressive indentation for nested conditional expressions using a specific style (issue #3676). Instead of using a one-liner, the style keeps the true branch in the same line as its associated condition but the false branch in the next line. Without the changes in this PR, the false branch gets mistakenly indented. This PR corrects the behavior by specifying this category of style in the function
nodeWillIndentChildinsmartindenter.ts. - The added unit test includes examples mentioned in the original issue and discussion.
- The solution does not address the "different, but similar" example in the last comment on May 31, 2019. I'm not sure if it's opened as a separate issue already? Also, when I stepped through that example, it appears that the issue might be more related to how context node is assigned to child node, and how indentation, delta, node start position get inherited/recalculated with nested, mixed types.
- As of now, the code is up to date and all tests, including the new test, passed locally.
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.
@microsoft-github-policy-service agree
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.
https://github.com/microsoft/TypeScript/issues/3676