Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions fixtures/small/aref_in_call_chain_actual.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
assert_equal(
1,
T.cast(T.must(pages[1]&.elements)[0], Name::Spacing::To::Extend::CodeQuality::AcrossManyLines).table[
:line_items
]
.length
)

foo.bar[some_really_long_index][another_really_long_index]
.baz
.qux

result.data[
:first_key,
:second_key
]
.transform
.process

outer_method(
inner.call[0]
.chain
.another
)

matrix[row][col]
.value
.to_s
.upcase
29 changes: 29 additions & 0 deletions fixtures/small/aref_in_call_chain_expected.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
assert_equal(
1,
T.cast(T.must(pages[1]&.elements)[0], Name::Spacing::To::Extend::CodeQuality::AcrossManyLines).table[
:line_items
]
.length
)

foo.bar[some_really_long_index][another_really_long_index]
.baz
.qux

result.data[
:first_key,
:second_key
]
.transform
.process

outer_method(
inner.call[0]
.chain
.another
)

matrix[row][col]
.value
.to_s
.upcase
13 changes: 12 additions & 1 deletion librubyfmt/src/format_prism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3037,7 +3037,18 @@ fn split_node_into_call_chains<'src>(node: prism::Node<'src>) -> Vec<Vec<prism::
let is_aref: bool = !node_is_dot_call;

if is_aref && seen_dot_call && has_dot_after[i] {
split_before.push(i);
let mut split_idx = i;
while split_idx < elements.len() {
if let Some(call_node) = elements[split_idx].as_call_node()
&& call_node.call_operator_loc().is_none()
{
// Still an aref, advance past it
split_idx += 1;
continue;
}
break;
}
split_before.push(split_idx);
seen_dot_call = false;
continue;
}
Expand Down