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).
This commit is contained in:
Dmitry Gutov 2015-10-15 22:34:18 +03:00
parent b4c00f9ac9
commit 360d1d8caa
2 changed files with 17 additions and 3 deletions

View file

@ -1751,11 +1751,18 @@ This performs fontification according to `js--class-styles'."
"Return non-nil if point is on a JavaScript operator, other than a comma."
(save-match-data
(and (looking-at js--indent-operator-re)
(or (not (looking-at ":"))
(or (not (eq (char-after) ?:))
(save-excursion
(and (js--re-search-backward "[?:{]\\|\\_<case\\_>" nil t)
(looking-at "?")))))))
(eq (char-after) ??))))
(not (and
(eq (char-after) ?*)
(looking-at (concat "\\* *" js--name-re " *("))
(save-excursion
(goto-char (1- (match-end 0)))
(let (forward-sexp-function) (forward-sexp))
(js--forward-syntactic-ws)
(eq (char-after) ?{)))))))
(defun js--continued-expression-p ()
"Return non-nil if the current line continues an expression."

View file

@ -69,6 +69,13 @@ baz(`http://foo.bar/${tee}`)
are kept
unchanged!`
class A {
* x() {
return 1
* 2;
}
}
// Local Variables:
// indent-tabs-mode: nil
// js-indent-level: 2