branch: elpa/typescript-mode
commit 2cd997a8d52c3a3e3fb1442227794bad27f1802f
Author: Louis-Dominique Dubeau <[email protected]>
Commit: Louis-Dominique Dubeau <[email protected]>
Fix typescript--backward-to-parameter-list
Fix typescript--backward-to-parameter-list to avoid walking over
constructs like `switch (...)`, `for (...)`, etc.
---
test-files/switch-case-indent-default.ts | 8 ++++++++
typescript-mode.el | 6 +++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/test-files/switch-case-indent-default.ts
b/test-files/switch-case-indent-default.ts
index b1af8804b5..788b78f4c0 100644
--- a/test-files/switch-case-indent-default.ts
+++ b/test-files/switch-case-indent-default.ts
@@ -3,7 +3,15 @@ function indentTest(): any {
case: 1,
default: 2
};
+
+ // This function was specifically added to test for a reversion in
+ // the code that indents switch statements.
+ function turnip(): void {
+ }
+
switch (process.platform) {
+ case "moo":
+ break;
case "win32": {
const basePath = process.env.LOCALAPPDATA ||
process.env.APPDATA;
diff --git a/typescript-mode.el b/typescript-mode.el
index 1d5536f0bc..12bd16e79c 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -2180,7 +2180,11 @@ moved on success."
;; The earlier test for dotted names comes into play if
the
;; logic moves over one part of a dotted name at a time
(which
;; is what `backward-sexp` normally does).
- (looking-back typescript--dotted-name-re nil))
+ (and (looking-back typescript--dotted-name-re nil)
+ ;; We don't want the loop to walk over constructs
like switch (...) or for (...), etc.
+ (not (save-excursion
+ (backward-word)
+ (looking-at
"\\_<\\(switch\\|if\\|while\\|until\\|for\\)\\_>\\(?:\\s-\\|\n\\)*(")))))
(condition-case nil
(backward-sexp)
(scan-error nil)))