diff options
| author | Dmitry Gutov | 2017-04-13 03:50:41 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2017-04-13 03:50:41 +0300 |
| commit | 6354e3c3368d99fad755d4dbd7c872ce1280f005 (patch) | |
| tree | 59a6f7279c027da215dc0e57d10d48fcbfb9c93d | |
| parent | 2e4f4c9d48c563ff8bec102b66da0225587786c6 (diff) | |
| download | emacs-6354e3c3368d99fad755d4dbd7c872ce1280f005.tar.gz emacs-6354e3c3368d99fad755d4dbd7c872ce1280f005.zip | |
Handle indentation of nested ternary operators in JS
* lisp/progmodes/js.el (js--looking-at-operator-p):
Handle nested ternary operators.
| -rw-r--r-- | lisp/progmodes/js.el | 2 | ||||
| -rw-r--r-- | test/manual/indent/js.js | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index c220353e9b7..bae9e52bf0f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el | |||
| @@ -1788,6 +1788,8 @@ This performs fontification according to `js--class-styles'." | |||
| 1788 | (and (looking-at js--indent-operator-re) | 1788 | (and (looking-at js--indent-operator-re) |
| 1789 | (or (not (eq (char-after) ?:)) | 1789 | (or (not (eq (char-after) ?:)) |
| 1790 | (save-excursion | 1790 | (save-excursion |
| 1791 | (js--backward-syntactic-ws) | ||
| 1792 | (when (= (char-before) ?\)) (backward-list)) | ||
| 1791 | (and (js--re-search-backward "[?:{]\\|\\_<case\\_>" nil t) | 1793 | (and (js--re-search-backward "[?:{]\\|\\_<case\\_>" nil t) |
| 1792 | (eq (char-after) ??)))) | 1794 | (eq (char-after) ??)))) |
| 1793 | (not (and | 1795 | (not (and |
diff --git a/test/manual/indent/js.js b/test/manual/indent/js.js index 846c3a1a5c2..1ad76a83e18 100644 --- a/test/manual/indent/js.js +++ b/test/manual/indent/js.js | |||
| @@ -128,6 +128,13 @@ if (x > 72 && | |||
| 128 | let x = svg.mumble() | 128 | let x = svg.mumble() |
| 129 | .zzz; | 129 | .zzz; |
| 130 | 130 | ||
| 131 | // https://github.com/mooz/js2-mode/issues/405 | ||
| 132 | if (1) { | ||
| 133 | isSet | ||
| 134 | ? (isEmpty ? 2 : 3) | ||
| 135 | : 4 | ||
| 136 | } | ||
| 137 | |||
| 131 | // Local Variables: | 138 | // Local Variables: |
| 132 | // indent-tabs-mode: nil | 139 | // indent-tabs-mode: nil |
| 133 | // js-indent-level: 2 | 140 | // js-indent-level: 2 |