[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 5b0487aae8 085/222: Fix the Emacs regex us
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 5b0487aae8 085/222: Fix the Emacs regex used for highlighting TS regexes. |
Date: |
Sun, 6 Feb 2022 16:59:20 -0500 (EST) |
branch: elpa/typescript-mode
commit 5b0487aae890e7e9f7105a679deecc50428e912d
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>
Fix the Emacs regex used for highlighting TS regexes.
The previous regex would treat // as a regex, which is wrong. In JS
(which TS follows to the letter, in this case), // is never a regular
expression. It *looks* like an empty regular expression, but if it
appears outside a string or comment, then it is the start of a single
line comment, not an empty regular expression. The old regex also had
trouble dealing with an escaped forward slash appearing in a
regex. The commit fixes both problems, and it adds tests to check for
such issues.
---
typescript-mode-tests.el | 29 ++++++++++++++++++++---------
typescript-mode.el | 2 +-
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/typescript-mode-tests.el b/typescript-mode-tests.el
index 4a9e4f0f4c..4974819416 100644
--- a/typescript-mode-tests.el
+++ b/typescript-mode-tests.el
@@ -284,22 +284,33 @@ declare function declareFunctionDefn(x3: xty3, y3: yty3):
ret3;"
'(("=" . nil) ("/foo/" . font-lock-string-face)
("(" . nil) ("/bar/" . font-lock-string-face)
("," . nil) ("/baz/" . font-lock-string-face)
- (":" . nil) ("/buzz/" . font-lock-string-face)))))
+ (":" . nil) ("/buzz/" . font-lock-string-face))))
+ ;; Make sure that escaped forward slashes are handled too.
+ (font-lock-test "var a = /flip\\/flop/;"
+ '(("=" . nil)
+ (("/flip" "\\\\" "/" "flop/") . font-lock-string-face)
+ (";" . nil)))
+ ;; A sequence of two forward slashes is never a regex, so there is
+ ;; no such thing as an \"empty regex\" when we use the forward slash
+ ;; notation.
+ (font-lock-test "=//g something // comment"
+ '(("g something" . font-lock-comment-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)))
+ "=/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)))
+ "=/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)))
+ "=/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))))
+ "=/foo\\\\/g something // comment"
+ (should (eq (get-face-at "g something") nil))))
+
(defun flyspell-predicate-test (search-for)
"This function runs a test on
diff --git a/typescript-mode.el b/typescript-mode.el
index 25918105a0..6497d3b7cd 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -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.")
- [nongnu] elpa/typescript-mode 32b8e1b6d0 134/222: Merge pull request #94 from jack-williams/add-bigint, (continued)
- [nongnu] elpa/typescript-mode 32b8e1b6d0 134/222: Merge pull request #94 from jack-williams/add-bigint, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 6ae2c7ab9e 135/222: Highlight multiple implements types (#96), ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 761f3aec6e 161/222: Fix issues reported by package-lint, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e82a4d2527 170/222: Add a new indentation test case that triggers an infinite loop., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 54f14c4827 202/222: Update README.md, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b369d7d251 206/222: Merge pull request #147 from ltrel/typo-fixes, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode bc37bc4b15 176/222: Fix another member expression infinite loop., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1e9fc35cb9 210/222: Make cask and emacs locations overridable., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 96800ed070 208/222: Migrate build to use proper tasks and new source for Emacs, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e824162051 222/222: Merge pull request #159 from tancnle/fix-cl-deprecation-warnings, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5b0487aae8 085/222: Fix the Emacs regex used for highlighting TS regexes.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode 2cd997a8d5 102/222: Fix typescript--backward-to-parameter-list, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2815dd1b4b 098/222: Add option to support indented case-statements. Fixes #23 (#66), ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 861d5983b6 090/222: Make the comment-start and comment-end variables local., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4e3850dd2a 105/222: Remove logic handling preprocessor macros, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 32f5034e9d 127/222: Extract tests as general tests, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e15e2bfa1a 131/222: Add jsdoc tests, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode c0f11efdfd 143/222: Fixing typescript--forward-expression for multiline indented string, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a0f2c3ebd4 164/222: Reimplement template auto conversion as a post-self-insert-hook, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b44b75dbe1 172/222: Add test case for infinite loop, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5bf30fe8d6 175/222: Add member expressions tests involving type parameters., ELPA Syncer, 2022/02/06