bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#26070: 26.0.50; js-mode slash insertion bug


From: Tom Tromey
Subject: bug#26070: 26.0.50; js-mode slash insertion bug
Date: Wed, 22 Mar 2017 16:18:22 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

>>>>> "Richard" == Richard Copley <rcopley@gmail.com> writes:

Richard> Caught one!

Thank you.

Richard> Insert the text below in a JS-mode buffer, go to the beginning of the
Richard> blank first line in function h() and type "/". There is an infloop.

How did you find this?  I'm very curious.

Anyway, please try this patch on top of the previous one I sent.
Or if you'd prefer I can send a combined patch.

Tom

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index fa865db..c220353 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1722,12 +1722,13 @@ js-syntax-propertize-regexp
     (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.
-                 (or (not (match-end 1)) (<= (match-end 1) end)))
-        (put-text-property (match-beginning 1) (or (match-end 1) (match-end 0))
+      (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 /.../.





reply via email to

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