diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2016-04-28 02:00:23 +0300 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2016-04-28 02:00:48 +0300 |
commit | 0255a70c8ae22e259e8938ac3840c7b6687edec8 (patch) | |
tree | 7e300091da3bedac669c525b3131d798ffd1b633 /lisp/progmodes | |
parent | ff7e201ed87d206334afedd4366deebba440efde (diff) | |
download | emacs-0255a70c8ae22e259e8938ac3840c7b6687edec8.tar.gz |
Don't mistake `for' inside a function for a part of array comprehension
* lisp/progmodes/js.el (js--indent-in-array-comp): Also check the
depth in parens between the bracket and `for' (bug#23391).
* test/indent/js.js: Add a corresponding example.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r-- | lisp/progmodes/js.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 8c93ffa8731..48eb3e778e1 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -1892,9 +1892,11 @@ In particular, return the buffer position of the first `for' kwd." ;; To skip arbitrary expressions we need the parser, ;; so we'll just guess at it. (if (and (> end (point)) ; Not empty literal. - (re-search-forward "[^,]]* \\(for\\) " end t) + (re-search-forward "[^,]]* \\(for\\_>\\)" end t) ;; Not inside comment or string literal. - (not (nth 8 (parse-partial-sexp bracket (point))))) + (let ((status (parse-partial-sexp bracket (point)))) + (and (= 1 (car status)) + (not (nth 8 status))))) (match-beginning 1))))))) (defun js--array-comp-indentation (bracket for-kwd) |