emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 6354e3c: Handle indentation of nested ternary opera


From: Dmitry Gutov
Subject: [Emacs-diffs] master 6354e3c: Handle indentation of nested ternary operators in JS
Date: Wed, 12 Apr 2017 20:51:45 -0400 (EDT)

branch: master
commit 6354e3c3368d99fad755d4dbd7c872ce1280f005
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Handle indentation of nested ternary operators in JS
    
    * lisp/progmodes/js.el (js--looking-at-operator-p):
    Handle nested ternary operators.
---
 lisp/progmodes/js.el     | 2 ++
 test/manual/indent/js.js | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index c220353..bae9e52 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1788,6 +1788,8 @@ This performs fontification according to 
`js--class-styles'."
     (and (looking-at js--indent-operator-re)
          (or (not (eq (char-after) ?:))
              (save-excursion
+               (js--backward-syntactic-ws)
+               (when (= (char-before) ?\)) (backward-list))
                (and (js--re-search-backward "[?:{]\\|\\_<case\\_>" nil t)
                     (eq (char-after) ??))))
          (not (and
diff --git a/test/manual/indent/js.js b/test/manual/indent/js.js
index 846c3a1..1ad76a8 100644
--- a/test/manual/indent/js.js
+++ b/test/manual/indent/js.js
@@ -128,6 +128,13 @@ if (x > 72 &&
 let x = svg.mumble()
     .zzz;
 
+// https://github.com/mooz/js2-mode/issues/405
+if (1) {
+  isSet
+    ? (isEmpty ? 2 : 3)
+    : 4
+}
+
 // Local Variables:
 // indent-tabs-mode: nil
 // js-indent-level: 2



reply via email to

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