branch: elpa/typescript-mode
commit dd832751abf27f4dd098f09e2dbf69511faa38a5
Merge: c9b22f5f33 7d80174b23
Author: Jostein Kjønigsen <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #156 from zkry/fix-dot-after-exclamation-indentation
Skip past ? and ! in typescript--compute-member-expression-indent
---
typescript-mode-general-tests.el | 8 ++++++++
typescript-mode.el | 2 ++
2 files changed, 10 insertions(+)
diff --git a/typescript-mode-general-tests.el b/typescript-mode-general-tests.el
index 3ccdb0539f..c900bc01b0 100644
--- a/typescript-mode-general-tests.el
+++ b/typescript-mode-general-tests.el
@@ -204,6 +204,14 @@ a severity set to WARNING, no rule name."
(forward-char 1)
(should (= 8 (current-column)))))
+(ert-deftest correctly-indents-dot-dot-after-exclamation ()
+ (with-temp-buffer
+ (ignore-errors (typescript-mode))
+ (insert "situation('8/8/8/8/8/8/8/R3K2R w - - 0 1')?.")
+ (forward-char -1)
+ (newline-and-indent)
+ (should (= 4 (current-column)))))
+
(ert-deftest indentation-does-not-hang-on-multiline-string ()
"Testcase for https://github.com/ananthakumaran/typescript.el/issues/20"
diff --git a/typescript-mode.el b/typescript-mode.el
index ef4f0e55b9..8c1b7eb230 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -2308,6 +2308,8 @@ starts the member expression.
(typescript--backward-syntactic-ws)
(while (eq (char-before) ?\;)
(backward-char))
+ (when (memq (char-before) '(?\? ?\!))
+ (backward-char))
(while (memq (char-before) '(?\] ?} ?\) ?>))
(if (not (eq (char-before) ?>))
(backward-list)