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

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

[nongnu] elpa/typescript-mode 2cd997a8d5 102/222: Fix typescript--backwa


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode 2cd997a8d5 102/222: Fix typescript--backward-to-parameter-list
Date: Sun, 6 Feb 2022 16:59:22 -0500 (EST)

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

    Fix typescript--backward-to-parameter-list
    
    Fix typescript--backward-to-parameter-list to avoid walking over
    constructs like `switch (...)`, `for (...)`, etc.
---
 test-files/switch-case-indent-default.ts | 8 ++++++++
 typescript-mode.el                       | 6 +++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/test-files/switch-case-indent-default.ts 
b/test-files/switch-case-indent-default.ts
index b1af8804b5..788b78f4c0 100644
--- a/test-files/switch-case-indent-default.ts
+++ b/test-files/switch-case-indent-default.ts
@@ -3,7 +3,15 @@ function indentTest(): any {
         case: 1,
         default: 2
     };
+
+    // This function was specifically added to test for a reversion in
+    // the code that indents switch statements.
+    function turnip(): void {
+    }
+
     switch (process.platform) {
+        case "moo":
+            break;
         case "win32": {
             const basePath = process.env.LOCALAPPDATA ||
                 process.env.APPDATA;
diff --git a/typescript-mode.el b/typescript-mode.el
index 1d5536f0bc..12bd16e79c 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -2180,7 +2180,11 @@ moved on success."
                      ;; The earlier test for dotted names comes into play if 
the
                      ;; logic moves over one part of a dotted name at a time 
(which
                      ;; is what `backward-sexp` normally does).
-                     (looking-back typescript--dotted-name-re nil))
+                     (and (looking-back typescript--dotted-name-re nil)
+                          ;; We don't want the loop to walk over constructs 
like switch (...) or for (...), etc.
+                          (not (save-excursion
+                                 (backward-word)
+                                 (looking-at 
"\\_<\\(switch\\|if\\|while\\|until\\|for\\)\\_>\\(?:\\s-\\|\n\\)*(")))))
                     (condition-case nil
                         (backward-sexp)
                       (scan-error nil)))



reply via email to

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