typescript-ts-mode: align ternary-chain branches (bug#78187)
* 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.
This commit is contained in:
committed by
Yuan Fu
parent
16bfbc6fe3
commit
c80fbe3f23
@@ -118,7 +118,7 @@ Argument LANGUAGE is either `typescript' or `tsx'."
|
||||
((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)
|
||||
|
||||
@@ -93,6 +93,15 @@ const foo = () => {
|
||||
};
|
||||
=-=-=
|
||||
|
||||
Name: Chained ternary expressions
|
||||
|
||||
=-=
|
||||
const a = cond1 ? 1
|
||||
: cond2 ? 2
|
||||
: cond3 ? 3
|
||||
: 4;
|
||||
=-=-=
|
||||
|
||||
Code:
|
||||
(lambda ()
|
||||
(setq indent-tabs-mode nil)
|
||||
|
||||
Reference in New Issue
Block a user