Skip to content

Commit

Permalink
Fix precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
reese authored Aug 18, 2023
1 parent 9a39f02 commit 00da814
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions librubyfmt/src/render_targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,21 @@ impl AbstractTokenTarget for BreakableCallChainEntry {
}
}

let all_element_locations = call_chain_to_check
.iter()
.filter_map(|cc_elem| cc_elem.start_line())
.collect::<Vec<u64>>();

// Multiline the chain if all the call chain elements are not on the same line
if let Some(first_op_start_end) = all_element_locations.first() {
let chain_is_user_multilined = !all_element_locations
.iter()
.all(|op_start_end| op_start_end == first_op_start_end);
if chain_is_user_multilined {
return true;
}
}

// Ignore chains that are basically only method calls, e.g.
// ````ruby
// Thing.foo(args)
Expand All @@ -363,21 +378,6 @@ impl AbstractTokenTarget for BreakableCallChainEntry {
_ => {}
}

let all_element_locations = call_chain_to_check
.iter()
.filter_map(|cc_elem| cc_elem.start_line())
.collect::<Vec<u64>>();

// Multiline the chain if all the call chain elements are not on the same line
if let Some(first_op_start_end) = all_element_locations.first() {
let chain_is_user_multilined = !all_element_locations
.iter()
.all(|op_start_end| op_start_end == first_op_start_end);
if chain_is_user_multilined {
return true;
}
}

let chain_blocks_are_multilined = call_chain_to_check
.iter()
.filter_map(|elem| match elem {
Expand Down

0 comments on commit 00da814

Please sign in to comment.