[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 ab126284081: Fix typescript-ts-mode indentation for switch stat
From: |
Eli Zaretskii |
Subject: |
emacs-29 ab126284081: Fix typescript-ts-mode indentation for switch statements |
Date: |
Wed, 29 Nov 2023 09:33:11 -0500 (EST) |
branch: emacs-29
commit ab126284081cd1f6a3317dc1e94636bf17af2375
Author: nverno <noah.v.peart@gmail.com>
Commit: Eli Zaretskii <eliz@gnu.org>
Fix typescript-ts-mode indentation for switch statements
* lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode): Add
indentation rule for switch case and default keywords. (Bug#67488)
---
lisp/progmodes/typescript-ts-mode.el | 3 +++
.../progmodes/typescript-ts-mode-resources/indent.erts | 17 +++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/lisp/progmodes/typescript-ts-mode.el
b/lisp/progmodes/typescript-ts-mode.el
index a2b16d1beea..0fbac709c63 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -107,6 +107,9 @@ Argument LANGUAGE is either `typescript' or `tsx'."
((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)
+ ((or (node-is "case")
+ (node-is "default"))
+ parent-bol typescript-ts-mode-indent-offset)
((parent-is "switch_case") parent-bol typescript-ts-mode-indent-offset)
((parent-is "switch_default") parent-bol typescript-ts-mode-indent-offset)
((parent-is "type_arguments") parent-bol typescript-ts-mode-indent-offset)
diff --git a/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
b/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
index 20f423259b4..7b6185e0386 100644
--- a/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
@@ -45,6 +45,23 @@ const foo = () => {
};
=-=-=
+Name: Switch statement
+
+=-=
+const foo = (x: string) => {
+ switch (x) {
+ case "a":
+ console.log(x);
+ return 1;
+ case "b":
+ return 2;
+ case "c":
+ default:
+ return 0;
+ }
+};
+=-=-=
+
Code:
(lambda ()
(setq indent-tabs-mode nil)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 ab126284081: Fix typescript-ts-mode indentation for switch statements,
Eli Zaretskii <=