(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).
This commit is contained in:
parent
2d02a5f729
commit
c28f87a53d
2 changed files with 20 additions and 10 deletions
|
@ -1770,7 +1770,11 @@ This performs fontification according to `js--class-styles'."
|
||||||
"Return non-nil if the current line continues an expression."
|
"Return non-nil if the current line continues an expression."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(or (js--looking-at-operator-p)
|
(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)
|
(and (js--re-search-backward "\n" nil t)
|
||||||
(progn
|
(progn
|
||||||
(skip-chars-backward " \t")
|
(skip-chars-backward " \t")
|
||||||
|
|
|
@ -95,6 +95,12 @@ Foobar
|
||||||
console.log(num);
|
console.log(num);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var arr = [
|
||||||
|
-1, 2,
|
||||||
|
-3, 4 +
|
||||||
|
-5
|
||||||
|
];
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// indent-tabs-mode: nil
|
// indent-tabs-mode: nil
|
||||||
// js-indent-level: 2
|
// js-indent-level: 2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue