diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-09-16 16:34:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-16 16:34:24 +0200 |
commit | aa98527ce7efc1b4fd38e1d17c6f455239f39f21 (patch) | |
tree | b71cf4cacbe2b87b52f5e3fa3dd097f03e22e5f6 /test/functional/lua/buffer_updates_spec.lua | |
parent | cf522488cca72b0dd6f19f0c0c3c007b8d118c3f (diff) | |
parent | 34c0f7af04bb96fb97949165c23a988f1957fcd9 (diff) | |
download | rneovim-aa98527ce7efc1b4fd38e1d17c6f455239f39f21.tar.gz rneovim-aa98527ce7efc1b4fd38e1d17c6f455239f39f21.tar.bz2 rneovim-aa98527ce7efc1b4fd38e1d17c6f455239f39f21.zip |
Merge pull request #12917 from bfredl/bytes_setline
buf_attach: fix buffer updates with setline()
Diffstat (limited to 'test/functional/lua/buffer_updates_spec.lua')
-rw-r--r-- | test/functional/lua/buffer_updates_spec.lua | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 5be47070a7..cc5db2a355 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -5,6 +5,7 @@ local inspect = require'vim.inspect' local command = helpers.command local meths = helpers.meths +local funcs = helpers.funcs local clear = helpers.clear local eq = helpers.eq local fail = helpers.fail @@ -273,7 +274,7 @@ describe('lua: nvim_buf_attach on_bytes', function() local events = exec_lua("return get_events(...)" ) if not pcall(eq, expected, events) then - local msg = 'unexpected byte updates received.\n\nBABBLA MER \n\n' + local msg = 'unexpected byte updates received.\n\n' msg = msg .. 'received events:\n' for _, e in ipairs(events) do @@ -300,7 +301,7 @@ describe('lua: nvim_buf_attach on_bytes', function() end local text = meths.buf_get_lines(0, 0, -1, true) local bytes = table.concat(text, '\n') .. '\n' - eq(string.len(bytes), string.len(shadowbytes), shadowbytes) + eq(string.len(bytes), string.len(shadowbytes), '\non_bytes: total bytecount of buffer is wrong') for i = 1, string.len(shadowbytes) do local shadowbyte = string.sub(shadowbytes, i, i) if shadowbyte ~= '\255' then @@ -355,6 +356,26 @@ describe('lua: nvim_buf_attach on_bytes', function() { "test1", "bytes", 1, 5, 7, 4, 118, 0, 0, 0, 1, 4, 5 }; } end) + + it('setline(num, line)', function() + local check_events = setup_eventcheck(verify) + funcs.setline(2, "babla") + check_events { + { "test1", "bytes", 1, 3, 1, 0, 16, 0, 15, 15, 0, 5, 5 }; + } + + funcs.setline(2, {"foo", "bar"}) + check_events { + { "test1", "bytes", 1, 4, 1, 0, 16, 0, 5, 5, 0, 3, 3 }; + { "test1", "bytes", 1, 5, 2, 0, 20, 0, 15, 15, 0, 3, 3 }; + } + + local buf_len = meths.buf_line_count(0) + funcs.setline(buf_len + 1, "baz") + check_events { + { "test1", "bytes", 1, 6, 7, 0, 90, 0, 0, 0, 1, 0, 4 }; + } + end) end describe('(with verify) handles', function() |