]> git.eshelyaron.com Git - emacs.git/commitdiff
ruby-ts-mode: Fix indent inside parenthesized_expr and else/end after unless
authorDmitry Gutov <dgutov@yandex.ru>
Tue, 17 Jan 2023 22:41:14 +0000 (00:41 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Wed, 18 Jan 2023 01:27:37 +0000 (03:27 +0200)
* 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.

lisp/progmodes/ruby-ts-mode.el
test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb

index 19b766ceadb8c397cab3c704420032c4448ab76d..853c869a319278a14b7ca4ffcf30eb5245ac02b0 100644 (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)
index 6b4107ef97bd19be61932361e46f1b60c2a67419..7de94ceadec977b3e461a0d343a6ea4ab5ba298a 100644 (file)
@@ -18,6 +18,16 @@ qux = [1,
 att = {a: 1,
        b: 2}
 
+a = 1 ? 2 :(
+  2 + 3
+)
+
+unless bismark
+  sink += 12
+else
+  dog = 99
+end
+
 # Local Variables:
 # mode: ruby-ts
 # End: