diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-08-26 20:57:57 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-08-27 22:13:45 +0200 |
commit | ed60015266356b3c0c42aa34698d9287f22fcba1 (patch) | |
tree | c1ae9ec1da22f94bce1157cd42a74112c2849746 /src/nvim/tui/input.c | |
parent | 4344ac11119abd20ba911d72cf540321277dd150 (diff) | |
download | rneovim-ed60015266356b3c0c42aa34698d9287f22fcba1.tar.gz rneovim-ed60015266356b3c0c42aa34698d9287f22fcba1.tar.bz2 rneovim-ed60015266356b3c0c42aa34698d9287f22fcba1.zip |
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).
Diffstat (limited to 'src/nvim/tui/input.c')
-rw-r--r-- | src/nvim/tui/input.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index f9f39c36ff..c74ef58ba1 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -107,13 +107,12 @@ static void tinput_wait_enqueue(void **argv) const String keys = { .data = buf, .size = len }; if (input->paste) { Error err = ERROR_INIT; - Boolean rv = nvim_paste(keys, input->paste, &err); - // Paste phase: "continue" (unless handler failed). - input->paste = rv && !ERROR_SET(&err) ? 2 : 0; + // Paste phase: "continue" (unless handler canceled). + input->paste = !nvim_paste(keys, input->paste, &err) + ? 0 : (1 == input->paste ? 2 : input->paste); rbuffer_consumed(input->key_buffer, len); rbuffer_reset(input->key_buffer); if (ERROR_SET(&err)) { - msg_putchar('\n'); // TODO(justinmk): emsgf() does not display, why? msg_printf_attr(HL_ATTR(HLF_E)|MSG_HIST, "paste: %s", err.msg); api_clear_error(&err); @@ -373,7 +372,7 @@ static bool handle_bracketed_paste(TermInput *input) tinput_flush(input, true); // Paste phase: "first-chunk". input->paste = 1; - } else if (input->paste != 0) { + } else if (input->paste) { // Paste phase: "last-chunk". input->paste = input->paste == 2 ? 3 : -1; tinput_flush(input, true); |