1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-01 09:51:22 -08:00
emacs/test/lisp/progmodes/ruby-mode-resources/ruby-bracketed-args-indent.rb
Aaron Jensen 16a7051888 Fix indentation of keyword argument arrays/hashes in ruby-mode
* lisp/progmodes/ruby-mode.el (ruby-smie-rules): Check for ':' and
'=>' as previous tokens, and handle symbols ending with ':' to
properly indent keyword argument arrays and hashes when
ruby-bracketed-args-indent is nil.

* lisp/progmodes/ruby-ts-mode.el (ruby-ts--parent-call-or-bol):
Handle arrays/hashes that are children of 'pair' nodes (keyword
arguments) to ensure consistent indentation.

* test/lisp/progmodes/ruby-mode-resources/ruby-bracketed-args-indent.rb:
Add test cases for keyword argument arrays and hashes with both
symbol-colon and hash-rocket syntax.

When ruby-bracketed-args-indent is nil, arrays and hashes used as
keyword argument values now indent by ruby-indent-level from the
line start, matching the documented behavior and fixing inconsistent
indentation (bug#74517).

(https://lists.gnu.org/archive/html/emacs-devel/2025-11/msg00939.html)
2025-11-26 01:31:12 +02:00

60 lines
586 B
Ruby

foo
.update({
key => value,
other_key:
}, {
key => value,
other_key:
})
update([
1,
2
], [
3,
4
])
update([{
key: "value"
}, {
key: "value"
}])
update(arg1, {
foo: "bar"
}, [
1,
2
], arg2)
def foo
foo.update(
{
key => value,
other_key: foo
}
)
end
some_method(arg, include: [
:value1,
:value2
])
some_method(arg, options: {
key: "value"
})
some_method(arg, :include => [
:value1,
:value2
])
some_method(arg, :options => {
:key => "value"
})
# Local Variables:
# ruby-bracketed-args-indent: nil
# End: