mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 15:38:33 +00:00
input_enqueue(): Fix length calculation. (#5981)
Ref: https://github.com/neovim/neovim/issues/5885#issuecomment-273614373
This commit is contained in:
@@ -170,12 +170,13 @@ bool os_isatty(int fd)
|
|||||||
|
|
||||||
size_t input_enqueue(String keys)
|
size_t input_enqueue(String keys)
|
||||||
{
|
{
|
||||||
char *ptr = keys.data, *end = ptr + keys.size;
|
char *ptr = keys.data;
|
||||||
|
char *end = ptr + keys.size;
|
||||||
|
|
||||||
while (rbuffer_space(input_buffer) >= 6 && ptr < end) {
|
while (rbuffer_space(input_buffer) >= 6 && ptr < end) {
|
||||||
uint8_t buf[6] = { 0 };
|
uint8_t buf[6] = { 0 };
|
||||||
unsigned int new_size = trans_special((const uint8_t **)&ptr, keys.size,
|
unsigned int new_size
|
||||||
buf, true);
|
= trans_special((const uint8_t **)&ptr, (size_t)(end - ptr), buf, true);
|
||||||
|
|
||||||
if (new_size) {
|
if (new_size) {
|
||||||
new_size = handle_mouse_event(&ptr, buf, new_size);
|
new_size = handle_mouse_event(&ptr, buf, new_size);
|
||||||
@@ -185,8 +186,7 @@ size_t input_enqueue(String keys)
|
|||||||
|
|
||||||
if (*ptr == '<') {
|
if (*ptr == '<') {
|
||||||
char *old_ptr = ptr;
|
char *old_ptr = ptr;
|
||||||
// Invalid or incomplete key sequence, skip until the next '>' or until
|
// Invalid or incomplete key sequence, skip until the next '>' or *end.
|
||||||
// *end
|
|
||||||
do {
|
do {
|
||||||
ptr++;
|
ptr++;
|
||||||
} while (ptr < end && *ptr != '>');
|
} while (ptr < end && *ptr != '>');
|
||||||
|
Reference in New Issue
Block a user