diff options
| author | Dmitry Gutov | 2016-04-28 02:00:23 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2016-04-28 02:00:48 +0300 |
| commit | 0255a70c8ae22e259e8938ac3840c7b6687edec8 (patch) | |
| tree | 7e300091da3bedac669c525b3131d798ffd1b633 /lisp | |
| parent | ff7e201ed87d206334afedd4366deebba440efde (diff) | |
| download | emacs-0255a70c8ae22e259e8938ac3840c7b6687edec8.tar.gz emacs-0255a70c8ae22e259e8938ac3840c7b6687edec8.zip | |
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')
| -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." | |||
| 1892 | ;; To skip arbitrary expressions we need the parser, | 1892 | ;; To skip arbitrary expressions we need the parser, |
| 1893 | ;; so we'll just guess at it. | 1893 | ;; so we'll just guess at it. |
| 1894 | (if (and (> end (point)) ; Not empty literal. | 1894 | (if (and (> end (point)) ; Not empty literal. |
| 1895 | (re-search-forward "[^,]]* \\(for\\) " end t) | 1895 | (re-search-forward "[^,]]* \\(for\\_>\\)" end t) |
| 1896 | ;; Not inside comment or string literal. | 1896 | ;; Not inside comment or string literal. |
| 1897 | (not (nth 8 (parse-partial-sexp bracket (point))))) | 1897 | (let ((status (parse-partial-sexp bracket (point)))) |
| 1898 | (and (= 1 (car status)) | ||
| 1899 | (not (nth 8 status))))) | ||
| 1898 | (match-beginning 1))))))) | 1900 | (match-beginning 1))))))) |
| 1899 | 1901 | ||
| 1900 | (defun js--array-comp-indentation (bracket for-kwd) | 1902 | (defun js--array-comp-indentation (bracket for-kwd) |