From 1dff09739346037a588a3b9290800c09a9b3409a Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Fri, 1 Feb 2019 03:01:39 +0300 Subject: [PATCH] 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 b01a4295c2f9bb58858880e4e28b05cc8396791c) --- lisp/progmodes/js.el | 9 +-------- test/manual/indent/js.js | 7 +++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 14571a04e1c..9c3f3b3e4f4 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -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) ?*))) diff --git a/test/manual/indent/js.js b/test/manual/indent/js.js index b0d8bcabd20..df790986947 100644 --- a/test/manual/indent/js.js +++ b/test/manual/indent/js.js @@ -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 -- 2.39.2