Trigger VSCode to rename after extract variable assist is applied

When the user applies the "Extract Variable" assist, the cursor is
positioned at the newly inserted variable. This commit adds a command
to the assist that triggers the rename action in VSCode. This way, the
user can quickly rename the variable after applying the assist.

Fixes part of: #17579
This commit is contained in:
bors 2024-07-11 08:55:34 +00:00 committed by Josh McKinney
parent 5577e4e3b1
commit 8efe8a8528
No known key found for this signature in database
GPG key ID: 722287396A903BC5
17 changed files with 80 additions and 33 deletions

View file

@ -98,7 +98,7 @@ fn quickfix_for_redundant_assoc_item(
group: None,
target: range,
source_change: Some(source_change_builder.finish()),
trigger_signature_help: false,
command: None,
}])
}

View file

@ -82,7 +82,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::TypedHole) -> Option<Vec<Assist>
original_range.file_id,
TextEdit::replace(original_range.range, code),
)),
trigger_signature_help: false,
command: None,
})
.collect();

View file

@ -130,7 +130,7 @@ fn add_variant_to_union(
group: None,
target: error_range.range,
source_change: Some(src_change_builder.finish()),
trigger_signature_help: false,
command: None,
})
}
@ -173,7 +173,7 @@ fn add_field_to_struct_fix(
group: None,
target: error_range.range,
source_change: Some(src_change_builder.finish()),
trigger_signature_help: false,
command: None,
})
}
None => {
@ -204,7 +204,7 @@ fn add_field_to_struct_fix(
group: None,
target: error_range.range,
source_change: Some(src_change_builder.finish()),
trigger_signature_help: false,
command: None,
})
}
Some(FieldList::TupleFieldList(_tuple)) => {
@ -266,7 +266,7 @@ fn method_fix(
file_id,
TextEdit::insert(range.end(), "()".to_owned()),
)),
trigger_signature_help: false,
command: None,
})
}
#[cfg(test)]

View file

@ -108,7 +108,7 @@ fn field_fix(
(file_id, TextEdit::insert(range.start(), "(".to_owned())),
(file_id, TextEdit::insert(range.end(), ")".to_owned())),
])),
trigger_signature_help: false,
command: None,
})
}
@ -191,7 +191,7 @@ fn assoc_func_fix(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedMethodCall) -
file_id,
TextEdit::replace(range, assoc_func_call_expr_string),
)),
trigger_signature_help: false,
command: None,
})
} else {
None

View file

@ -73,7 +73,7 @@ fn fixes(
diagnostic_range.file_id,
TextEdit::replace(name_range, format!("_{}", var_name.display(db))),
)),
trigger_signature_help: false,
command: None,
}])
}

View file

@ -613,7 +613,7 @@ fn unresolved_fix(id: &'static str, label: &str, target: TextRange) -> Assist {
group: None,
target,
source_change: None,
trigger_signature_help: false,
command: None,
}
}