paste: abort paste if handler does not return true

This commit is contained in:
Justin M. Keyes
2019-08-19 00:41:58 +02:00
parent 68ea9a7c8a
commit 4389401a7c
2 changed files with 3 additions and 4 deletions

View File

@@ -109,7 +109,7 @@ local function _paste(data)
-- TODO: do not redraw (slow!) until paste is finished.
-- if eof then
vim.api.nvim_command('redraw')
return 0
return true -- Paste will not continue if not returning `true`.
end
-- TODO(ZyX-I): Create compatibility layer.

View File

@@ -133,9 +133,8 @@ static void tinput_wait_enqueue(void **argv)
Object fret
= nvim_execute_lua(STATIC_CSTR_AS_STRING("return vim._paste(...)"),
args, &err);
if ((fret.type == kObjectTypeInteger && fret.data.integer)
|| (fret.type == kObjectTypeBoolean && fret.data.boolean)
|| (fret.type == kObjectTypeString && fret.data.string.size)) {
if (fret.type != kObjectTypeBoolean || !fret.data.boolean) {
// Abort paste if handler does not return true.
input->paste_enabled = false;
}
api_free_object(fret);