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: Richard Copley
Subject: bug#26070: 26.0.50; js-mode slash insertion bug
Date: Thu, 23 Mar 2017 07:00:58 +0000

On 22 March 2017 at 22:18, Tom Tromey <tom@tromey.com> wrote:
>>>>>> "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.

I didn't go looking. The recipe is reduced from a program I was
writing. The infloop happened when I went to comment out a line.
Would have happened to somebody sooner or later :)

> Anyway, please try this patch on top of the previous one I sent.

Seems good, thanks very much.

> 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]