diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-11-15 08:51:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-15 08:51:30 -0800 |
commit | 87a053f126c79f5eeb1654e35beb31d9fe733163 (patch) | |
tree | bdfbe6fbbd03f391561b7e9884b376fd606e04ec /runtime/lua/vim/lsp/sync.lua | |
parent | 8f984dc1f29aa6ce41f233b983453bfd795e8238 (diff) | |
download | rneovim-87a053f126c79f5eeb1654e35beb31d9fe733163.tar.gz rneovim-87a053f126c79f5eeb1654e35beb31d9fe733163.tar.bz2 rneovim-87a053f126c79f5eeb1654e35beb31d9fe733163.zip |
fix(lsp): fix edge cases in incremental sync (#16308)
Diffstat (limited to 'runtime/lua/vim/lsp/sync.lua')
-rw-r--r-- | runtime/lua/vim/lsp/sync.lua | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/sync.lua b/runtime/lua/vim/lsp/sync.lua index 37247c61b9..585c14a00f 100644 --- a/runtime/lua/vim/lsp/sync.lua +++ b/runtime/lua/vim/lsp/sync.lua @@ -219,6 +219,10 @@ local function compute_end_range(prev_lines, curr_lines, start_range, firstline, -- Iterate from end to beginning of shortest line local prev_end_byte_idx = prev_line_length - byte_offset + 1 + -- Handle case where lines match + if prev_end_byte_idx == 0 then + prev_end_byte_idx = 1 + end local prev_byte_idx, prev_char_idx = align_position(prev_line, prev_end_byte_idx, 'start', offset_encoding) local prev_end_range = { line_idx = prev_line_idx, byte_idx = prev_byte_idx, char_idx = prev_char_idx } @@ -228,6 +232,10 @@ local function compute_end_range(prev_lines, curr_lines, start_range, firstline, curr_end_range = { line_idx = start_line_idx, byte_idx = 1, char_idx = 1 } else local curr_end_byte_idx = curr_line_length - byte_offset + 1 + -- Handle case where lines match + if curr_end_byte_idx == 0 then + curr_end_byte_idx = 1 + end local curr_byte_idx, curr_char_idx = align_position(curr_line, curr_end_byte_idx, 'start', offset_encoding) curr_end_range = { line_idx = curr_line_idx, byte_idx = curr_byte_idx, char_idx = curr_char_idx } end |