[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode b650e42662 1/2: fix(fontlock): only re-fon
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode b650e42662 1/2: fix(fontlock): only re-fontify method calls with reserved words |
Date: |
Fri, 5 Aug 2022 16:59:12 -0400 (EDT) |
branch: elpa/typescript-mode
commit b650e42662db55d4c455e1b0369d16acb50aeb92
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
fix(fontlock): only re-fontify method calls with reserved words
Functions can not be called after a reserved word such as `if` or
`delete`, however methods can. Only re-apply fontification on
methods.
---
typescript-mode-general-tests.el | 10 +++++++---
typescript-mode.el | 4 +++-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/typescript-mode-general-tests.el b/typescript-mode-general-tests.el
index 686db6bfdf..ff8220b2f5 100644
--- a/typescript-mode-general-tests.el
+++ b/typescript-mode-general-tests.el
@@ -397,15 +397,19 @@ snake_cased_function(1, 2, 3)"
(("<" ">" ",") . nil))))
(ert-deftest font-lock/method-call-with-keyword-name ()
- "If the name of the function/method is a keyword, it should still be
highlighted as function."
+ "If the name of the method is a keyword, it should still be highlighted as
function."
(test-with-fontified-buffer
"const app = express();
app.get()
app.post()
-app.delete()"
+app.delete()
+if (true) {}
+// for (abc) {}"
(should (eq (get-face-at "get") 'font-lock-function-name-face))
(should (eq (get-face-at "post") 'font-lock-function-name-face))
- (should (eq (get-face-at "delete") 'font-lock-function-name-face))))
+ (should (eq (get-face-at "delete") 'font-lock-function-name-face))
+ (should (eq (get-face-at "if") 'font-lock-keyword-face))
+ (should (eq (get-face-at "for") 'font-lock-comment-face))))
(ert-deftest font-lock/generics ()
"Tests that type hints within generics are highlighted properly."
diff --git a/typescript-mode.el b/typescript-mode.el
index 032abbc7a5..47d5c4bd09 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -2137,7 +2137,9 @@ This performs fontification according to
`typescript--class-styles'."
,@typescript--font-lock-keywords-3
(,typescript--decorator-re (1 font-lock-function-name-face))
- (,typescript--function-call-re (1 font-lock-function-name-face t))
+ (,typescript--function-call-re (1 font-lock-function-name-face))
+ (,(concat "\\(?:\\.\\s-*\\)" typescript--function-call-re)
+ (1 font-lock-function-name-face t))
(,typescript--builtin-re (1 font-lock-type-face))
;; arrow function
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/typescript-mode b650e42662 1/2: fix(fontlock): only re-fontify method calls with reserved words,
ELPA Syncer <=