diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2022-08-07 16:01:34 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2022-08-07 16:01:34 -0600 |
commit | a5f27a311fb28797a72b8aa16ec7122c5a1b15e4 (patch) | |
tree | 3732f7339e29431f31310aef6ffc802cf4f6255d /test/functional/api | |
parent | 6c909fedc924d9f4257aa204b0168c6177cc5d28 (diff) | |
parent | 629169462a82f0fbb7a8911a4554894537d6776c (diff) | |
download | rneovim-a5f27a311fb28797a72b8aa16ec7122c5a1b15e4.tar.gz rneovim-a5f27a311fb28797a72b8aa16ec7122c5a1b15e4.tar.bz2 rneovim-a5f27a311fb28797a72b8aa16ec7122c5a1b15e4.zip |
Merge branch 'master' of https://github.com/neovim/neovim into rahm
Diffstat (limited to 'test/functional/api')
-rw-r--r-- | test/functional/api/buffer_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/api/keymap_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 7 |
3 files changed, 22 insertions, 3 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index dc668e7201..8f6fc666c9 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -7,6 +7,7 @@ local meths = helpers.meths local funcs = helpers.funcs local request = helpers.request local exc_exec = helpers.exc_exec +local exec_lua = helpers.exec_lua local feed_command = helpers.feed_command local insert = helpers.insert local NIL = helpers.NIL @@ -565,6 +566,17 @@ describe('api/buf', function() eq('start is higher than end', pcall_err(set_text, 1, 0, 0, 0, {})) eq('start is higher than end', pcall_err(set_text, 0, 1, 0, 0, {})) end) + + it('no heap-use-after-free when called consecutively #19643', function() + set_text(0, 0, 0, 0, {'one', '', '', 'two'}) + eq({'one', '', '', 'two'}, get_lines(0, 4, true)) + meths.win_set_cursor(0, {1, 0}) + exec_lua([[ + vim.api.nvim_buf_set_text(0, 0, 3, 1, 0, {''}) + vim.api.nvim_buf_set_text(0, 0, 3, 1, 0, {''}) + ]]) + eq({'one', 'two'}, get_lines(0, 2, true)) + end) end) describe('nvim_buf_get_text', function() diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index eb2a467a8b..a93a4544ff 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -822,7 +822,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() print('jkl;') end }) ]] assert.truthy(string.match(exec_lua[[return vim.api.nvim_exec(':nmap asdf', true)]], - "^\nn asdf <Lua function %d+>")) + "^\nn asdf <Lua %d+>")) end) it ('mapcheck() returns lua mapping correctly', function() @@ -830,7 +830,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() print('jkl;') end }) ]] assert.truthy(string.match(funcs.mapcheck('asdf', 'n'), - "^<Lua function %d+>")) + "^<Lua %d+>")) end) it ('maparg() returns lua mapping correctly', function() @@ -838,7 +838,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() print('jkl;') end }) ]] assert.truthy(string.match(funcs.maparg('asdf', 'n'), - "^<Lua function %d+>")) + "^<Lua %d+>")) local mapargs = funcs.maparg('asdf', 'n', false, true) assert(type(mapargs.callback) == 'number', 'callback is not luaref number') mapargs.callback = nil diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 17de6730fb..fe623ff824 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3822,5 +3822,12 @@ describe('API', function() feed("[l") neq(nil, string.find(eval("v:errmsg"), "E5108:")) end) + it('handles 0 range #19608', function() + meths.buf_set_lines(0, 0, -1, false, { "aa" }) + meths.cmd({ cmd = 'delete', range = { 0 } }, {}) + command('undo') + eq({'aa'}, meths.buf_get_lines(0, 0, 1, false)) + assert_alive() + end) end) end) |