Skip to content

fix: respect useTabs when aligning wrapped nested ternary conditions - #1134

Open
hoanle0126 wants to merge 1 commit into
jhipster:mainfrom
hoanle0126:fix/ternary-condition-use-tabs-947
Open

hoanle0126 wants to merge 1 commit into
jhipster:mainfrom
hoanle0126:fix/ternary-condition-use-tabs-947

Conversation

@hoanle0126

Copy link
Copy Markdown

Fixes #947

Summary

When a nested ternary expression is in the alternative position (else branch) and its condition wraps across multiple lines (e.g. a binary expression inside the condition), printTernaryTest aligned the wrapped condition lines with align(2, printed) unconditionally. When useTabs: true is configured, align(2, ...) inserts two literal space characters instead of a tab, producing mixed tabs and spaces on the wrapped condition line.

Changes

  • Pass options to printTernaryTest in src/printers/expressions.ts and use options.useTabs ? indent(printed) : align(2, printed) (matching printBranch in the same file).
  • Add unit test coverage in both test/unit-test/conditional-expression/spaces and test/unit-test/conditional-expression/tabs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.10.0] Outputs spaces instead of tabs

1 participant