[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 09bdb97c32 065/222: Fix an indentation bug
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 09bdb97c32 065/222: Fix an indentation bug. |
Date: |
Sun, 6 Feb 2022 16:59:16 -0500 (EST) |
branch: elpa/typescript-mode
commit 09bdb97c32b52e33a229d7b7d06633ccda8701e8
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>
Fix an indentation bug.
In a return value annotation, a generic in a position other than the
last in a union of types (e.g. Array<number> | number) was causing the
algorithm to go off-track.
---
test-files/indentation-reference-document.ts | 7 +++++++
typescript-mode.el | 25 +++++++++++++++----------
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/test-files/indentation-reference-document.ts
b/test-files/indentation-reference-document.ts
index d6e3124f0f..2fdf6ef337 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -282,6 +282,13 @@ function bif(a: number,
return "abc):d";
}
+// Generic and union in return type. This case was constructed from
+// a specific bug in the indentation code.
+function bif2(a: number,
+ b: number): Array<number> | number {
+ return 1;
+}
+
// Comment where the return type would appear.
function gogo(a: number,
b: number) /* foo */ {
diff --git a/typescript-mode.el b/typescript-mode.el
index 4b091fa64d..448a31e519 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1808,18 +1808,23 @@ moved on success."
(save-excursion
(loop named search-loop
do (progn
- (if (eq (char-before) ?>)
- (if (looking-back "=>" (- (point) 2))
- ;; Move back over the arrow of an arrow
function.
- (backward-char 2)
- ;; Otherwise, we are looking at the end of the
parameters
- ;; list of a generic. We need to move back over
the list.
- (backward-char)
-
(typescript--backward-over-generic-parameter-list))
- ;; General case: we just move back over the current
sexp.
+ (cond
+ ((eq (char-before) ?>)
+ (if (looking-back "=>" (- (point) 2))
+ ;; Move back over the arrow of an arrow function.
+ (backward-char 2)
+ ;; Otherwise, we are looking at the end of the
parameters
+ ;; list of a generic. We need to move back over the
list.
+ (backward-char)
+ (typescript--backward-over-generic-parameter-list)))
+ ;; Looking at a union: skip over the character.
+ ((eq (char-before) ?|)
+ (backward-char))
+ ;; General case: we just move back over the current
sexp.
+ (t
(condition-case nil
(backward-sexp)
- (scan-error nil)))
+ (scan-error nil))))
(typescript--backward-syntactic-ws)
(let ((before (char-before)))
;; Check whether we are at "):".
- [nongnu] elpa/typescript-mode ca510ab853 048/222: Merge pull request #30 from lddubeau/fix/keyword-members, (continued)
- [nongnu] elpa/typescript-mode ca510ab853 048/222: Merge pull request #30 from lddubeau/fix/keyword-members, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a2c2ff03e7 024/222: Add support for compilation-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7526f138a0 032/222: Avoid capturing things we dont need for compilation-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 666052f09f 033/222: Update readme., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4235b47a38 060/222: Fix indent for lines which starts with tabs., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 52c08d0628 091/222: Add more fontification tests for regular expressions., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e25c7ddb8a 062/222: Fix indentation of funcs with return annotations., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 536e4da380 087/222: Fix bug with hanling array shorthand in return value types., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 70acbf9c3d 078/222: Change font-lock-test to also accept a list of locations, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a2167a133d 056/222: Fix errors with indentation when line has wide unicode chars., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 09bdb97c32 065/222: Fix an indentation bug.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode 8b2815514d 088/222: Simplify typescript--backward-to-parameter-list, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f9cd0dd539 112/222: Try parse new error-format introduced in tsc 2.7+, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a1cdb7a1ec 121/222: Remove redundant regexp groups for jsdoc tags, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode fd1c9daa4d 094/222: Add failing cases., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode bd046e0fae 120/222: Add tags in usejsdoc.org, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 3c79132066 136/222: fix warnings from package-lint, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 000131df29 150/222: Update CI-settings, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b1d1948c15 123/222: Merge pull request #88 from Ptival/fix-indentation-method-calls-keywords, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 039d122384 156/222: add a test for simple tsx, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode c766ec8009 159/222: Include symbol constituents in typescript--function-call-re, ELPA Syncer, 2022/02/06