diff options
author | Jean Pierre <jeanp413@hotmail.com> | 2021-04-19 20:26:36 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-20 11:26:36 +1000 |
commit | 6d404ec54bab00d9f86c8d69a70dd94e5ab83434 (patch) | |
tree | 5c1d99cc17da1134b9fb728ff8e9689e00a1694c /cli/lsp/text.rs | |
parent | b6203cb4657f8269bf80b135b3c49fb9304895c1 (diff) |
feat(lsp): Implement textDocument/semanticTokens/full (#10233)
Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
Diffstat (limited to 'cli/lsp/text.rs')
-rw-r--r-- | cli/lsp/text.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cli/lsp/text.rs b/cli/lsp/text.rs index 262b27c49..fedeabd06 100644 --- a/cli/lsp/text.rs +++ b/cli/lsp/text.rs @@ -20,7 +20,7 @@ where P: FnMut(&T) -> bool, { let mut left = 0; - let mut right = slice.len(); + let mut right = slice.len() - 1; while left != right { let mid = left + (right - left) / 2; @@ -31,7 +31,7 @@ where // In both cases left <= right is satisfied. // Therefore if left < right in a step, // left <= right is satisfied in the next step. - // Therefore as long as left != right, 0 <= left < right <= len is satisfied + // Therefore as long as left != right, 0 <= left < right < len is satisfied // and if this case 0 <= mid < len is satisfied too. let value = unsafe { slice.get_unchecked(mid) }; if predicate(value) { @@ -109,6 +109,10 @@ impl LineIndex { curr_col += c_len; } + // utf8_offsets and utf16_offsets length is equal to (# of lines + 1) + utf8_offsets.push(curr_row); + utf16_offsets.push(curr_offset_u16); + if !utf16_chars.is_empty() { utf16_lines.insert(line, utf16_chars); } @@ -185,6 +189,10 @@ impl LineIndex { } } + pub fn text_content_length_utf16(&self) -> TextSize { + *self.utf16_offsets.last().unwrap() + } + fn utf16_to_utf8_col(&self, line: u32, mut col: u32) -> TextSize { if let Some(utf16_chars) = self.utf16_lines.get(&line) { for c in utf16_chars { |