From 3e83e44792021fb9d18acbb664172ce9a06dc9be Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sun, 14 Dec 2014 09:20:07 -0300 Subject: [PATCH] input: Ignore invalid "<" key sequences Ignoring invalid key sequences simplifies input handling in UIs. The only downside is having to use "" everytime a "<" is needed on functional tests. --- src/nvim/os/input.c | 10 ++++++++-- test/functional/legacy/066_visual_block_tab_spec.lua | 10 +++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index c0d588f4ef..130e239a34 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -187,14 +187,20 @@ size_t input_enqueue(String keys) unsigned int new_size = trans_special((uint8_t **)&ptr, buf, false); if (!new_size) { + if (*ptr == '<') { + // Invalid key sequence, skip until the next '>' or until *end + do { + ptr++; + } while (ptr < end && *ptr != '>'); + ptr++; + continue; + } // copy the character unmodified *buf = (uint8_t)*ptr++; new_size = 1; } new_size = handle_mouse_event(&ptr, buf, new_size); - // TODO(tarruda): Don't produce past unclosed '<' characters, except if - // there's a lot of characters after the '<' rbuffer_write(input_buffer, (char *)buf, new_size); } diff --git a/test/functional/legacy/066_visual_block_tab_spec.lua b/test/functional/legacy/066_visual_block_tab_spec.lua index cd283e6746..82bb988c67 100644 --- a/test/functional/legacy/066_visual_block_tab_spec.lua +++ b/test/functional/legacy/066_visual_block_tab_spec.lua @@ -23,18 +23,18 @@ describe('visual block shift and tab characters', function() abcdefghijklmnopqrstuvwxyz]]) feed('gg') - feed([[fe4jRugvr1:'<,'>yank A]]) + feed([[fe4jRugvr1:','>yank A]]) execute('/^abcdefgh') - feed('4jI j<<11|D') + feed('4jI j11|D') feed('j7|a ') feed('j7|a ') - feed('j7|a 4k13|4j<') + feed('j7|a 4k13|4j') execute('$-5,$yank A') execute([[$-4,$s/\s\+//g]]) - feed('4kI j<<') + feed('4kI j') feed('j7|a ') feed('j7|a ') - feed('j7|a 4k13|4j3<') + feed('j7|a 4k13|4j3') execute('$-4,$yank A') -- Put @a and clean empty lines