mirror of
https://github.com/denoland/deno
synced 2024-10-30 02:21:11 +00: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 {
|
||||
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(
|
||||
self.code_actions.as_ref(),
|
||||
data,
|
||||
|
@ -3136,6 +3153,7 @@ impl CompletionEntryDetails {
|
|||
detail,
|
||||
documentation,
|
||||
command,
|
||||
text_edit,
|
||||
additional_text_edits,
|
||||
insert_text,
|
||||
// NOTE(bartlomieju): it's not entirely clear to me why we need to do that,
|
||||
|
|
Loading…
Reference in a new issue