Fix logic for updating insert_range
on completion resolution (#32523)
I don't have a concrete misbehavior from it, but this update of `insert_range` doesn't make sense for two reasons: * If the resolved completion doesn't have a new `text_edit` it would clear out the `insert_range`. * It doesn't update the completion if it has already been resolved, except this update of `insert_range` happened before that. Guessing it was written this way because this field needed to only be mutated within the `CompletionSource::Lsp` case and this was a convenient match below. Release Notes: - N/A Co-authored-by: Smit <smit@zed.dev>
This commit is contained in:
parent
e5ad2c2518
commit
7f44e4b89c
1 changed files with 3 additions and 5 deletions
|
@ -5545,7 +5545,6 @@ impl LspStore {
|
|||
.into_response()
|
||||
.context("resolve completion")?;
|
||||
|
||||
let mut updated_insert_range = None;
|
||||
if let Some(text_edit) = resolved_completion.text_edit.as_ref() {
|
||||
// Technically we don't have to parse the whole `text_edit`, since the only
|
||||
// language server we currently use that does update `text_edit` in `completionItem/resolve`
|
||||
|
@ -5561,22 +5560,21 @@ impl LspStore {
|
|||
|
||||
completion.new_text = parsed_edit.new_text;
|
||||
completion.replace_range = parsed_edit.replace_range;
|
||||
|
||||
updated_insert_range = parsed_edit.insert_range;
|
||||
if let CompletionSource::Lsp { insert_range, .. } = &mut completion.source {
|
||||
*insert_range = parsed_edit.insert_range;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut completions = completions.borrow_mut();
|
||||
let completion = &mut completions[completion_index];
|
||||
if let CompletionSource::Lsp {
|
||||
insert_range,
|
||||
lsp_completion,
|
||||
resolved,
|
||||
server_id: completion_server_id,
|
||||
..
|
||||
} = &mut completion.source
|
||||
{
|
||||
*insert_range = updated_insert_range;
|
||||
if *resolved {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue