[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 9ed9ff4690 1/6: ruby-ts-mode: Fix the rules for hanging arrays
From: |
Dmitry Gutov |
Subject: |
emacs-29 9ed9ff4690 1/6: ruby-ts-mode: Fix the rules for hanging arrays and hashes |
Date: |
Tue, 17 Jan 2023 20:28:43 -0500 (EST) |
branch: emacs-29
commit 9ed9ff4690a8b26ac9729a66aa22f2e14856cd0c
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
ruby-ts-mode: Fix the rules for hanging arrays and hashes
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules):
Fix the rules for hanging arrays and hashes (to line up to
parent-bol instead of the opening brace).
* test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb:
New file with examples.
* test/lisp/progmodes/ruby-ts-mode-tests.el: Use it here.
---
lisp/progmodes/ruby-ts-mode.el | 18 ++++-------------
test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb | 23 ++++++++++++++++++++++
test/lisp/progmodes/ruby-ts-mode-tests.el | 1 +
3 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index 939c054b04..19b766cead 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -749,20 +749,10 @@ i.e. expr of def foo(args) = expr is returned."
(not ruby-ts--same-line-hash-array-p))
grand-parent ruby-indent-level)
- ((n-p-gp "}" "hash" "assignment") (ruby-ts--bol
ruby-ts--grand-parent-node) 0)
- ((n-p-gp nil "hash" "assignment") (ruby-ts--bol
ruby-ts--grand-parent-node) ruby-indent-level)
- ((n-p-gp "]" "array" "assignment") (ruby-ts--bol
ruby-ts--grand-parent-node) 0)
- ((n-p-gp nil "array" "assignment") (ruby-ts--bol
ruby-ts--grand-parent-node) ruby-indent-level)
-
- ((n-p-gp "}" "hash" "argument_list") first-sibling 0)
- ((n-p-gp nil "hash" "argument_list") first-sibling
ruby-indent-level)
- ((n-p-gp "]" "array" "argument_list") first-sibling 0)
- ((n-p-gp nil "array" "argument_list") first-sibling
ruby-indent-level)
-
- ((match "}" "hash") first-sibling 0)
- ((parent-is "hash") first-sibling ruby-indent-level)
- ((match "]" "array") first-sibling 0)
- ((parent-is "array") first-sibling ruby-indent-level)
+ ((match "}" "hash") parent-bol 0)
+ ((parent-is "hash") parent-bol ruby-indent-level)
+ ((match "]" "array") parent-bol 0)
+ ((parent-is "array") parent-bol ruby-indent-level)
;; If the previous method isn't finished yet, this will get
;; the next method indented properly.
diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb
b/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb
new file mode 100644
index 0000000000..6b4107ef97
--- /dev/null
+++ b/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb
@@ -0,0 +1,23 @@
+variable = foo(
+ [
+ qwe
+ ], [
+ rty
+ ], {
+ a: 3
+ }
+)
+
+tee = [
+ qwe
+]
+
+qux = [1,
+ 2]
+
+att = {a: 1,
+ b: 2}
+
+# Local Variables:
+# mode: ruby-ts
+# End:
diff --git a/test/lisp/progmodes/ruby-ts-mode-tests.el
b/test/lisp/progmodes/ruby-ts-mode-tests.el
index eaf6367a30..d7b6258385 100644
--- a/test/lisp/progmodes/ruby-ts-mode-tests.el
+++ b/test/lisp/progmodes/ruby-ts-mode-tests.el
@@ -250,6 +250,7 @@ The whitespace before and including \"|\" on each line is
removed."
(should (equal (buffer-string) orig))))
(kill-buffer buf)))))
+(ruby-ts-deftest-indent "ruby-ts.rb")
(ruby-ts-deftest-indent "ruby-method-params-indent.rb")
(ruby-ts-deftest-indent "ruby-block-indent.rb")
- emacs-29 updated (c4f0b6ccea -> 343b9b3dfe), Dmitry Gutov, 2023/01/17
- emacs-29 343b9b3dfe 6/6: ruby-ts-mode: Obey the option ruby-method-call-indent, Dmitry Gutov, 2023/01/17
- emacs-29 045404d1aa 5/6: ruby-ts-mode: Obey the option ruby-after-operator-indent, Dmitry Gutov, 2023/01/17
- emacs-29 9ed9ff4690 1/6: ruby-ts-mode: Fix the rules for hanging arrays and hashes,
Dmitry Gutov <=
- emacs-29 5e2e68a0c2 2/6: ruby-ts-mode: Fix indent inside parenthesized_expr and else/end after unless, Dmitry Gutov, 2023/01/17
- emacs-29 ac5516bd7d 3/6: ruby-ts-mode: Fix/change indentation of a continuation method call, Dmitry Gutov, 2023/01/17
- emacs-29 300ca6ac37 4/6: ruby-ts-mode: Fix indent after operator or conditional, Dmitry Gutov, 2023/01/17