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.
This commit is contained in:
parent
ff7e201ed8
commit
0255a70c8a
2 changed files with 12 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -53,6 +53,14 @@ var p = {
|
|||
var evens = [e for each (e in range(0, 21))
|
||||
if (ed % 2 == 0)];
|
||||
|
||||
var funs = [
|
||||
function() {
|
||||
for (;;) {
|
||||
}
|
||||
},
|
||||
function(){},
|
||||
];
|
||||
|
||||
!b
|
||||
!=b
|
||||
!==b
|
||||
|
|
Loading…
Add table
Reference in a new issue