Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions typescript-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,29 @@ declare function declareFunctionDefn(x3: xty3, y3: yty3): ret3;"
(("y0" "y1" "y2" "y3") . font-lock-variable-name-face)
(("ret0" "ret1" "ret2" "ret3") . nil))))

(ert-deftest font-lock/regexp ()
"Regular expresssions should be fontified as string constant."
(let ((content "=/foo/ (/bar/ ,/baz/ :/buzz/"))
(font-lock-test content
'(("=" . nil) ("/foo/" . font-lock-string-face)
("(" . nil) ("/bar/" . font-lock-string-face)
("," . nil) ("/baz/" . font-lock-string-face)
(":" . nil) ("/buzz/" . font-lock-string-face)))))

(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
"=/foo/g something // comment"
(should (eq (get-face-at "g something") nil)))
(test-with-temp-buffer
"=/foo\\bar/g something // comment"
(should (eq (get-face-at "g something") nil)))
(test-with-temp-buffer
"=/foo\\\\bar/g something // comment"
(should (eq (get-face-at "g something") nil)))
(test-with-temp-buffer
"=/foo\\\\/g something // comment"
(should (eq (get-face-at "g something") nil))))

(defun flyspell-predicate-test (search-for)
"This function runs a test on
Expand Down
2 changes: 1 addition & 1 deletion typescript-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ This performs fontification according to `typescript--class-styles'."
;; as the newline is escaped with \. Account for that in the regexp
;; below.
(defconst typescript--regexp-literal
"[=(,:]\\(?:\\s-\\|\n\\)*\\(/\\)\\(?:\\\\/\\|[^/*]\\)\\(?:\\\\/\\|[^/]\\)*\\(/\\)"
"[=(,:]\\(?:\\s-\\|\n\\)*\\(/\\)[^/]*\\(/\\)"
"Regexp matching a typescript regular expression literal.
Match groups 1 and 2 are the characters forming the beginning and
end of the literal.")
Expand Down