branch: elpa/typescript-mode
commit 89d22c4e188cd93ea9550e85d17a2d9c0f3393dc
Author: Louis-Dominique Dubeau <[email protected]>
Commit: Louis-Dominique Dubeau <[email protected]>
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