mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
paste: handle vim.paste() failure
- Show error only once per "paste stream". - Drain remaining chunks until phase=3. - Lay groundwork for "cancel". - Constrain semantics of "cancel" to mean "client must stop"; it is unrelated to presence of error(s).
This commit is contained in:
@@ -395,6 +395,11 @@ describe('API', function()
|
||||
eq({0,3,6,0}, funcs.getpos('.'))
|
||||
eq(false, nvim('get_option', 'paste'))
|
||||
end)
|
||||
it('vim.paste() failure', function()
|
||||
nvim('execute_lua', 'vim._paste = (function(lines, phase) error("fake fail") end)', {})
|
||||
expect_err([[Error executing lua: %[string "%<nvim>"]:1: fake fail]],
|
||||
request, 'nvim_paste', 'line 1\nline 2\nline 3', 1)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_put', function()
|
||||
@@ -455,6 +460,25 @@ describe('API', function()
|
||||
eq({0,1,2,0}, funcs.getpos('.'))
|
||||
eq('', nvim('eval', 'v:errmsg'))
|
||||
end)
|
||||
|
||||
it('detects charwise/linewise text (empty {type})', function()
|
||||
-- linewise (final item is empty string)
|
||||
nvim('put', {'line 1','line 2','line 3',''}, '', true, true)
|
||||
expect([[
|
||||
|
||||
line 1
|
||||
line 2
|
||||
line 3]])
|
||||
eq({0,4,1,0}, funcs.getpos('.'))
|
||||
command('%delete _')
|
||||
-- charwise (final item is non-empty)
|
||||
nvim('put', {'line 1','line 2','line 3'}, '', true, true)
|
||||
expect([[
|
||||
line 1
|
||||
line 2
|
||||
line 3]])
|
||||
eq({0,3,6,0}, funcs.getpos('.'))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_strwidth', function()
|
||||
|
||||
Reference in New Issue
Block a user