···78337833 ) {
78347834 let pipeline_range = self.edits.src_span_to_lsp_range(*location);
78357835 if within(self.params.range, pipeline_range) {
78367836- // We will always desugar the pipeline's first step. If there's no
78377837- // intermediate assignment it means we're dealing with a single step
78387838- // pipeline and the call is `finally`.
78397839- let (call, call_kind) = assignments
78407840- .first()
78367836+ // Add final assignment to the list
78377837+ let all_assignments = assignments
78387838+ .iter()
78417839 .map(|(call, kind)| (call.location, *kind))
78427842- .unwrap_or_else(|| (finally.location(), *finally_kind));
78407840+ .chain(iter::once((finally.location(), *finally_kind)));
78417841+ let mut call_information = None;
78427842+ // Span, containing content that will be extracted as call argument
78437843+ let mut accumulated_span = first_value.location;
78447844+78457845+ for (current_location, current_kind) in all_assignments {
78467846+ if within(
78477847+ self.params.range,
78487848+ self.edits.src_span_to_lsp_range(current_location),
78497849+ ) {
78507850+ call_information = Some((accumulated_span, current_location, current_kind));
78517851+ break;
78527852+ }
78537853+ accumulated_span = accumulated_span.merge(¤t_location);
78547854+ }
78557855+78567856+ let (final_prev, final_call, final_kind) = match call_information {
78577857+ Some(triple) => triple,
78587858+78597859+ // Here two situations are possible:
78607860+ // - If the cursor is not on any of the assignments (for example, it is on first value), then we need
78617861+ // to use that first value as accumulated location, and the first call location and kind
78627862+ // - If there are no assignments, then we are dealing with a single
78637863+ // step pipeline and the call is `finally`
78647864+ None => {
78657865+ let (call, call_kind) = &assignments
78667866+ .first()
78677867+ .map(|(call, call_kind)| (call.location, *call_kind))
78687868+ .unwrap_or_else(|| (finally.location(), *finally_kind));
78697869+ (first_value.location, *call, *call_kind)
78707870+ }
78717871+ };
7843787278447873 self.locations = Some(ConvertToFunctionCallLocations {
78457845- first_value: first_value.location,
78467846- call,
78477847- call_kind,
78747874+ first_value: final_prev,
78757875+ call: final_call,
78767876+ call_kind: final_kind,
78487877 });
7849787878507879 ast::visit::visit_typed_expr_pipeline(