aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/completion.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-04-14 06:30:15 +0000
committerBlaž Hrastnik2021-04-14 06:39:31 +0000
commit3e5f24a9d5cec26697a75e515bff46de418b32da (patch)
treede3cf4a3be699798d3797f5af2d52a1e58227155 /helix-term/src/ui/completion.rs
parent811f952a41177242f7dfa4d66f2b16157f918718 (diff)
lsp: support both utf-8 and utf-16 offsets.
Still need to implement the clangd encoding negotiation, but it's a start. Should also manually override to utf8 for pyls.
Diffstat (limited to 'helix-term/src/ui/completion.rs')
-rw-r--r--helix-term/src/ui/completion.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index a804b5f2..7a8413f8 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -26,7 +26,11 @@ pub struct Completion {
}
impl Completion {
- pub fn new(items: Vec<CompletionItem>, trigger_offset: usize) -> Self {
+ pub fn new(
+ items: Vec<CompletionItem>,
+ offset_encoding: helix_lsp::OffsetEncoding,
+ trigger_offset: usize,
+ ) -> Self {
// let items: Vec<CompletionItem> = Vec::new();
let mut menu = Menu::new(
items,
@@ -99,8 +103,12 @@ impl Completion {
doc.apply(&remove, view.id);
}
- let transaction =
- util::generate_transaction_from_edits(doc.text(), vec![edit]);
+ use helix_lsp::OffsetEncoding;
+ let transaction = util::generate_transaction_from_edits(
+ doc.text(),
+ vec![edit],
+ offset_encoding, // TODO: should probably transcode in Client
+ );
doc.apply(&transaction, view.id);
}
_ => (),