ruby-ts-mode: Fix indent inside parenthesized_expr and else/end after unless

* lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules):
Fix indentation for parenthesized_expression and else/end after
'unless'.

* test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb:
New examples.
This commit is contained in:
Dmitry Gutov 2023-01-18 00:41:14 +02:00
parent 9ed9ff4690
commit 5e2e68a0c2
2 changed files with 15 additions and 2 deletions

View file

@ -587,11 +587,11 @@ i.e. expr of def foo(args) = expr is returned."
;;
;; I'm using very restrictive patterns hoping to reduce rules
;; triggering unintentionally.
((match "else" "if")
((match "else" "if\\|unless")
(ruby-ts--align-keywords ruby-ts--parent-node) 0)
((match "elsif" "if")
(ruby-ts--align-keywords ruby-ts--parent-node) 0)
((match "end" "if")
((match "end" "if\\|unless")
(ruby-ts--align-keywords ruby-ts--parent-node) 0)
((n-p-gp nil "then\\|else\\|elsif" "if\\|unless")
(ruby-ts--align-keywords ruby-ts--grand-parent-node) ruby-indent-level)
@ -754,6 +754,9 @@ i.e. expr of def foo(args) = expr is returned."
((match "]" "array") parent-bol 0)
((parent-is "array") parent-bol ruby-indent-level)
((match ")" "parenthesized_statements") parent-bol 0)
((parent-is "parenthesized_statements") parent-bol ruby-indent-level)
;; If the previous method isn't finished yet, this will get
;; the next method indented properly.
((n-p-gp ,ruby-ts--method-regex "body_statement" ,ruby-ts--class-or-module-regex)

View file

@ -18,6 +18,16 @@
att = {a: 1,
b: 2}
a = 1 ? 2 :(
2 + 3
)
unless bismark
sink += 12
else
dog = 99
end
# Local Variables:
# mode: ruby-ts
# End: