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

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

[nongnu] elpa/typescript-mode 89d22c4e18 051/222: Don't interpret forwar


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode 89d22c4e18 051/222: Don't interpret forward slash in list as operator.
Date: Sun, 6 Feb 2022 16:59:12 -0500 (EST)

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

    Don't interpret forward slash in list as operator.
---
 test-files/indentation-reference-document.ts | 21 +++++++++++++++++++++
 typescript-mode.el                           |  8 ++++++++
 2 files changed, 29 insertions(+)

diff --git a/test-files/indentation-reference-document.ts 
b/test-files/indentation-reference-document.ts
index 8e9c809f5a..da1dd7d80c 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -215,4 +215,25 @@ namespace ts.server {
                      ...rest: any[]) {
         }
     }
+
+    {
+        // Regular expressions in lists.
+
+        // List objects...
+        const a = [
+            /abc/,
+            /def/
+        ];
+
+        const z =
+            /abcd/;
+
+        // Argument lists...
+        function foo(a: RegExp, b: RegExp): void {
+        }
+
+        foo(
+            /abc/,
+            /def/);
+    }
 }
diff --git a/typescript-mode.el b/typescript-mode.el
index 64f35247a6..5de10fb9a6 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1659,6 +1659,14 @@ See `font-lock-keywords'.")
              (save-excursion
                (and (typescript--re-search-backward "[?:{]\\|\\_<case\\_>" nil 
t)
                     (looking-at "?"))))
+         ;; Do not identify forward slashes appearing in a "list" as
+         ;; an operator. The lists are: arrays, or lists of
+         ;; arguments. In this context, they must be part of regular
+         ;; expressions, and not math operators.
+         (not (and (looking-at "/")
+                   (save-excursion
+                     (typescript--backward-syntactic-ws)
+                     (memq (char-before) '(?, ?\[ ?\()))))
          ;; Do not identify methods, or fields, that are named "in" or
          ;; "instanceof" as being operator keywords.
          (not (and



reply via email to

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