From b141ca5a2ab6354b5c64f2ce9cc593675a7d1b64 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 9 Sep 2024 02:49:49 +0200 Subject: [PATCH] fix: catch out-of-bounds line deletion sending --- lua/codemp/buffers.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/codemp/buffers.lua b/lua/codemp/buffers.lua index 601c89d..ce372be 100644 --- a/lua/codemp/buffers.lua +++ b/lua/codemp/buffers.lua @@ -46,6 +46,10 @@ local function attach(name, buffer, content, nowait) change_content = "" else local actual_end_row = start_row + new_end_row + if new_byte_len == old_end_byte_len - 1 and new_end_row == old_end_row - 1 then + -- if just 1 byte changes and the line count changes, we deleted a line but getting text would mean going out of bounds + actual_end_row = actual_end_row - 1 + end local actual_end_col = new_end_col if new_end_row == 0 then actual_end_col = new_end_col + start_col end change_content = table.concat(