Implement utf8 offsets

This commit is contained in:
Aleksey Kladov
2021-02-13 00:55:27 +03:00
parent 0025836f26
commit c8b9ec8e62
5 changed files with 45 additions and 15 deletions

View File

@@ -7,7 +7,7 @@ use lsp_server::Notification;
use crate::{
from_proto,
global_state::GlobalState,
line_endings::{LineEndings, LineIndex},
line_endings::{LineEndings, LineIndex, OffsetEncoding},
};
pub(crate) fn is_canceled(e: &(dyn Error + 'static)) -> bool {
@@ -95,8 +95,9 @@ pub(crate) fn apply_document_changes(
) {
let mut line_index = LineIndex {
index: Arc::new(ide::LineIndex::new(old_text)),
// We don't care about line endings here.
// We don't care about line endings or offset encoding here.
endings: LineEndings::Unix,
encoding: OffsetEncoding::Utf16,
};
// The changes we got must be applied sequentially, but can cross lines so we