diff options
author | Tom Tromey <tom@tromey.com> | 2017-02-05 11:40:18 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-02-11 12:30:32 -0700 |
commit | 862d6438cfa6c6c035033697751f3d002357b024 (patch) | |
tree | cc7eab8482c2fe5fabb37660d1d5a6353aefd159 /test | |
parent | c2e19a73401eb37d5c13f6c8589dc1e5d706d239 (diff) | |
download | emacs-862d6438cfa6c6c035033697751f3d002357b024.tar.gz |
Recognize JS regexp literals more correctly
Bug#25529
* lisp/progmodes/js.el (js--syntax-propertize-regexp-regexp): New
constant.
(js-syntax-propertize-regexp): Use it. Remove "end" argument.
(js--syntax-propertize-regexp-syntax-table): Remove.
(js-syntax-propertize): Update.
* test/lisp/progmodes/js-tests.el (js-mode-regexp-syntax-bug-25529):
New test.
Diffstat (limited to 'test')
-rw-r--r-- | test/lisp/progmodes/js-tests.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el index 7cb737c30e2..d61f084e0df 100644 --- a/test/lisp/progmodes/js-tests.el +++ b/test/lisp/progmodes/js-tests.el @@ -23,6 +23,7 @@ (require 'ert) (require 'js) +(require 'syntax) (ert-deftest js-mode-fill-bug-19399 () (with-temp-buffer @@ -99,6 +100,22 @@ if (!/[ (:,='\"]/.test(value)) { (forward-line) (should (looking-at " \\* test")))) +(ert-deftest js-mode-regexp-syntax-bug-25529 () + (dolist (regexp-contents '("[^[]" + "[/]" + ;; A comment with the regexp on the next + ;; line. + "*comment*/\n/regexp")) + (with-temp-buffer + (js-mode) + (insert "let x = /" regexp-contents "/;\n") + (save-excursion (insert "something();\n")) + ;; The failure mode was that the regexp literal was not + ;; recognized, causing the next line to be given string syntax; + ;; but check for comment syntax as well to prevent an + ;; implementation not recognizing the comment example. + (should-not (syntax-ppss-context (syntax-ppss)))))) + (provide 'js-tests) ;;; js-tests.el ends here |