]> git.eshelyaron.com Git - emacs.git/commitdiff
(ruby-ts--indent-rules): Indent inside empty parens properly
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 19 Jan 2023 15:31:43 +0000 (17:31 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 19 Jan 2023 17:44:10 +0000 (19:44 +0200)
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules):
Consider the case when there are no arguments inside the call yet.

* test/lisp/progmodes/ruby-ts-mode-tests.el
(ruby-ts-indent-call-no-args): Add test.

lisp/progmodes/ruby-ts-mode.el
test/lisp/progmodes/ruby-ts-mode-tests.el

index f075824591d0e4f9fa671fe65279abf218599c37..41a1d8df2a6695fefeca75ae37353dfe7519a54f 100644 (file)
@@ -680,7 +680,9 @@ a statement container is a node that matches
            ((and (query "(argument_list \"(\" _ @indent)")
                  (node-is ")"))
             ruby-ts--parent-call-or-bol 0)
-           ((query "(argument_list \"(\" _ @indent)")
+           ((or (query "(argument_list \"(\" _ @indent)")
+                ;; No arguments yet; NODE is nil in that case.
+                (match "\\`\\'" "argument_list"))
             ruby-ts--parent-call-or-bol ruby-indent-level)
            ;; 3) No paren, ruby-parenless-call-arguments-indent is t
            ((and ruby-ts--parenless-call-arguments-indent-p (parent-is "argument_list"))
index d34c235e82ba950fce353667e46c0f5261c26167..18e3e60a04a51bdfc13b94f8093d15adef83469f 100644 (file)
@@ -110,6 +110,18 @@ The whitespace before and including \"|\" on each line is removed."
      |      42
      |    end")))
 
+
+(ert-deftest ruby-ts-indent-call-no-args ()
+  (skip-unless (treesit-ready-p 'ruby t))
+  (ruby-ts-with-temp-buffer
+      "variable = foo(
+
+)"
+    (goto-char (point-min))
+    (forward-line 1)
+    (funcall indent-line-function)
+    (should (= (current-indentation) ruby-indent-level))))
+
 (ert-deftest ruby-ts-add-log-current-method-examples ()
   (skip-unless (treesit-ready-p 'ruby t))
   (let ((pairs '(("foo" . "#foo")