[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode f25f4751fe 052/222: Merge pull request #31
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode f25f4751fe 052/222: Merge pull request #31 from lddubeau/fix/spread-syntax |
Date: |
Sun, 6 Feb 2022 16:59:13 -0500 (EST) |
branch: elpa/typescript-mode
commit f25f4751fea12298905c811a1f469a6b0a169ef1
Merge: 5931f2776d 89d22c4e18
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: GitHub <noreply@github.com>
Merge pull request #31 from lddubeau/fix/spread-syntax
Indentation fixes for handling the spread syntax and regular expressions in
lists.
---
test-files/indentation-reference-document.ts | 40 ++++++++++++++++++++++++++++
typescript-mode.el | 32 +++++++++++++++-------
2 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/test-files/indentation-reference-document.ts
b/test-files/indentation-reference-document.ts
index f6c4919120..da1dd7d80c 100644
--- a/test-files/indentation-reference-document.ts
+++ b/test-files/indentation-reference-document.ts
@@ -196,4 +196,44 @@ namespace ts.server {
}
}
}
+
+ // Spread syntax
+ {
+ const a = { a: 1, b: 2 };
+ const b = {
+ ...a,
+ a: 3,
+ };
+ const c = [1, 2];
+ const d = [
+ "a",
+ ...c
+ ];
+
+ function foo(a: string,
+ b: number,
+ ...rest: any[]) {
+ }
+ }
+
+ {
+ // Regular expressions in lists.
+
+ // List objects...
+ const a = [
+ /abc/,
+ /def/
+ ];
+
+ const z =
+ /abcd/;
+
+ // Argument lists...
+ function foo(a: RegExp, b: RegExp): void {
+ }
+
+ foo(
+ /abc/,
+ /def/);
+ }
}
diff --git a/typescript-mode.el b/typescript-mode.el
index 08651a8dd0..5de10fb9a6 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -1659,6 +1659,14 @@ See `font-lock-keywords'.")
(save-excursion
(and (typescript--re-search-backward "[?:{]\\|\\_<case\\_>" nil
t)
(looking-at "?"))))
+ ;; Do not identify forward slashes appearing in a "list" as
+ ;; an operator. The lists are: arrays, or lists of
+ ;; arguments. In this context, they must be part of regular
+ ;; expressions, and not math operators.
+ (not (and (looking-at "/")
+ (save-excursion
+ (typescript--backward-syntactic-ws)
+ (memq (char-before) '(?, ?\[ ?\()))))
;; Do not identify methods, or fields, that are named "in" or
;; "instanceof" as being operator keywords.
(not (and
@@ -1683,16 +1691,20 @@ See `font-lock-keywords'.")
"Return non-nil if the current line continues an expression."
(save-excursion
(back-to-indentation)
- (or (typescript--looking-at-operator-p)
- (and (typescript--re-search-backward "\n" nil t)
- (progn
- (skip-chars-backward " \t")
- (or (bobp) (backward-char))
- (and (> (point) (point-min))
- (save-excursion (backward-char) (not (looking-at "[/*]/")))
- (typescript--looking-at-operator-p)
- (and (progn (backward-char)
- (not (looking-at "++\\|--\\|/[/*]"))))))))))
+ (and
+ ;; Don't identify the spread syntax or rest operator as a
+ ;; "continuation".
+ (not (looking-at "\\.\\.\\."))
+ (or (typescript--looking-at-operator-p)
+ (and (typescript--re-search-backward "\n" nil t)
+ (progn
+ (skip-chars-backward " \t")
+ (or (bobp) (backward-char))
+ (and (> (point) (point-min))
+ (save-excursion (backward-char) (not (looking-at
"[/*]/")))
+ (typescript--looking-at-operator-p)
+ (and (progn (backward-char)
+ (not (looking-at "++\\|--\\|/[/*]")))))))))))
(defun typescript--end-of-do-while-loop-p ()
- [nongnu] elpa/typescript-mode 5a3c84247d 007/222: Typescript added the "protected" keyword in 1.3., (continued)
- [nongnu] elpa/typescript-mode 5a3c84247d 007/222: Typescript added the "protected" keyword in 1.3., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 49241bcc1f 011/222: Merge pull request #3 from OrangeShark/typescript1.5, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode ad8f356cbe 021/222: Merge pull request #15 from valerian/bool, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 39827549ef 017/222: Merge pull request #13 from wingyplus/highlight-set-and-get-keyword, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 266be8f6c7 018/222: added "readonly" keyword, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 588d5f3d63 027/222: Update README.md, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f72826e564 036/222: Merge pull request #25 from ananthakumaran/revert-24-wrong-cursor-position, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d5c4fb27c8 034/222: Merge pull request #24 from hekt/wrong-cursor-position, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 447cfbc078 030/222: Improve compilation-mode support., ELPA Syncer, 2022/02/06
- [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 <=
- [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, 2022/02/06
- [nongnu] elpa/typescript-mode e780858a86 050/222: Don't interpret spread syntax as a continuation., ELPA Syncer, 2022/02/06