[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode ca510ab853 048/222: Merge pull request #30
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode ca510ab853 048/222: Merge pull request #30 from lddubeau/fix/keyword-members |
Date: |
Sun, 6 Feb 2022 16:59:11 -0500 (EST) |
branch: elpa/typescript-mode
commit ca510ab853feb45bb0a6fa5bfe01c96bb1da50ba
Merge: a532ef57cf 2587e92851
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: GitHub <noreply@github.com>
Merge pull request #30 from lddubeau/fix/keyword-members
Don't interpret class members as keywords.
---
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 2573266955 086/222: Fix a bug in handling function return type annotations., (continued)
- [nongnu] elpa/typescript-mode 2573266955 086/222: Fix a bug in handling function return type annotations., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b62f52a35c 009/222: Add let, const, namespace keywords from 1.5, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 976ae69337 003/222: add url, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 514d6f0416 012/222: Add 'async' and 'await' as keywords, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d27114244a 014/222: added "abstract" keyword, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 54e0c562d4 020/222: removed keyword "bool" which is deprecated since TypeScript 0.9, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d81cc72782 013/222: Merge pull request #7 from paulkoerbitz/patch-1, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a532ef57cf 046/222: Merge pull request #29 from lddubeau/fix/method-generator, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode c1a7d40dd8 005/222: highlight template string, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 8fe879a96d 028/222: Support 'of' keyword., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode ca510ab853 048/222: Merge pull request #30 from lddubeau/fix/keyword-members,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode a2c2ff03e7 024/222: Add support for compilation-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7526f138a0 032/222: Avoid capturing things we dont need for compilation-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 666052f09f 033/222: Update readme., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4235b47a38 060/222: Fix indent for lines which starts with tabs., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 52c08d0628 091/222: Add more fontification tests for regular expressions., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e25c7ddb8a 062/222: Fix indentation of funcs with return annotations., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 536e4da380 087/222: Fix bug with hanling array shorthand in return value types., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 70acbf9c3d 078/222: Change font-lock-test to also accept a list of locations, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a2167a133d 056/222: Fix errors with indentation when line has wide unicode chars., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 09bdb97c32 065/222: Fix an indentation bug., ELPA Syncer, 2022/02/06