diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-03-27 19:02:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-27 19:02:48 -0700 |
commit | b79596eb5e942a299aa021a0f9a3f2db909294da (patch) | |
tree | f1ce583af85097949860c343ccefe86846703fdb | |
parent | 2b663c061b8a1fa173ff23901734356bc96758bd (diff) | |
parent | af683fdb570bc74a2b5b38bf5787ec55c1d6d9eb (diff) | |
download | rneovim-b79596eb5e942a299aa021a0f9a3f2db909294da.tar.gz rneovim-b79596eb5e942a299aa021a0f9a3f2db909294da.tar.bz2 rneovim-b79596eb5e942a299aa021a0f9a3f2db909294da.zip |
Merge pull request #14231 from mjlbach/fix_utf16_ranges
lsp: fix utf16 ranges for incremental sync
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index a75ab37508..942c6761c4 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -373,9 +373,12 @@ function M.compute_diff(old_lines, new_lines, start_line_idx, end_line_idx) adj_end_char = #old_lines[#old_lines + end_line + 1] + end_char + 1 end + start_char = vim.str_utfindex(old_lines[start_line], start_char - 1) + adj_end_char = vim.str_utfindex(old_lines[#old_lines + end_line + 1], adj_end_char) + local result = { range = { - start = { line = start_line - 1, character = start_char - 1}, + start = { line = start_line - 1, character = start_char}, ["end"] = { line = adj_end_line, character = adj_end_char} }, text = text, |