(ruby-ts--indent-rules): Indent inside empty parens properly

* 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.
This commit is contained in:
Dmitry Gutov 2023-01-19 17:31:43 +02:00
parent 7fb69ce233
commit 0d3b6518e3
2 changed files with 15 additions and 1 deletions

View 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"))

View 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")