diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-01-15 09:19:27 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-01-15 09:19:27 -0300 |
commit | 5f24549ab1ecd69236be2761a2e43690ba7cf283 (patch) | |
tree | 7db3ba6961a7115c43e0133a6780f4a742112f05 /src/nvim/os/input.c | |
parent | 9b4f6fbd33ebd452d472b0333accfcb34e01173b (diff) | |
parent | 14ebe608e2d26ba352f5abe1c32ce18fcc2eca06 (diff) | |
download | rneovim-5f24549ab1ecd69236be2761a2e43690ba7cf283.tar.gz rneovim-5f24549ab1ecd69236be2761a2e43690ba7cf283.tar.bz2 rneovim-5f24549ab1ecd69236be2761a2e43690ba7cf283.zip |
Merge PR #1810 'abstract_ui fixes and improvements(continuation)'
Diffstat (limited to 'src/nvim/os/input.c')
-rw-r--r-- | src/nvim/os/input.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index c0d588f4ef..2ae4558f3d 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); } @@ -217,7 +223,8 @@ static unsigned int handle_mouse_event(char **ptr, uint8_t *buf, mouse_code = buf[5]; } - if (mouse_code < KE_LEFTMOUSE || mouse_code > KE_RIGHTRELEASE) { + if (!((mouse_code >= KE_LEFTMOUSE && mouse_code <= KE_RIGHTRELEASE) + || (mouse_code >= KE_MOUSEDOWN && mouse_code <= KE_MOUSERIGHT))) { return bufsize; } @@ -226,7 +233,7 @@ static unsigned int handle_mouse_event(char **ptr, uint8_t *buf, // find mouse coordinates, and it would be too expensive to refactor this // now. int col, row, advance; - if (sscanf(*ptr, "<%d,%d>%n", &col, &row, &advance)) { + if (sscanf(*ptr, "<%d,%d>%n", &col, &row, &advance) != EOF && advance) { if (col >= 0 && row >= 0) { mouse_row = row; mouse_col = col; |