|
|
@ -88,7 +88,6 @@ impl menu::Item for CompletionItem {
|
|
|
|
pub struct CompletionItem {
|
|
|
|
pub struct CompletionItem {
|
|
|
|
pub item: lsp::CompletionItem,
|
|
|
|
pub item: lsp::CompletionItem,
|
|
|
|
pub language_server_id: usize,
|
|
|
|
pub language_server_id: usize,
|
|
|
|
pub offset_encoding: OffsetEncoding,
|
|
|
|
|
|
|
|
pub resolved: bool,
|
|
|
|
pub resolved: bool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -121,6 +120,7 @@ impl Completion {
|
|
|
|
doc: &Document,
|
|
|
|
doc: &Document,
|
|
|
|
view_id: ViewId,
|
|
|
|
view_id: ViewId,
|
|
|
|
item: &CompletionItem,
|
|
|
|
item: &CompletionItem,
|
|
|
|
|
|
|
|
offset_encoding: OffsetEncoding,
|
|
|
|
trigger_offset: usize,
|
|
|
|
trigger_offset: usize,
|
|
|
|
include_placeholder: bool,
|
|
|
|
include_placeholder: bool,
|
|
|
|
replace_mode: bool,
|
|
|
|
replace_mode: bool,
|
|
|
@ -143,8 +143,6 @@ impl Completion {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let offset_encoding = item.offset_encoding;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let Some(range) = util::lsp_range_to_range(doc.text(), edit.range, offset_encoding) else{
|
|
|
|
let Some(range) = util::lsp_range_to_range(doc.text(), edit.range, offset_encoding) else{
|
|
|
|
return Transaction::new(doc.text());
|
|
|
|
return Transaction::new(doc.text());
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -238,8 +236,21 @@ impl Completion {
|
|
|
|
// always present here
|
|
|
|
// always present here
|
|
|
|
let item = item.unwrap();
|
|
|
|
let item = item.unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let transaction =
|
|
|
|
let offset_encoding = editor
|
|
|
|
item_to_transaction(doc, view.id, item, trigger_offset, true, replace_mode);
|
|
|
|
.language_servers
|
|
|
|
|
|
|
|
.get_by_id(item.language_server_id)
|
|
|
|
|
|
|
|
.expect("language server disappeared between completion request and application")
|
|
|
|
|
|
|
|
.offset_encoding();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let transaction = item_to_transaction(
|
|
|
|
|
|
|
|
doc,
|
|
|
|
|
|
|
|
view.id,
|
|
|
|
|
|
|
|
item,
|
|
|
|
|
|
|
|
offset_encoding,
|
|
|
|
|
|
|
|
trigger_offset,
|
|
|
|
|
|
|
|
true,
|
|
|
|
|
|
|
|
replace_mode,
|
|
|
|
|
|
|
|
);
|
|
|
|
doc.apply_temporary(&transaction, view.id);
|
|
|
|
doc.apply_temporary(&transaction, view.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PromptEvent::Validate => {
|
|
|
|
PromptEvent::Validate => {
|
|
|
@ -251,6 +262,12 @@ impl Completion {
|
|
|
|
// always present here
|
|
|
|
// always present here
|
|
|
|
let mut item = item.unwrap().clone();
|
|
|
|
let mut item = item.unwrap().clone();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let offset_encoding = editor
|
|
|
|
|
|
|
|
.language_servers
|
|
|
|
|
|
|
|
.get_by_id(item.language_server_id)
|
|
|
|
|
|
|
|
.expect("language server disappeared between completion request and application")
|
|
|
|
|
|
|
|
.offset_encoding();
|
|
|
|
|
|
|
|
|
|
|
|
let language_server = editor
|
|
|
|
let language_server = editor
|
|
|
|
.language_servers
|
|
|
|
.language_servers
|
|
|
|
.get_by_id(item.language_server_id)
|
|
|
|
.get_by_id(item.language_server_id)
|
|
|
@ -270,6 +287,7 @@ impl Completion {
|
|
|
|
doc,
|
|
|
|
doc,
|
|
|
|
view.id,
|
|
|
|
view.id,
|
|
|
|
&item,
|
|
|
|
&item,
|
|
|
|
|
|
|
|
offset_encoding,
|
|
|
|
trigger_offset,
|
|
|
|
trigger_offset,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
replace_mode,
|
|
|
|
replace_mode,
|
|
|
@ -287,7 +305,7 @@ impl Completion {
|
|
|
|
let transaction = util::generate_transaction_from_edits(
|
|
|
|
let transaction = util::generate_transaction_from_edits(
|
|
|
|
doc.text(),
|
|
|
|
doc.text(),
|
|
|
|
additional_edits,
|
|
|
|
additional_edits,
|
|
|
|
item.offset_encoding, // TODO: should probably transcode in Client
|
|
|
|
offset_encoding, // TODO: should probably transcode in Client
|
|
|
|
);
|
|
|
|
);
|
|
|
|
doc.apply(&transaction, view.id);
|
|
|
|
doc.apply(&transaction, view.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -414,7 +432,6 @@ impl Completion {
|
|
|
|
let resolved_item = CompletionItem {
|
|
|
|
let resolved_item = CompletionItem {
|
|
|
|
item: resolved_item,
|
|
|
|
item: resolved_item,
|
|
|
|
language_server_id: current_item.language_server_id,
|
|
|
|
language_server_id: current_item.language_server_id,
|
|
|
|
offset_encoding: current_item.offset_encoding,
|
|
|
|
|
|
|
|
resolved: true,
|
|
|
|
resolved: true,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|