From 179f0bca1890637f47e76c8acfd33040a6b7d515 Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Fri, 18 Sep 2020 08:44:32 +0200 Subject: buf_updates: fix wrong updates on linewise change --- test/functional/lua/buffer_updates_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/functional/lua') diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index ac5d25bdab..6b62768470 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -289,6 +289,12 @@ describe('lua: nvim_buf_attach on_bytes', function() if verify then for _, event in ipairs(events) do + for _, elem in ipairs(event) do + if type(elem) == "number" and elem < 0 then + fail(string.format("Received event has negative values")) + end + end + if event[1] == verify_name and event[2] == "bytes" then local _, _, _, _, _, _, start_byte, _, _, old_byte, _, _, new_byte = unpack(event) local before = string.sub(shadowbytes, 1, start_byte) @@ -411,6 +417,24 @@ describe('lua: nvim_buf_attach on_bytes', function() { "test1", "bytes", 1, 3, 0, 0, 0, 0, 0, 0, 0, 1, 1 }; } end) + + it("changing lines", function() + local check_events = setup_eventcheck(verify, origlines) + + feed "cc" + check_events { + { "test1", "bytes", 1, 4, 1, 0, 1, 0, 15, 15, 0, 0, 0 }; + } + + feed "" + check_events {} + + feed "c3j" + check_events { + { "test1", "bytes", 1, 4, 1, 0, 1, 3, 0, 48, 0, 0, 0 }; + { "test1", "bytes", 1, 5, 0, 0, 0, 4, 0, 0, 4, 0, 51 }; + } + end) end describe('(with verify) handles', function() -- cgit