From: Dmitry Gutov Date: Thu, 15 Oct 2015 19:34:18 +0000 (+0300) Subject: js-mode: Don't misindent generator methods X-Git-Tag: emacs-25.0.90~1115 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=360d1d8caa1db0ffa7d0c02d4f03a4c921155c5a;p=emacs.git 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). --- 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'." "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 "[?:{]\\|\\_" 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." 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}`) are kept unchanged!` +class A { + * x() { + return 1 + * 2; + } +} + // Local Variables: // indent-tabs-mode: nil // js-indent-level: 2