]> git.eshelyaron.com Git - emacs.git/commitdiff
js-mode: Don't misindent generator methods
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 15 Oct 2015 19:34:18 +0000 (22:34 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 15 Oct 2015 19:36:08 +0000 (22:36 +0300)
* lisp/progmodes/js.el (js--looking-at-operator-p): Distinguish
generator methods from multiplication operator
(https://github.com/mooz/js2-mode/issues/275).

lisp/progmodes/js.el
test/indent/js.js

index f2140159e64c8c9aea8ff432fdcafcc3ab1f6f5e..5a4f383337e155aa6e188ca2155e41bbb9b1865e 100644 (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."
index 2120233259ae72b590c9db4d7fbec069bb941d7b..d897b9f81e77b7f407f3d8bced6e161dfce49520 100644 (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