[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 2573266955 086/222: Fix a bug in handling
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 2573266955 086/222: Fix a bug in handling function return type annotations. |
Date: |
Sun, 6 Feb 2022 16:59:20 -0500 (EST) |
branch: elpa/typescript-mode
commit 257326695531eb3320403a8624b7179b71fd1103
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>
Fix a bug in handling function return type annotations.
The algorithm would work fine indenting the line after the curly brace
in "function foo(): ((a: X) => void) {" but if the parentheses around
the return type were missing, the algorithm would go astray. This
commit fixes the problem.
---
test-files/indentation-reference-document.ts | 6 ++++++
typescript-mode.el | 11 +++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/test-files/indentation-reference-document.ts
b/test-files/indentation-reference-document.ts
index 16522752b0..12c7d843d0 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -252,6 +252,12 @@ function moo(x: any,
return null;
}
+// No parens around return type.
+function moo2(x: any,
+ f: string): (a: number) => void {
+ return null;
+}
+
// Parens around return type.
function foo(x: any,
f: string): ((a: number) => void) {
diff --git a/typescript-mode.el b/typescript-mode.el
index 6497d3b7cd..947d410929 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -2060,10 +2060,17 @@ moved on success."
(loop named search-loop
do (progn
(cond
- ;; Looking at the arrow of an arrow function:
+ ;; Looking at the arrow of a function definition:
;; move back over the arrow.
((looking-back "=>" (- (point) 2))
- (backward-char 2))
+ (backward-char 2)
+ (typescript--backward-syntactic-ws)
+ ;; Immediately handle a parenthesized list of
arguments. Otherwise, the
+ ;; algorithm here will go astray.
+ (when (eq (char-before) ?\))
+ (condition-case nil
+ (backward-sexp)
+ (scan-error nil))))
;; Looking at the end of the parameters list
;; of a generic: move back over the list.
((eq (char-before) ?>)
- [nongnu] branch elpa/typescript-mode created (now e824162051), ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a09bd6b0e7 001/222: initial commit, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 49b3cc1c4a 022/222: added "as" and "from" keywords, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 256d930586 010/222: Add type keyword from TypeScript 1.4, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 77aa2b44af 019/222: Merge pull request #14 from valerian/readonly, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 3b0ace2a71 037/222: Add GPLv3 license file to repo., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 9dde78e730 042/222: Add Travis CI build-status to readme., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7f4bf6cad9 075/222: Highlight function name for exported or declared functions., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2573266955 086/222: Fix a bug in handling function return type annotations.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode b62f52a35c 009/222: Add let, const, namespace keywords from 1.5, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 976ae69337 003/222: add url, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 514d6f0416 012/222: Add 'async' and 'await' as keywords, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d27114244a 014/222: added "abstract" keyword, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 54e0c562d4 020/222: removed keyword "bool" which is deprecated since TypeScript 0.9, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d81cc72782 013/222: Merge pull request #7 from paulkoerbitz/patch-1, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a532ef57cf 046/222: Merge pull request #29 from lddubeau/fix/method-generator, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode c1a7d40dd8 005/222: highlight template string, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 8fe879a96d 028/222: Support 'of' keyword., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode ca510ab853 048/222: Merge pull request #30 from lddubeau/fix/keyword-members, ELPA Syncer, 2022/02/06