emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/typescript-mode d8501770f6 103/222: Fix indentation of mul


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode d8501770f6 103/222: Fix indentation of multiple curly braces in sequence.
Date: Sun, 6 Feb 2022 16:59:22 -0500 (EST)

branch: elpa/typescript-mode
commit d8501770f6ebd50bbbaada2c65b19c85564c1d1e
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>

    Fix indentation of multiple curly braces in sequence.
---
 test-files/indentation-reference-document.ts |  6 ++++++
 typescript-mode.el                           | 22 ++++++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/test-files/indentation-reference-document.ts 
b/test-files/indentation-reference-document.ts
index fe06883a14..07ede0318f 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -489,3 +489,9 @@ function foo14(something: string,
 const a =
     1; // Blah
 const b = 2;
+
+function blipblop(): void {
+    {
+        const q = 1;
+    }
+}
diff --git a/typescript-mode.el b/typescript-mode.el
index 12bd16e79c..93da60b2c1 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -2217,14 +2217,28 @@ moved on success."
           ((nth 1 parse-status)
            (let ((same-indent-p (looking-at "[]})]"))
                  (switch-keyword-p (looking-at 
"\\_<default\\_>\\|\\_<case\\_>[^:]"))
-                 (continued-expr-p (typescript--continued-expression-p)))
-             (goto-char (nth 1 parse-status))
+                 (continued-expr-p (typescript--continued-expression-p))
+                 (list-start (nth 1 parse-status)))
+             (goto-char list-start)
              (if (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)")
                  (progn
                    (skip-syntax-backward " ")
-                   (when (or (typescript--backward-to-parameter-list)
-                             (eq (char-before) ?\)))
+                   (cond
+                    ((or (typescript--backward-to-parameter-list)
+                         (eq (char-before) ?\)))
+                     ;; Take the curly brace as marking off the body of a 
function.
+                     ;; In that case, we want the code that follows to see the 
indentation
+                     ;; that was in effect at the beginning of the function 
declaration, and thus
+                     ;; we want to move back over the list of function 
parameters.
                      (backward-list))
+                    ((looking-back "," nil)
+                     ;; If we get here, we have a comma, spaces and an opening 
curly brace. (And
+                     ;; (point) is just after the comma.) We don't want to 
move from the current position
+                     ;; so that object literals in parameter lists are 
properly indented.
+                     nil)
+                    (t
+                     ;; In all other cases, we don't want to move from the 
curly brace.
+                     (goto-char list-start)))
                    (back-to-indentation)
                    (let* ((in-switch-p (unless same-indent-p
                                          (looking-at "\\_<switch\\_>")))



reply via email to

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