branch: elpa/typescript-mode
commit 30391a518a1d41d5c534a30850a50b0974132aec
Author: Louis-Dominique Dubeau <[email protected]>
Commit: Louis-Dominique Dubeau <[email protected]>

    Fix indentation issue with conditional operators.
    
    Prior to this change if the conditional operator had an object
    in the true branch, indentation would fail.
---
 test-files/indentation-reference-document.ts | 4 ++++
 typescript-mode.el                           | 6 ++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/test-files/indentation-reference-document.ts 
b/test-files/indentation-reference-document.ts
index 2fdf6ef337..16522752b0 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -161,6 +161,10 @@ namespace ts.server {
             2 :
             3;
 
+        const e2 = b ?
+            { a: 1 } :
+            3;
+
         const f = window
             .document;
 
diff --git a/typescript-mode.el b/typescript-mode.el
index a7f5970d2f..9d16f697d7 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1906,8 +1906,10 @@ See `font-lock-keywords'.")
     (and (looking-at typescript--indent-operator-re)
          (or (not (looking-at ":"))
              (save-excursion
-               (and (typescript--re-search-backward "[?:{]\\|\\_<case\\_>" nil 
t)
-                    (looking-at "?"))))
+               (backward-sexp)
+               (and
+                (typescript--re-search-backward "[?:{]\\|\\_<case\\_>" nil t)
+                (looking-at "?"))))
          ;; Do not identify forward slashes appearing in a "list" as
          ;; an operator. The lists are: arrays, or lists of
          ;; arguments. In this context, they must be part of regular

Reply via email to