* lisp/progmodes/typescript-ts-mode.el:
(typescript-ts-mode--indent-rules): Make sure each new ternary
branch is aligned with the previous one.
* test/lisp/progmodes/typescript-ts-mode-resources/indent.erts:
(Chained ternary expressions): New test.
(cherry picked from commit
c80fbe3f2355ab7182dcba98ed9717f0231aab00)
((and (parent-is "comment") c-ts-common-looking-at-star)
c-ts-common-comment-start-after-first-star -1)
((parent-is "comment") prev-adaptive-prefix 0)
- ((parent-is "ternary_expression") parent-bol typescript-ts-mode-indent-offset)
+ ((parent-is "ternary_expression") standalone-parent typescript-ts-mode-indent-offset)
((parent-is "member_expression") parent-bol typescript-ts-mode-indent-offset)
((parent-is "named_imports") parent-bol typescript-ts-mode-indent-offset)
((parent-is "statement_block") parent-bol typescript-ts-mode-indent-offset)
};
=-=-=
+Name: Chained ternary expressions
+
+=-=
+const a = cond1 ? 1
+ : cond2 ? 2
+ : cond3 ? 3
+ : 4;
+=-=-=
+
Code:
(lambda ()
(setq tsx-ts-mode-indent-offset 2)