[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 2587e92851 047/222: Don't interpret class
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 2587e92851 047/222: Don't interpret class members as keywords. |
Date: |
Sun, 6 Feb 2022 16:59:10 -0500 (EST) |
branch: elpa/typescript-mode
commit 2587e92851632868513343f845c4741a693acf4f
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>
Don't interpret class members as keywords.
Without this PR, having a method or field that is named "in" or
"instanceof" or the same in a different case (e.g. "instanceOf") results
in incorrect indentation.
---
test-files/indentation-reference-document.ts | 34 ++++++++++++++++++++++++++++
typescript-mode.el | 14 ++++++++++--
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/test-files/indentation-reference-document.ts
b/test-files/indentation-reference-document.ts
index 36996c5a73..f6c4919120 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -161,5 +161,39 @@ namespace ts.server {
const f = window
.document;
+
+ const g = f
+ instanceof Object;
+
+ const h = "q"
+ in [1, 2];
+
+ }
+
+ {
+ // Object with fields that are keyword names.
+ const a = {
+ in: 1,
+ IN: 1,
+ instanceof: 1,
+ instanceOf: 1,
+ };
+
+ // Objects with methods that are keyword names. At the top of
+ // the object declaration, and after a function declaration.
+ class One {
+ instanceOf(): void {
+ }
+
+ in(): void {}
+ }
+
+ // After a field declaration.
+ class Two {
+ foo: boolean = true;
+
+ instanceOf(): void {
+ }
+ }
}
}
diff --git a/typescript-mode.el b/typescript-mode.el
index 8c5f516d56..d021e1bee2 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1642,9 +1642,12 @@ See `font-lock-keywords'.")
"each"))
"Regexp matching keywords optionally followed by an opening brace.")
+(defconst typescript--indent-keyword-re
+ (typescript--regexp-opt-symbol '("in" "instanceof"))
+ "Regexp matching keywords that affect indentation of continued expressions.")
+
(defconst typescript--indent-operator-re
- (concat "[-+*/%<>=&^|?:.]\\([^-+*/]\\|$\\)\\|"
- (typescript--regexp-opt-symbol '("in" "instanceof")))
+ (concat "[-+*/%<>=&^|?:.]\\([^-+*/]\\|$\\)\\|" typescript--indent-keyword-re)
"Regexp matching operators that affect indentation of continued
expressions.")
@@ -1656,6 +1659,13 @@ See `font-lock-keywords'.")
(save-excursion
(and (typescript--re-search-backward "[?:{]\\|\\_<case\\_>" nil
t)
(looking-at "?"))))
+ ;; Do not identify methods, or fields, that are named "in" or
+ ;; "instanceof" as being operator keywords.
+ (not (and
+ (looking-at typescript--indent-keyword-re)
+ (save-excursion
+ (typescript--backward-syntactic-ws)
+ (memq (char-before) '(?, ?{ ?} ?\;)))))
(not (and
(looking-at "*")
;; Generator method (possibly using computed property).
- [nongnu] elpa/typescript-mode 49241bcc1f 011/222: Merge pull request #3 from OrangeShark/typescript1.5, (continued)
- [nongnu] elpa/typescript-mode 49241bcc1f 011/222: Merge pull request #3 from OrangeShark/typescript1.5, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode ad8f356cbe 021/222: Merge pull request #15 from valerian/bool, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 39827549ef 017/222: Merge pull request #13 from wingyplus/highlight-set-and-get-keyword, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 266be8f6c7 018/222: added "readonly" keyword, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 588d5f3d63 027/222: Update README.md, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f72826e564 036/222: Merge pull request #25 from ananthakumaran/revert-24-wrong-cursor-position, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d5c4fb27c8 034/222: Merge pull request #24 from hekt/wrong-cursor-position, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 447cfbc078 030/222: Improve compilation-mode support., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b502d8453d 041/222: On second thought, lets NOT support Emacs 24.1 and 24.2., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f25f4751fe 052/222: Merge pull request #31 from lddubeau/fix/spread-syntax, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2587e92851 047/222: Don't interpret class members as keywords.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode face381789 083/222: Implement clean make-target to assist local development., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 20af0fec5f 077/222: Extend function prefix font-lock test to check arguments are correct., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5e2165d4b6 038/222: We need a Gitignore-file., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 330c887241 095/222: Fix indentation of functions with numbers in return type., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b7074c5dea 106/222: Remove redundant code, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode bf9a4155cc 043/222: Revise Emacs versions tested a little more., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a3c91282bc 039/222: Add test-case and indentation-reference document., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d29f31c791 045/222: Fix indentation of methods that are generators., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e780858a86 050/222: Don't interpret spread syntax as a continuation., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f3140123d6 067/222: Remove a leftover comment., ELPA Syncer, 2022/02/06