Skip to content

Commit 367cfb7

Browse files
committed
fix(fontlock): do not fontify function calls as keywords
If a method/function is named same as keyword or built-in, it should still be fontified as method/function call.
1 parent 83bf47e commit 367cfb7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

typescript-mode-general-tests.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,17 @@ snake_cased_function(1, 2, 3)"
383383
(("endpoint" "data") . nil)
384384
(("<" ">" ",") . nil))))
385385

386+
(ert-deftest font-lock/method-call-with-keyword-name ()
387+
"If the name of the function/method is a keyword, it should still be highlighted as function."
388+
(test-with-fontified-buffer
389+
"const app = express();
390+
app.get()
391+
app.post()
392+
app.delete()"
393+
(should (eq (get-face-at "get") 'font-lock-function-name-face))
394+
(should (eq (get-face-at "post") 'font-lock-function-name-face))
395+
(should (eq (get-face-at "delete") 'font-lock-function-name-face))))
396+
386397
(ert-deftest font-lock/generics ()
387398
"Tests that type hints within generics are highlighted properly."
388399
(font-lock-test

typescript-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2020,7 +2020,7 @@ This performs fontification according to `typescript--class-styles'."
20202020
,@typescript--font-lock-keywords-3
20212021

20222022
(,typescript--decorator-re (1 font-lock-function-name-face))
2023-
(,typescript--function-call-re (1 font-lock-function-name-face))
2023+
(,typescript--function-call-re (1 font-lock-function-name-face t))
20242024
(,typescript--builtin-re (1 font-lock-type-face))
20252025

20262026
;; arrow function

0 commit comments

Comments
 (0)