diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 5f4e11e0b4c..adcdf15c7ad 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -842,6 +842,16 @@ ruby-ts--parent-call-or-bol ;; No paren/curly/brace found on the same line. ((< (treesit-node-start found) parent-bol) parent-bol) + ;; Nesting of brackets args. + ((and + (not (eq ruby-bracketed-args-indent t)) + (string-match-p "\\`array\\|hash\\'" (treesit-node-type parent)) + (equal (treesit-node-parent parent) found) + ;; Grandparent is not a parenless call. + (or (not (equal (treesit-node-type found) "argument_list")) + (equal (treesit-node-type (treesit-node-child found 0)) + "("))) + parent-bol) ;; Hash or array opener on the same line. ((string-match-p "\\`array\\|hash\\'" (treesit-node-type found)) (save-excursion diff --git a/test/lisp/progmodes/ruby-ts-mode-tests.el b/test/lisp/progmodes/ruby-ts-mode-tests.el index 61ef80eb610..05d98974acf 100644 --- a/test/lisp/progmodes/ruby-ts-mode-tests.el +++ b/test/lisp/progmodes/ruby-ts-mode-tests.el @@ -326,6 +326,7 @@ "ruby-block-indent.rb" (ruby-ts-deftest-indent "ruby-method-call-indent.rb") (ruby-ts-deftest-indent "ruby-method-params-indent.rb") (ruby-ts-deftest-indent "ruby-parenless-call-arguments-indent.rb") +(ruby-ts-deftest-indent "ruby-bracketed-args-indent.rb") (provide 'ruby-ts-mode-tests)