aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2015-10-15 22:34:18 +0300
committerDmitry Gutov2015-10-15 22:36:08 +0300
commit360d1d8caa1db0ffa7d0c02d4f03a4c921155c5a (patch)
tree30b87cc589d07a639882410cc273dffa17ff0bc9
parentb4c00f9ac9d57eca8f2a4950fca6198065dbdcd0 (diff)
downloademacs-360d1d8caa1db0ffa7d0c02d4f03a4c921155c5a.tar.gz
emacs-360d1d8caa1db0ffa7d0c02d4f03a4c921155c5a.zip
js-mode: Don't misindent generator methods
* lisp/progmodes/js.el (js--looking-at-operator-p): Distinguish generator methods from multiplication operator (https://github.com/mooz/js2-mode/issues/275).
-rw-r--r--lisp/progmodes/js.el13
-rw-r--r--test/indent/js.js7
2 files changed, 17 insertions, 3 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index f2140159e64..5a4f383337e 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1751,11 +1751,18 @@ This performs fontification according to `js--class-styles'."
1751 "Return non-nil if point is on a JavaScript operator, other than a comma." 1751 "Return non-nil if point is on a JavaScript operator, other than a comma."
1752 (save-match-data 1752 (save-match-data
1753 (and (looking-at js--indent-operator-re) 1753 (and (looking-at js--indent-operator-re)
1754 (or (not (looking-at ":")) 1754 (or (not (eq (char-after) ?:))
1755 (save-excursion 1755 (save-excursion
1756 (and (js--re-search-backward "[?:{]\\|\\_<case\\_>" nil t) 1756 (and (js--re-search-backward "[?:{]\\|\\_<case\\_>" nil t)
1757 (looking-at "?"))))))) 1757 (eq (char-after) ??))))
1758 1758 (not (and
1759 (eq (char-after) ?*)
1760 (looking-at (concat "\\* *" js--name-re " *("))
1761 (save-excursion
1762 (goto-char (1- (match-end 0)))
1763 (let (forward-sexp-function) (forward-sexp))
1764 (js--forward-syntactic-ws)
1765 (eq (char-after) ?{)))))))
1759 1766
1760(defun js--continued-expression-p () 1767(defun js--continued-expression-p ()
1761 "Return non-nil if the current line continues an expression." 1768 "Return non-nil if the current line continues an expression."
diff --git a/test/indent/js.js b/test/indent/js.js
index 2120233259a..d897b9f81e7 100644
--- a/test/indent/js.js
+++ b/test/indent/js.js
@@ -69,6 +69,13 @@ baz(`http://foo.bar/${tee}`)
69 are kept 69 are kept
70 unchanged!` 70 unchanged!`
71 71
72class A {
73 * x() {
74 return 1
75 * 2;
76 }
77}
78
72// Local Variables: 79// Local Variables:
73// indent-tabs-mode: nil 80// indent-tabs-mode: nil
74// js-indent-level: 2 81// js-indent-level: 2