branch: elpa/typescript-mode
commit 6ae2c7ab9e8f5bd5c8f924e9abae76fdd0c295b6
Author: Eder Elorriaga <[email protected]>
Commit: Jostein Kjønigsen <[email protected]>
Highlight multiple implements types (#96)
* Highlight multiple implements types
* Add tests for 1 to many elements after implements
---
typescript-mode-general-tests.el | 16 ++++++++++++++++
typescript-mode.el | 4 ++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/typescript-mode-general-tests.el b/typescript-mode-general-tests.el
index cb89f8b986..9a79108da1 100644
--- a/typescript-mode-general-tests.el
+++ b/typescript-mode-general-tests.el
@@ -358,6 +358,22 @@ declare function declareFunctionDefn(x3: xty3, y3: yty3):
ret3;"
(should (eq (get-face-at "Foo") 'font-lock-type-face))
(should (eq (get-face-at "Bar") 'font-lock-type-face))
(should (eq (get-face-at "Qux") 'font-lock-type-face)))
+ (test-with-fontified-buffer
+ "export class Foo extends Bar implements Qux, Ajx {}"
+ (should (eq (get-face-at "Foo") 'font-lock-type-face))
+ (should (eq (get-face-at "Bar") 'font-lock-type-face))
+ (should (eq (get-face-at "Qux") 'font-lock-type-face))
+ (should (eq (get-face-at ",") 'nil))
+ (should (eq (get-face-at "Ajx") 'font-lock-type-face)))
+ (test-with-fontified-buffer
+ "export class Foo extends Bar implements Qux, Ajx, Psd {}"
+ (should (eq (get-face-at "Foo") 'font-lock-type-face))
+ (should (eq (get-face-at "Bar") 'font-lock-type-face))
+ (should (eq (get-face-at "Qux") 'font-lock-type-face))
+ (should (eq (get-face-at ",") 'nil))
+ (should (eq (get-face-at "Ajx") 'font-lock-type-face))
+ (should (eq (get-face-at ",") 'nil))
+ (should (eq (get-face-at "Psd") 'font-lock-type-face)))
;; Ensure we require symbol boundaries.
(test-with-fontified-buffer
"Notclass Foo"
diff --git a/typescript-mode.el b/typescript-mode.el
index 6f54c7a594..3f61313b27 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1749,8 +1749,8 @@ and searches for the next token to be highlighted."
(,(rx symbol-start "extends" (+ space) (group (+ (or (syntax word) (syntax
symbol)))))
(1 font-lock-type-face))
- (,(rx symbol-start "implements" (+ space) (group (+ (or (syntax word)
(syntax symbol)))))
- (1 font-lock-type-face))
+ (,(rx symbol-start "implements" (+ space))
+ (,(rx symbol-start (+ (syntax word))) nil nil (0 font-lock-type-face)))
(,(rx symbol-start "interface" (+ space) (group (+ (or (syntax word)
(syntax symbol)))))
(1 font-lock-type-face))