emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master ad26461b48d 3/6: Merge from savannah/emacs-29


From: Po Lu
Subject: master ad26461b48d 3/6: Merge from savannah/emacs-29
Date: Thu, 23 Nov 2023 19:48:04 -0500 (EST)

branch: master
commit ad26461b48ddc6d8d07e818b0536674f73f41b22
Merge: 37b18d88bbc 9af03e0e189
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Merge from savannah/emacs-29
    
    9af03e0e189 typescript-ts-mode: Support indentation for conditionals ...
---
 lisp/progmodes/typescript-ts-mode.el               |  5 +++++
 .../typescript-ts-mode-resources/indent.erts       | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/lisp/progmodes/typescript-ts-mode.el 
b/lisp/progmodes/typescript-ts-mode.el
index b976145dbf3..b6d5495adbb 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -124,6 +124,11 @@ Argument LANGUAGE is either `typescript' or `tsx'."
      ((parent-is "arrow_function") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "parenthesized_expression") parent-bol 
typescript-ts-mode-indent-offset)
      ((parent-is "binary_expression") parent-bol 
typescript-ts-mode-indent-offset)
+     ((match "while" "do_statement") parent-bol 0)
+     ((match "else" "if_statement") parent-bol 0)
+     ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") 
"_statement")
+                          "else_clause")))
+      parent-bol typescript-ts-mode-indent-offset)
 
      ,@(when (eq language 'tsx)
         (append (tsx-ts-mode--indent-compatibility-b893426)
diff --git a/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts 
b/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
index 146ee76574e..20f423259b4 100644
--- a/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
@@ -23,6 +23,28 @@ const foo = () => {
 }
 =-=-=
 
+Name: Statement indentation without braces
+
+=-=
+const foo = () => {
+  if (true)
+    console.log("if_statement");
+  else if (false)
+    console.log("if_statement");
+  else
+    console.log("else_clause");
+  for (let i = 0; i < 1; i++)
+    console.log("for_statement");
+  for (let i of [true])
+    console.log("for_in_statement");
+  while (false)
+    console.log("while_statement");
+  do
+    console.log("do_statement");
+  while (false)
+};
+=-=-=
+
 Code:
   (lambda ()
     (setq indent-tabs-mode nil)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]