From 94e330243e14200ba6b45e696e6a80c611438dec Mon Sep 17 00:00:00 2001
From: Dmitry Gutov <dgutov@yandex.ru>
Date: Tue, 3 Jan 2023 02:26:00 +0200
Subject: [PATCH] ruby-ts-mode: Indentation fixes

* lisp/progmodes/ruby-ts-mode.el (ruby-ts--align-keywords):
Fix for 'def' (which was misread as 'method' in the check).
(ruby-ts--indent-rules): Indent the curly block closer the same
way as the 'do ... end' closer.
---
 lisp/progmodes/ruby-ts-mode.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index 96596cb5daf..6fb6f71991c 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -355,8 +355,11 @@ Otherwise return start of PRED."
   (lambda (node parent bol &rest rest)
     (let* ((pred-node (funcall pred node parent bol rest))
            (temp (treesit-node-start pred-node))
-           (keyword (treesit-node-type pred-node))
-           (bol (ruby-smie--indent-to-stmt-p keyword)))
+           (type (treesit-node-type pred-node))
+           (bol (ruby-smie--indent-to-stmt-p
+                 (if (equal type "method")
+                     "def"
+                   type))))
       (when temp
         (if bol
             (save-excursion
@@ -736,7 +739,7 @@ i.e. expr of def foo(args) = expr is returned."
            ((match "end" "do_block") parent-bol 0)
            ((n-p-gp "block_body" "block" nil) parent-bol ruby-indent-level)
            ((n-p-gp nil "block_body" "block") (ruby-ts--bol ruby-ts--grand-parent-node) ruby-indent-level)
-           ((match "}" "block") (ruby-ts--bol ruby-ts--grand-parent-node) 0)
+           ((match "}" "block") parent-bol 0)
 
            ;; Chained strings
            ((match "string" "chained_string") first-sibling 0)
-- 
2.39.5