aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorPhilipp Mildenberger2023-03-19 23:02:41 +0000
committerPhilipp Mildenberger2023-05-18 19:58:15 +0000
commit1d5d5dab4718b9db40a20037c1cb1edf66f7991a (patch)
treeca5445cd32b50a6ecd44fe2a3604d51872d1a4db /helix-term/src
parent2eeac10755e6b88e3d5861dee7e2016a10c01c9f (diff)
Remove offset_encoding in CompletionItem
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs1
-rw-r--r--helix-term/src/ui/completion.rs31
2 files changed, 24 insertions, 8 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 060c9d83..772db6f8 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -4269,7 +4269,6 @@ pub fn completion(cx: &mut Context) {
.map(|item| CompletionItem {
item,
language_server_id,
- offset_encoding,
resolved: false,
})
.collect();
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index 980bc8b6..e62efdac 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -88,7 +88,6 @@ impl menu::Item for CompletionItem {
pub struct CompletionItem {
pub item: lsp::CompletionItem,
pub language_server_id: usize,
- pub offset_encoding: OffsetEncoding,
pub resolved: bool,
}
@@ -121,6 +120,7 @@ impl Completion {
doc: &Document,
view_id: ViewId,
item: &CompletionItem,
+ offset_encoding: OffsetEncoding,
trigger_offset: usize,
include_placeholder: 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{
return Transaction::new(doc.text());
};
@@ -238,8 +236,21 @@ impl Completion {
// always present here
let item = item.unwrap();
- let transaction =
- item_to_transaction(doc, view.id, item, trigger_offset, true, replace_mode);
+ 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 transaction = item_to_transaction(
+ doc,
+ view.id,
+ item,
+ offset_encoding,
+ trigger_offset,
+ true,
+ replace_mode,
+ );
doc.apply_temporary(&transaction, view.id);
}
PromptEvent::Validate => {
@@ -251,6 +262,12 @@ impl Completion {
// always present here
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
.language_servers
.get_by_id(item.language_server_id)
@@ -270,6 +287,7 @@ impl Completion {
doc,
view.id,
&item,
+ offset_encoding,
trigger_offset,
false,
replace_mode,
@@ -287,7 +305,7 @@ impl Completion {
let transaction = util::generate_transaction_from_edits(
doc.text(),
additional_edits,
- item.offset_encoding, // TODO: should probably transcode in Client
+ offset_encoding, // TODO: should probably transcode in Client
);
doc.apply(&transaction, view.id);
}
@@ -414,7 +432,6 @@ impl Completion {
let resolved_item = CompletionItem {
item: resolved_item,
language_server_id: current_item.language_server_id,
- offset_encoding: current_item.offset_encoding,
resolved: true,
};