[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 42a60e5c88 190/222: Merge pull request #13
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 42a60e5c88 190/222: Merge pull request #137 from sirikid/feature/comma-first-lists |
Date: |
Sun, 6 Feb 2022 16:59:31 -0500 (EST) |
branch: elpa/typescript-mode
commit 42a60e5c881082db2ec2c541a5c154308c4863e6
Merge: f36fddeb54 710f5425a4
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: GitHub <noreply@github.com>
Merge pull request #137 from sirikid/feature/comma-first-lists
Add option for list items indenting
---
test-files/list-items-indent-comma-first.ts | 22 +++++++++++++++++++
test-files/list-items-indent-default.ts | 22 +++++++++++++++++++
typescript-mode-general-tests.el | 34 +++++++++++++++++++++++++++++
typescript-mode.el | 8 ++++++-
4 files changed, 85 insertions(+), 1 deletion(-)
diff --git a/test-files/list-items-indent-comma-first.ts
b/test-files/list-items-indent-comma-first.ts
new file mode 100644
index 0000000000..2a7485c89c
--- /dev/null
+++ b/test-files/list-items-indent-comma-first.ts
@@ -0,0 +1,22 @@
+const arr =
+ [ 'one'
+ , 'two'
+ , 'three' ];
+
+const obj =
+ { a: 111
+ , b: 222
+ , c: 333 };
+
+const depth = { arr: [ 'one'
+ , 'two'
+ , 'three' ]
+ , obj: { a: 111
+ , b: 222
+ , c: 333 }
+ , func_call: Object.assign
+ ( {}
+ , { x: 1
+ , y: 2
+ , z: 3 }
+ , { i: 'i', j: 'j' } ) };
diff --git a/test-files/list-items-indent-default.ts
b/test-files/list-items-indent-default.ts
new file mode 100644
index 0000000000..290c8250dc
--- /dev/null
+++ b/test-files/list-items-indent-default.ts
@@ -0,0 +1,22 @@
+const arr =
+ [ 'one'
+ , 'two'
+ , 'three' ];
+
+const obj =
+ { a: 111
+ , b: 222
+ , c: 333 };
+
+const depth = { arr: [ 'one'
+ , 'two'
+ , 'three' ]
+ , obj: { a: 111
+ , b: 222
+ , c: 333 }
+ , func_call: Object.assign
+ ( {}
+ , { x: 1
+ , y: 2
+ , z: 3 }
+ , { i: 'i', j: 'j' } ) };
diff --git a/typescript-mode-general-tests.el b/typescript-mode-general-tests.el
index 6e3f098aa7..aa1f1f8c78 100644
--- a/typescript-mode-general-tests.el
+++ b/typescript-mode-general-tests.el
@@ -52,6 +52,40 @@
(typescript-test-get-doc))))
(kill-buffer buffer)))
+(ert-deftest list-items-indent-default ()
+ (with-current-buffer (find-file "test-files/list-items-indent-default.ts")
+ (typescript-mode)
+ (let ((test-reference (typescript-test-get-doc)))
+ (typescript-test-indent-all)
+ (should (string= test-reference (typescript-test-get-doc))))
+ (kill-buffer)))
+
+(ert-deftest list-items-indent-default-not-comma-first ()
+ (with-current-buffer (find-file
"test-files/list-items-indent-comma-first.ts")
+ (typescript-mode)
+ (let ((test-reference (typescript-test-get-doc)))
+ (typescript-test-indent-all)
+ (should (not (string= test-reference (typescript-test-get-doc)))))
+ (kill-buffer)))
+
+(ert-deftest list-items-indent-comma-first ()
+ (with-current-buffer (find-file
"test-files/list-items-indent-comma-first.ts")
+ (typescript-mode)
+ (let ((test-reference (typescript-test-get-doc))
+ (typescript-indent-list-items nil))
+ (typescript-test-indent-all)
+ (should (string= test-reference (typescript-test-get-doc))))
+ (kill-buffer)))
+
+(ert-deftest list-items-indent-comma-first-not-default ()
+ (with-current-buffer (find-file "test-files/list-items-indent-default.ts")
+ (typescript-mode)
+ (let ((test-reference (typescript-test-get-doc))
+ (typescript-indent-list-items nil))
+ (typescript-test-indent-all)
+ (should (not (string= test-reference (typescript-test-get-doc)))))
+ (kill-buffer)))
+
(defun get-all-matched-strings (to-match)
(let (result)
(dotimes (x (/ (length (match-data)) 2))
diff --git a/typescript-mode.el b/typescript-mode.el
index 09add95553..7bad249e70 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -653,6 +653,11 @@ replicate tsserver behaviour. Indent level is taken to be
:type 'boolean
:group 'typescript)
+(defcustom typescript-indent-list-items t
+ "Enable indenting of list items, useful for certain code styles."
+ :type 'boolean
+ :group 'typescript)
+
(defcustom typescript-auto-indent-flag t
"Whether to automatically indent when typing punctuation characters.
If non-nil, the characters {}();,: also indent the current line
@@ -2535,7 +2540,8 @@ moved on success."
(if (and in-switch-p typescript-indent-switch-clauses)
(+ indent typescript-indent-level)
indent)))
- (unless same-indent-p
+ (when (and (not same-indent-p)
+ typescript-indent-list-items)
(forward-char)
(skip-chars-forward " \t"))
(if continued-expr-p
- [nongnu] elpa/typescript-mode f9cd0dd539 112/222: Try parse new error-format introduced in tsc 2.7+, (continued)
- [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
- [nongnu] elpa/typescript-mode 5e0b9ee095 168/222: Add a test that fails without the following indentation fix., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 42a60e5c88 190/222: Merge pull request #137 from sirikid/feature/comma-first-lists,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode 1c2a8b2391 211/222: Move build to use proper tasks, support OSX and Windows., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7f1cde0a90 221/222: Make c-comment-line-break-function work as expected., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 438fc968bf 016/222: Highlight set and get keyword, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b6e993513c 015/222: Merge pull request #10 from nahuel/patch-1, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 09123ba690 002/222: prepare for melpa, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode abc0751c0e 025/222: Merge pull request #22 from josteink/master, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5931f2776d 049/222: Add keyof keyword., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 782e8dd32e 071/222: Add fontification support for jsdoc/typedoc tags., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f6d28c7a0d 073/222: Remove the fontification hack., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4b69ca57f5 080/222: Simplify regexp literal, ELPA Syncer, 2022/02/06