(not (any ?\] ?\\))
(and "\\" not-newline)))
"]")))
- (group "/"))
+ (group (zero-or-one "/")))
"Regular expression matching a JavaScript regexp literal.")
(defun js-syntax-propertize-regexp (end)
(when (eq (nth 3 ppss) ?/)
;; A /.../ regexp.
(goto-char (nth 8 ppss))
- (when (and (looking-at js--syntax-propertize-regexp-regexp)
- ;; Don't touch text after END.
- (<= (match-end 1) end))
- (put-text-property (match-beginning 1) (match-end 1)
+ (when (looking-at js--syntax-propertize-regexp-regexp)
+ ;; Don't touch text after END.
+ (when (> end (match-end 1))
+ (setq end (match-end 1)))
+ (put-text-property (match-beginning 1) end
'syntax-table (string-to-syntax "\"/"))
- (goto-char (match-end 0))))))
+ (goto-char end)))))
(defun js-syntax-propertize (start end)
;; JavaScript allows immediate regular expression objects, written /.../.
(font-lock-ensure)
(should (eq (get-text-property (point) 'face) (caddr test))))))
+(ert-deftest js-mode-propertize-bug-1 ()
+ (with-temp-buffer
+ (js-mode)
+ (save-excursion (insert "x"))
+ (insert "/")
+ ;; The bug was a hang.
+ (should t)))
+
+(ert-deftest js-mode-propertize-bug-2 ()
+ (with-temp-buffer
+ (js-mode)
+ (insert "function f() {
+ function g()
+ {
+ 1 / 2;
+ }
+
+ function h() {
+")
+ (save-excursion
+ (insert "
+ 00000000000000000000000000000000000000000000000000;
+ 00000000000000000000000000000000000000000000000000;
+ 00000000000000000000000000000000000000000000000000;
+ 00000000000000000000000000000000000000000000000000;
+ 00000000000000000000000000000000000000000000000000;
+ 00000000000000000000000000000000000000000000000000;
+ 00000000000000000000000000000000000000000000000000;
+ 00000000000000000000000000000000000000000000000000;
+ 00;
+ }
+}
+"))
+ (insert "/")
+ ;; The bug was a hang.
+ (should t)))
+
(provide 'js-tests)
;;; js-tests.el ends here