Skip to content

Fix to aggressive indentation for ternary operator #3676#61430

Closed
wukongO-O wants to merge 6 commits intomicrosoft:mainfrom
wukongO-O:main
Closed

Fix to aggressive indentation for ternary operator #3676#61430
wukongO-O wants to merge 6 commits intomicrosoft:mainfrom
wukongO-O:main

Conversation

@wukongO-O
Copy link
Copy Markdown

@wukongO-O wukongO-O commented Mar 15, 2025

Fixes #3676

  • This PR provides a solution to the aggressive indentation for nested conditional expressions using a specific style (issue Indentation is too aggressive for ternary operator #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 nodeWillIndentChild in smartindenter.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.

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Mar 15, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 15, 2025
@typescript-bot
Copy link
Copy Markdown
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@wukongO-O
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@wukongO-O
Copy link
Copy Markdown
Author

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

#3676

@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Mar 16, 2025
@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Indentation is too aggressive for ternary operator

3 participants