emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-25 c28f87a: (js--continued-expression-p): Special-ca


From: Dmitry Gutov
Subject: [Emacs-diffs] emacs-25 c28f87a: (js--continued-expression-p): Special-case unary plus and minus
Date: Sat, 02 Apr 2016 00:07:25 +0000

branch: emacs-25
commit c28f87a53d4955396a3e3cb0223500eca921a872
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    (js--continued-expression-p): Special-case unary plus and minus
    
    * lisp/progmodes/js.el (js--continued-expression-p): Make an
    effort to recognize unary plus and minus, in the contexts where
    they make sense (https://github.com/mooz/js2-mode/issues/322).
---
 lisp/progmodes/js.el |   24 ++++++++++++++----------
 test/indent/js.js    |    6 ++++++
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 15a52ba..8c93ffa 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1770,16 +1770,20 @@ This performs fontification according to 
`js--class-styles'."
   "Return non-nil if the current line continues an expression."
   (save-excursion
     (back-to-indentation)
-    (or (js--looking-at-operator-p)
-        (and (js--re-search-backward "\n" nil t)
-            (progn
-              (skip-chars-backward " \t")
-              (or (bobp) (backward-char))
-              (and (> (point) (point-min))
-                    (save-excursion (backward-char) (not (looking-at "[/*]/")))
-                    (js--looking-at-operator-p)
-                   (and (progn (backward-char)
-                               (not (looking-at "+\\+\\|--\\|/[/*]"))))))))))
+    (if (js--looking-at-operator-p)
+        (or (not (memq (char-after) '(?- ?+)))
+            (progn
+              (forward-comment (- (point)))
+              (not (memq (char-before) '(?, ?\[ ?\()))))
+      (and (js--re-search-backward "\n" nil t)
+           (progn
+             (skip-chars-backward " \t")
+             (or (bobp) (backward-char))
+             (and (> (point) (point-min))
+                  (save-excursion (backward-char) (not (looking-at "[/*]/")))
+                  (js--looking-at-operator-p)
+                  (and (progn (backward-char)
+                              (not (looking-at "+\\+\\|--\\|/[/*]"))))))))))
 
 
 (defun js--end-of-do-while-loop-p ()
diff --git a/test/indent/js.js b/test/indent/js.js
index d843f61..61c7b44 100644
--- a/test/indent/js.js
+++ b/test/indent/js.js
@@ -95,6 +95,12 @@ Foobar
     console.log(num);
   });
 
+var arr = [
+  -1, 2,
+  -3, 4 +
+    -5
+];
+
 // Local Variables:
 // indent-tabs-mode: nil
 // js-indent-level: 2



reply via email to

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