[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode d29f31c791 045/222: Fix indentation of met
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode d29f31c791 045/222: Fix indentation of methods that are generators. |
Date: |
Sun, 6 Feb 2022 16:59:10 -0500 (EST) |
branch: elpa/typescript-mode
commit d29f31c7912c376b121394097cae0b3fc575636e
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>
Fix indentation of methods that are generators.
This is adapted from js.el's js--looking-at-operator-p function.
Fixes #9.
---
test-files/indentation-reference-document.ts | 73 ++++++++++++++++++++++++++++
typescript-mode.el | 13 ++++-
2 files changed, 85 insertions(+), 1 deletion(-)
diff --git a/test-files/indentation-reference-document.ts
b/test-files/indentation-reference-document.ts
index a6df0e6dc0..36996c5a73 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -89,4 +89,77 @@ namespace ts.server {
process.on("uncaughtException", function (err: Error) {
ioSession.logError(err, "unknown");
});
+
+ // Generators as methods.
+ class WithAGeneratorFirst {
+ *blah() {
+ }
+ }
+
+ class WithAGeneratorAfterAProperty {
+ public foo: string = "1";
+
+ *blah() {
+ }
+ }
+
+ class WithAGeneratorAfterAnotherMethod {
+ foo() {
+ }
+
+ *blah() {
+ }
+ }
+
+ class WithSpaceAfterAsterisk {
+ bar() {
+ }
+
+ * oops() {
+ }
+ }
+
+
+ class WithSpaceAfterParens {
+ bar() {
+ }
+
+ *oops () {
+ }
+ }
+
+ class WithArguments {
+ bar() {
+ }
+
+ *oops(foo: number, bar: string) {
+ }
+ }
+
+ // Some continued expressions
+ {
+ const a = 1 *
+ 2 /
+ 3 +
+ 4 -
+ 5 %
+ 6;
+
+ const b = 1 >
+ 2;
+
+ const c = 1 <
+ 2;
+
+ const d = 1 &
+ 2 |
+ 3;
+
+ const e = b ?
+ 2 :
+ 3;
+
+ const f = window
+ .document;
+ }
}
diff --git a/typescript-mode.el b/typescript-mode.el
index ba2919decc..8c5f516d56 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1655,7 +1655,18 @@ See `font-lock-keywords'.")
(or (not (looking-at ":"))
(save-excursion
(and (typescript--re-search-backward "[?:{]\\|\\_<case\\_>" nil
t)
- (looking-at "?")))))))
+ (looking-at "?"))))
+ (not (and
+ (looking-at "*")
+ ;; Generator method (possibly using computed property).
+ (looking-at (concat "\\* *\\(?:\\[\\|" typescript--name-re
+ " *(\\)"))
+ (save-excursion
+ (typescript--backward-syntactic-ws)
+ ;; We might misindent some expressions that would
+ ;; return NaN anyway. Shouldn't be a problem.
+ (memq (char-before) '(?, ?} ?{ ?\;)))))))
+)
(defun typescript--continued-expression-p ()
- [nongnu] elpa/typescript-mode b502d8453d 041/222: On second thought, lets NOT support Emacs 24.1 and 24.2., (continued)
- [nongnu] elpa/typescript-mode b502d8453d 041/222: On second thought, lets NOT support Emacs 24.1 and 24.2., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f25f4751fe 052/222: Merge pull request #31 from lddubeau/fix/spread-syntax, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2587e92851 047/222: Don't interpret class members as keywords., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode face381789 083/222: Implement clean make-target to assist local development., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 20af0fec5f 077/222: Extend function prefix font-lock test to check arguments are correct., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5e2165d4b6 038/222: We need a Gitignore-file., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 330c887241 095/222: Fix indentation of functions with numbers in return type., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b7074c5dea 106/222: Remove redundant code, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode bf9a4155cc 043/222: Revise Emacs versions tested a little more., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a3c91282bc 039/222: Add test-case and indentation-reference document., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d29f31c791 045/222: Fix indentation of methods that are generators.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode e780858a86 050/222: Don't interpret spread syntax as a continuation., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f3140123d6 067/222: Remove a leftover comment., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode aae70b59e6 023/222: Merge pull request #16 from wingyplus/add-as-and-from-keywords, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 3766e37f24 026/222: Add README, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f6907e8ae3 031/222: Fix error in compilation-mode alist registration., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 316b018d27 040/222: Add CI-config and test-runner., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode ab6d105807 076/222: Add regression tests for function name highlighting., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2c43dd034c 068/222: Merge pull request #46 from ananthakumaran/fix/union-type-in-return-annotation, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 3361adad67 093/222: Prevent messing up comment fontification when filling paragraphs., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5350c45aec 104/222: Add function to convert plain strings to template strings., ELPA Syncer, 2022/02/06