[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b2af331 083/110: Special-case unary + and -
From: |
Dmitry Gutov |
Subject: |
[elpa] master b2af331 083/110: Special-case unary + and - |
Date: |
Thu, 23 Jun 2016 01:13:01 +0000 (UTC) |
branch: master
commit b2af3314dbc039f2f34c27b725f7e32dd7b5bd1a
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Special-case unary + and -
Fixes #322
---
js2-old-indent.el | 24 ++++++++++--------------
tests/indent.el | 7 +++++++
2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/js2-old-indent.el b/js2-old-indent.el
index d855b9e..d8932d6 100644
--- a/js2-old-indent.el
+++ b/js2-old-indent.el
@@ -239,20 +239,16 @@ and comments have been removed."
"Return non-nil if the current line continues an expression."
(save-excursion
(back-to-indentation)
- (or (js2-looking-at-operator-p)
- (when (catch 'found
- (while (and (re-search-backward "\n" nil t)
- (let ((state (syntax-ppss)))
- (when (nth 4 state)
- (goto-char (nth 8 state))) ;; skip comments
- (skip-chars-backward " \t")
- (if (bolp)
- t
- (throw 'found t))))))
- (backward-char)
- (when (js2-looking-at-operator-p)
- (backward-char)
- (not (looking-at "\\*\\|\\+\\+\\|--\\|/[/*]")))))))
+ (if (js2-looking-at-operator-p)
+ (or (not (memq (char-after) '(?- ?+)))
+ (progn
+ (forward-comment (- (point)))
+ (not (memq (char-before) '(?, ?\[ ?\()))))
+ (forward-comment (- (point)))
+ (or (bobp) (backward-char))
+ (when (js2-looking-at-operator-p)
+ (backward-char)
+ (not (looking-at "\\*\\|\\+\\+\\|--\\|/[/*]"))))))
(defun js2-end-of-do-while-loop-p ()
"Return non-nil if word after point is `while' of a do-while
diff --git a/tests/indent.el b/tests/indent.el
index b0235ff..91b8656 100644
--- a/tests/indent.el
+++ b/tests/indent.el
@@ -179,6 +179,13 @@
|}"
:bind ((js2-indent-switch-body t)))
+(js2-deftest-indent continued-expression-vs-unary-minus
+ "var arr = [
+ | -1, 2,
+ | -3, 4 +
+ | -5
+ |];")
+
(js2-deftest-indent jsx-one-line
"var foo = <div></div>;")
- [elpa] master e48e862 055/110: Also parse async function statement in export node, (continued)
- [elpa] master e48e862 055/110: Also parse async function statement in export node, Dmitry Gutov, 2016/06/22
- [elpa] master e9227bd 058/110: Fix a byte-compilation warning, Dmitry Gutov, 2016/06/22
- [elpa] master 2a904e0 057/110: Implement object literal rest/spread (...), Dmitry Gutov, 2016/06/22
- [elpa] master 8047d7f 061/110: Recognize for-of and for-in loops with const, Dmitry Gutov, 2016/06/22
- [elpa] master 983f20a 072/110: Fix typo, Dmitry Gutov, 2016/06/22
- [elpa] master f8248df 066/110: Record class declarations for IMenu, Dmitry Gutov, 2016/06/22
- [elpa] master d92e772 069/110: Fix async parsing, Dmitry Gutov, 2016/06/22
- [elpa] master 5c97dce 002/110: Fix typo; Refs #185, Dmitry Gutov, 2016/06/22
- [elpa] master 97065c8 075/110: Fix compiler warning, Dmitry Gutov, 2016/06/22
- [elpa] master 849e061 081/110: js2-indent-operator-re, js2-declaration-keyword-re: Use symbols boundaries, Dmitry Gutov, 2016/06/22
- [elpa] master b2af331 083/110: Special-case unary + and -,
Dmitry Gutov <=
- [elpa] master 7e7b6da 076/110: Simplify await parsing, Dmitry Gutov, 2016/06/22
- [elpa] master b57d129 077/110: Merge pull request #304 from jacksonrayhamilton/fix-void-async-await, Dmitry Gutov, 2016/06/22
- [elpa] master 645d129 078/110: Add support for JSDoc @callback, @func and @method tags, Dmitry Gutov, 2016/06/22
- [elpa] master b576cef 097/110: Declare vars created with renaming destructuring, Dmitry Gutov, 2016/06/22
- [elpa] master 12586e5 098/110: Allow space before global declaration, Dmitry Gutov, 2016/06/22
- [elpa] master 910520e 100/110: Merge pull request #333 from daniellandau/master, Dmitry Gutov, 2016/06/22
- [elpa] master 5ebc7b8 099/110: Change warning message to not conflict with spec, Dmitry Gutov, 2016/06/22
- [elpa] master ae3ed93 102/110: Backport for fix for #335, Dmitry Gutov, 2016/06/22
- [elpa] master fa419df 093/110: Merge pull request #327 from XeCycle/ckw-as, Dmitry Gutov, 2016/06/22
- [elpa] master b78d224 045/110: Parse async methods, Dmitry Gutov, 2016/06/22