emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 360d1d8: js-mode: Don't misindent generator methods


From: Dmitry Gutov
Subject: [Emacs-diffs] master 360d1d8: js-mode: Don't misindent generator methods
Date: Thu, 15 Oct 2015 19:48:28 +0000

branch: master
commit 360d1d8caa1db0ffa7d0c02d4f03a4c921155c5a
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    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).
---
 lisp/progmodes/js.el |   13 ++++++++++---
 test/indent/js.js    |    7 +++++++
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index f214015..5a4f383 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 "[?:{]\\|\\_<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."
diff --git a/test/indent/js.js b/test/indent/js.js
index 2120233..d897b9f 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]