From e5d9b15044d56acd48569b3ca7ac9dabdeaa750e Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 25 Dec 2023 13:06:00 +0100 Subject: fix(buffer_updates): correct buffer updates when splitting empty line fixes #11591 --- test/functional/api/buffer_updates_spec.lua | 10 ++++++++++ test/functional/lua/buffer_updates_spec.lua | 9 +++++++++ 2 files changed, 19 insertions(+) (limited to 'test/functional') diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index b0efcf0dab..8e43d28322 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -349,6 +349,16 @@ describe('API: buffer events:', function() expectn('nvim_buf_lines_event', { b, tick, 3, 4, {}, false }) end) + it('visual paste split empty line', function() + local b, tick = editoriginal(true, { 'abc', '{', 'def', '}' }) + command('normal! ggyyjjvi{p') + expectn('nvim_buf_lines_event', { b, tick + 1, 2, 3, { '' }, false }) + expectn('nvim_buf_lines_event', { b, tick + 2, 2, 3, { '}' }, false }) + expectn('nvim_buf_lines_event', { b, tick + 3, 3, 4, {}, false }) + expectn('nvim_buf_lines_event', { b, tick + 3, 2, 3, { '' }, false }) + expectn('nvim_buf_lines_event', { b, tick + 4, 3, 3, { 'abc', '}' }, false }) + end) + it('when lines are filtered', function() -- Test filtering lines with !cat local b, tick = editoriginal(true, { 'A', 'C', 'E', 'B', 'D', 'F' }) diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 073ac40ef1..447c1ee345 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -1073,6 +1073,15 @@ describe('lua: nvim_buf_attach on_bytes', function() } end) + it('visual paste 2: splitting an empty line', function() + local check_events = setup_eventcheck(verify, { 'abc', '{', 'def', '}' }) + feed('ggyyjjvi{p') + check_events { + { 'test1', 'bytes', 1, 6, 2, 0, 6, 1, 0, 4, 0, 0, 0 }, + { 'test1', 'bytes', 1, 6, 2, 0, 6, 0, 0, 0, 2, 0, 5 }, + } + end) + it('nvim_buf_set_lines', function() local check_events = setup_eventcheck(verify, { 'AAA', 'BBB' }) -- cgit