From 3e5f24a9d5cec26697a75e515bff46de418b32da Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 14 Apr 2021 15:30:15 +0900 Subject: 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. --- helix-view/src/document.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'helix-view') diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 8e836f03..a04600b6 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -406,7 +406,7 @@ mod test { #[test] fn changeset_to_changes() { - use helix_lsp::{lsp, Client}; + use helix_lsp::{lsp, Client, OffsetEncoding}; let text = Rope::from("hello"); let mut doc = Document::new(text); let view = ViewId::default(); @@ -417,7 +417,12 @@ mod test { let transaction = Transaction::insert(doc.text(), doc.selection(view), " world".into()); let old_doc = doc.text().clone(); doc.apply(&transaction, view); - let changes = Client::changeset_to_changes(&old_doc, doc.text(), transaction.changes()); + let changes = Client::changeset_to_changes( + &old_doc, + doc.text(), + transaction.changes(), + OffsetEncoding::Utf8, + ); assert_eq!( changes, @@ -436,7 +441,12 @@ mod test { let transaction = transaction.invert(&old_doc); let old_doc = doc.text().clone(); doc.apply(&transaction, view); - let changes = Client::changeset_to_changes(&old_doc, doc.text(), transaction.changes()); + let changes = Client::changeset_to_changes( + &old_doc, + doc.text(), + transaction.changes(), + OffsetEncoding::Utf8, + ); // line: 0-based. // col: 0-based, gaps between chars. @@ -468,7 +478,12 @@ mod test { // aeilou let old_doc = doc.text().clone(); doc.apply(&transaction, view); - let changes = Client::changeset_to_changes(&old_doc, doc.text(), transaction.changes()); + let changes = Client::changeset_to_changes( + &old_doc, + doc.text(), + transaction.changes(), + OffsetEncoding::Utf8, + ); assert_eq!( changes, -- cgit v1.2.3-70-g09d2