mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(lsp): apply specifier rewrite to CompletionItem::text_edit (#21564)
This commit is contained in:
parent
fd6044dfec
commit
cd480b481e
1 changed files with 18 additions and 0 deletions
|
@ -3112,6 +3112,23 @@ impl CompletionEntryDetails {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
let mut text_edit = original_item.text_edit.clone();
|
||||||
|
if let Some(specifier_rewrite) = &data.specifier_rewrite {
|
||||||
|
if let Some(text_edit) = &mut text_edit {
|
||||||
|
match text_edit {
|
||||||
|
lsp::CompletionTextEdit::Edit(text_edit) => {
|
||||||
|
text_edit.new_text = text_edit
|
||||||
|
.new_text
|
||||||
|
.replace(&specifier_rewrite.0, &specifier_rewrite.1);
|
||||||
|
}
|
||||||
|
lsp::CompletionTextEdit::InsertAndReplace(insert_replace_edit) => {
|
||||||
|
insert_replace_edit.new_text = insert_replace_edit
|
||||||
|
.new_text
|
||||||
|
.replace(&specifier_rewrite.0, &specifier_rewrite.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
let (command, additional_text_edits) = parse_code_actions(
|
let (command, additional_text_edits) = parse_code_actions(
|
||||||
self.code_actions.as_ref(),
|
self.code_actions.as_ref(),
|
||||||
data,
|
data,
|
||||||
|
@ -3136,6 +3153,7 @@ impl CompletionEntryDetails {
|
||||||
detail,
|
detail,
|
||||||
documentation,
|
documentation,
|
||||||
command,
|
command,
|
||||||
|
text_edit,
|
||||||
additional_text_edits,
|
additional_text_edits,
|
||||||
insert_text,
|
insert_text,
|
||||||
// NOTE(bartlomieju): it's not entirely clear to me why we need to do that,
|
// NOTE(bartlomieju): it's not entirely clear to me why we need to do that,
|
||||||
|
|
Loading…
Add table
Reference in a new issue