emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/typescript-mode 9bd226b386 06/10: fix(fontlock): do not fo


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode 9bd226b386 06/10: fix(fontlock): do not fontify builtins in object/interface key context
Date: Sat, 30 Jul 2022 06:59:04 -0400 (EDT)

branch: elpa/typescript-mode
commit 9bd226b3860540f39887cf8f062a2dfc172f62b9
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>

    fix(fontlock): do not fontify builtins in object/interface key context
---
 typescript-mode-general-tests.el | 13 +++++++++++++
 typescript-mode.el               |  8 ++++++++
 2 files changed, 21 insertions(+)

diff --git a/typescript-mode-general-tests.el b/typescript-mode-general-tests.el
index 9c1102b915..ad5ed6220f 100644
--- a/typescript-mode-general-tests.el
+++ b/typescript-mode-general-tests.el
@@ -287,6 +287,19 @@ a severity set to WARNING, no rule name."
  " * @param {Something} bar A parameter. References [[moo]] and [[foo]].
  * @param second May hold ``x`` or ``y``.")
 
+(ert-deftest font-lock/interface-builtin-key-context-unfontify ()
+  "Builtins should not be fontified when they are in object or
+interface key context."
+  (test-with-fontified-buffer
+      "interface Foo { type: number; unknown: string; foo: boolean }"
+    (should (eq (get-face-at "type") 'default))
+    (should (eq (get-face-at "unknown") 'default)))
+
+  (test-with-fontified-buffer
+      "const x = { type: 4; unknown: 'bar'; foo: true }"
+    (should (eq (get-face-at "type") 'default))
+    (should (eq (get-face-at "unknown") 'default))))
+
 (ert-deftest font-lock/documentation-in-documentation-comments ()
   "Documentation in documentation comments should be fontified as
 documentation."
diff --git a/typescript-mode.el b/typescript-mode.el
index 268df97395..215a5d8585 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1737,6 +1737,14 @@ and searches for the next token to be highlighted."
   `(
     ,@typescript--font-lock-keywords-2
 
+    ;; Remove the fontification of keywords and built-ins when they
+    ;; are keys in an interface, object or class.
+    (,(rx "{")
+     (,(concat "\\(" typescript--keyword-re "\\):")
+      (save-excursion (ignore-errors (up-list)) (point))
+      nil
+      (1 'default t t)))
+
     (typescript--jsdoc-param-matcher (1 'typescript-jsdoc-tag t t)
                                      (2 'typescript-jsdoc-type t t)
                                      (3 'typescript-jsdoc-value t t))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]