]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle indentation of nested ternary operators in JS
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 13 Apr 2017 00:50:41 +0000 (03:50 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 13 Apr 2017 00:50:41 +0000 (03:50 +0300)
* lisp/progmodes/js.el (js--looking-at-operator-p):
Handle nested ternary operators.

lisp/progmodes/js.el
test/manual/indent/js.js

index c220353e9b702c9d5944926092f2faf17febafbe..bae9e52bf0fb570adacff4fe68de32132f2b9fda 100644 (file)
@@ -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
index 846c3a1a5c20ec5475c71698a906313110d681af..1ad76a83e18b60b3a5a05b49c06e6316f30aa007 100644 (file)
@@ -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