Skip to content

Commit 1588924

Browse files
authored
[prism] Match Ripper's multilining logic for call chains beginning with literal expressions (#766)
1 parent 02fb154 commit 1588924

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
CommonFields::OBVIOUSLY,
3+
CommonFields::THESE,
4+
CommonFields::ARE,
5+
CommonFields::FAKE_RESOURCE.with_wombo(true).with_combo(true).with_explosion(true)
6+
]
7+
.map do |field|
8+
# Swap things out, to make sure.
9+
override || field
10+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
CommonFields::OBVIOUSLY,
3+
CommonFields::THESE,
4+
CommonFields::ARE,
5+
CommonFields::FAKE_RESOURCE.with_wombo(true).with_combo(true).with_explosion(true)
6+
]
7+
.map do |field|
8+
# Swap things out, to make sure.
9+
override || field
10+
end

librubyfmt/src/format_prism.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,7 @@ fn call_chain_elements_are_user_multilined<'src>(
23402340
// placement, the user probably intended to break this onto multiple lines anyways.
23412341
let has_comment = ps.has_comment_in_offset_span(
23422342
call_chain_elements[0].location().end_offset(),
2343-
start_loc_for_call_node_in_chain(&call_chain_elements[1].as_call_node().unwrap()),
2343+
call_chain_elements.last().unwrap().location().end_offset(),
23442344
);
23452345
if is_literal_expression && !has_comment {
23462346
call_chain_elements = &call_chain_elements[1..];

0 commit comments

Comments
 (0)