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

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

[nongnu] elpa/typescript-mode 526f307ca8 101/222: Fontify yield and yiel


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode 526f307ca8 101/222: Fontify yield and yield* as keyword
Date: Sun, 6 Feb 2022 16:59:22 -0500 (EST)

branch: elpa/typescript-mode
commit 526f307ca8ca50b8f98975f2812198212f6acf2f
Author: felipe <felipe@fov.space>
Commit: felipe <felipe@fov.space>

    Fontify yield and yield* as keyword
    
    Closes #67
---
 typescript-mode-tests.el | 22 ++++++++++++++++++++++
 typescript-mode.el       |  3 ++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/typescript-mode-tests.el b/typescript-mode-tests.el
index 487dc2fa8d..795555f27d 100644
--- a/typescript-mode-tests.el
+++ b/typescript-mode-tests.el
@@ -350,6 +350,28 @@ declare function declareFunctionDefn(x3: xty3, y3: yty3): 
ret3;"
   (font-lock-test "=//g something // comment"
                   '(("g something" . font-lock-comment-face))))
 
+(ert-deftest font-lock/yield ()
+  "`yield' and `yield*' should be fontified as keywords."
+  (font-lock-test
+   "function* gen(x0: xty0, y0: yty0): ret0 {
+    yield 123;
+    yield* subIter;
+}"
+   '(("yield 123" . font-lock-keyword-face)
+     ("yield\\*" . font-lock-keyword-face)
+     ("\\* subIter" . font-lock-keyword-face))))
+
+(ert-deftest font-lock/yielder ()
+  "`yielder' should not be fontified as a keyword."
+  (font-lock-test
+   "function* gen(x0: xty0, y0: yty0): ret0 {
+    const yielder = 123;
+    yield abc;
+    return yielder;
+}"
+   '(("yielder =" . font-lock-variable-name-face)
+     ("yielder;" . nil))))
+
 (ert-deftest 
font-lock/text-after-trailing-regexp-delim-should-not-be-fontified ()
   "Text after trailing regular expression delimiter should not be fontified."
   (test-with-temp-buffer
diff --git a/typescript-mode.el b/typescript-mode.el
index bd2f332e4a..1d5536f0bc 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -290,7 +290,7 @@ Match group 1 is the name of the macro.")
      "private" "protected" "public" "readonly" "return" "set" "static" "string"
      "super" "switch"  "this" "throw" "true"
      "try" "type" "typeof" "var" "void"
-     "while" ))
+     "while"))                  ; yield is handled separately
   "Regexp matching any typescript keyword.")
 
 (defconst typescript--basic-type-re
@@ -318,6 +318,7 @@ Match group 1 is the name of the macro.")
                 (list "\\_<for\\_>"
                       "\\s-+\\(each\\)\\_>" nil nil
                       (list 1 'font-lock-keyword-face))
+                (cons "\\_<yield\\(\\*\\|\\_>\\)" 'font-lock-keyword-face)
                 (cons typescript--basic-type-re font-lock-type-face)
                 (cons typescript--constant-re font-lock-constant-face)))
   "Level two font lock keywords for `typescript-mode'.")



reply via email to

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