Skip to content

Commit d1123e0

Browse files
authored
Merge pull request #175 from Fuco1/bugfix/re-fontify-only-methods
fix(fontlock): only re-fontify method calls with reserved words
2 parents acd8d79 + b650e42 commit d1123e0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

typescript-mode-general-tests.el

+7-3
Original file line numberDiff line numberDiff line change
@@ -397,15 +397,19 @@ snake_cased_function(1, 2, 3)"
397397
(("<" ">" ",") . nil))))
398398

399399
(ert-deftest font-lock/method-call-with-keyword-name ()
400-
"If the name of the function/method is a keyword, it should still be highlighted as function."
400+
"If the name of the method is a keyword, it should still be highlighted as function."
401401
(test-with-fontified-buffer
402402
"const app = express();
403403
app.get()
404404
app.post()
405-
app.delete()"
405+
app.delete()
406+
if (true) {}
407+
// for (abc) {}"
406408
(should (eq (get-face-at "get") 'font-lock-function-name-face))
407409
(should (eq (get-face-at "post") 'font-lock-function-name-face))
408-
(should (eq (get-face-at "delete") 'font-lock-function-name-face))))
410+
(should (eq (get-face-at "delete") 'font-lock-function-name-face))
411+
(should (eq (get-face-at "if") 'font-lock-keyword-face))
412+
(should (eq (get-face-at "for") 'font-lock-comment-face))))
409413

410414
(ert-deftest font-lock/generics ()
411415
"Tests that type hints within generics are highlighted properly."

typescript-mode.el

+3-1
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,9 @@ This performs fontification according to `typescript--class-styles'."
21372137
,@typescript--font-lock-keywords-3
21382138

21392139
(,typescript--decorator-re (1 font-lock-function-name-face))
2140-
(,typescript--function-call-re (1 font-lock-function-name-face t))
2140+
(,typescript--function-call-re (1 font-lock-function-name-face))
2141+
(,(concat "\\(?:\\.\\s-*\\)" typescript--function-call-re)
2142+
(1 font-lock-function-name-face t))
21412143
(,typescript--builtin-re (1 font-lock-type-face))
21422144

21432145
;; arrow function

0 commit comments

Comments
 (0)