Commit dc9d837d authored by Dmitry Gutov's avatar Dmitry Gutov

Don't misindent computed property generator methods

* lisp/progmodes/js.el (js--looking-at-operator-p):
Don't misindent computed property generator methods
(https://github.com/mooz/js2-mode/issues/317).
parent 79231122
......@@ -1758,12 +1758,13 @@ This performs fontification according to `js--class-styles'."
(eq (char-after) ??))))
(not (and
(eq (char-after) ?*)
(looking-at (concat "\\* *" js--name-re " *("))
;; Generator method (possibly using computed property).
(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) ?{)))))))
(js--backward-syntactic-ws)
;; We might misindent some expressions that would
;; return NaN anyway. Shouldn't be a problem.
(memq (char-before) '(?, ?} ?{))))))))
(defun js--continued-expression-p ()
"Return non-nil if the current line continues an expression."
......
......@@ -72,7 +72,12 @@ baz(`http://foo.bar/${tee}`)
class A {
* x() {
return 1
* 2;
* a(2);
}
*[Symbol.iterator]() {
yield "Foo";
yield "Bar";
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment