[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-25 0255a70: Don't mistake `for' inside a function fo
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] emacs-25 0255a70: Don't mistake `for' inside a function for a part of array comprehension |
Date: |
Wed, 27 Apr 2016 23:01:50 +0000 |
branch: emacs-25
commit 0255a70c8ae22e259e8938ac3840c7b6687edec8
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
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.
---
lisp/progmodes/js.el | 6 ++++--
test/indent/js.js | 8 ++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 8c93ffa..48eb3e7 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)
diff --git a/test/indent/js.js b/test/indent/js.js
index 61c7b44..23fae17 100644
--- a/test/indent/js.js
+++ b/test/indent/js.js
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-25 0255a70: Don't mistake `for' inside a function for a part of array comprehension,
Dmitry Gutov <=