-
Notifications
You must be signed in to change notification settings - Fork 13k
Fix nested ternary operator indentation issue #62537
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
base: main
Are you sure you want to change the base?
Conversation
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
@harshith1118 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Your before and after look the same. |
Summary
This PR fixes the indentation issue with nested ternary expressions in TypeScript code. Previously, nested
ternary operations were getting increasingly indented, causing poor readability. This change ensures that
nested ternary expressions align at the same indentation level, improving code formatting consistency.
Details
The fix modifies the logic in src/services/formatting/smartIndenter.ts within the
childIsUnindentedBranchOfConditionalExpression function. Previously, when handling nested ternary
expressions (conditional expressions), the formatter was not properly handling the alignment of subsequent
ternary operations in a chain.
Before:
1 var current =
2 0 ? 1 :
3 2 ? 3 :
4 4;
After:
1 var expected =
2 0 ? 1 :
3 2 ? 3 :
4 4;
Tests
Code Review