Commit 1dff0973 authored by Dmitry Gutov's avatar Dmitry Gutov

Backport: js--re-search-backward-inner: Fix infloop

Fix JS indentation infloop reported in
https://github.com/mooz/js2-mode/issues/513.

* lisp/progmodes/js.el (js--re-search-backward-inner): Account for
multiline string literals.
* test/manual/indent/js.js: New test example.

(cherry picked from commit b01a4295)
parent dee3cdc5
Pipeline #856 passed with stage
in 30 minutes and 14 seconds
......@@ -794,7 +794,6 @@ macro as normal text."
(defun js--re-search-backward-inner (regexp &optional bound count)
"Auxiliary function for `js--re-search-backward'."
(let ((parse)
str-terminator
(orig-macro-start
(save-excursion
(and (js--beginning-of-macro)
......@@ -805,13 +804,7 @@ macro as normal text."
(save-excursion (backward-char) (looking-at "/[/*]")))
(forward-char))
(setq parse (syntax-ppss))
(cond ((setq str-terminator (nth 3 parse))
(when (eq str-terminator t)
(setq str-terminator ?/))
(re-search-backward
(concat "\\([^\\]\\|^\\)" (string str-terminator))
(point-at-bol) t))
((nth 7 parse)
(cond ((nth 8 parse)
(goto-char (nth 8 parse)))
((or (nth 4 parse)
(and (eq (char-before) ?/) (eq (char-after) ?*)))
......
......@@ -144,6 +144,13 @@ bar(
/abc/
)
// No infloop inside js--re-search-backward-inner
let b = {
a : `
//1
`
}
// Local Variables:
// indent-tabs-mode: nil
// js-indent-level: 2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment