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

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

[nongnu] elpa/typescript-mode e780858a86 050/222: Don't interpret spread


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode e780858a86 050/222: Don't interpret spread syntax as a continuation.
Date: Sun, 6 Feb 2022 16:59:11 -0500 (EST)

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

    Don't interpret spread syntax as a continuation.
    
    Prior to this patch, the spread syntax would be misinterpreted as an
    expression continuation when used for object and array spreads.
---
 test-files/indentation-reference-document.ts | 19 +++++++++++++++++++
 typescript-mode.el                           | 24 ++++++++++++++----------
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/test-files/indentation-reference-document.ts 
b/test-files/indentation-reference-document.ts
index f6c4919120..8e9c809f5a 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -196,4 +196,23 @@ namespace ts.server {
             }
         }
     }
+
+    // Spread syntax
+    {
+        const a = { a: 1, b: 2 };
+        const b = {
+            ...a,
+            a: 3,
+        };
+        const c = [1, 2];
+        const d = [
+            "a",
+            ...c
+        ];
+
+        function foo(a: string,
+                     b: number,
+                     ...rest: any[]) {
+        }
+    }
 }
diff --git a/typescript-mode.el b/typescript-mode.el
index 08651a8dd0..64f35247a6 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1683,16 +1683,20 @@ See `font-lock-keywords'.")
   "Return non-nil if the current line continues an expression."
   (save-excursion
     (back-to-indentation)
-    (or (typescript--looking-at-operator-p)
-        (and (typescript--re-search-backward "\n" nil t)
-            (progn
-              (skip-chars-backward " \t")
-              (or (bobp) (backward-char))
-              (and (> (point) (point-min))
-                    (save-excursion (backward-char) (not (looking-at "[/*]/")))
-                    (typescript--looking-at-operator-p)
-                   (and (progn (backward-char)
-                               (not (looking-at "++\\|--\\|/[/*]"))))))))))
+    (and
+     ;; Don't identify the spread syntax or rest operator as a
+     ;; "continuation".
+     (not (looking-at "\\.\\.\\."))
+     (or (typescript--looking-at-operator-p)
+         (and (typescript--re-search-backward "\n" nil t)
+              (progn
+                (skip-chars-backward " \t")
+                (or (bobp) (backward-char))
+                (and (> (point) (point-min))
+                     (save-excursion (backward-char) (not (looking-at 
"[/*]/")))
+                     (typescript--looking-at-operator-p)
+                     (and (progn (backward-char)
+                                 (not (looking-at "++\\|--\\|/[/*]")))))))))))
 
 
 (defun typescript--end-of-do-while-loop-p ()



reply via email to

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