diff options
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r-- | src/nvim/getchar.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 788e1113e2..6b716c2e1f 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -629,7 +629,7 @@ void stuffReadbuffSpec(const char *s) stuffReadbuffLen(s, 3); s += 3; } else { - int c = mb_ptr2char_adv((const char_u **)&s); + int c = mb_cptr2char_adv((const char_u **)&s); if (c == CAR || c == NL || c == ESC) { c = ' '; } @@ -2328,19 +2328,19 @@ static int vgetorpeek(bool advance) // try re-mapping. for (;;) { check_end_reg_executing(advance); - // os_breakcheck() can call input_enqueue() - if ((mapped_ctrl_c | curbuf->b_mapped_ctrl_c) & get_real_state()) { - ctrl_c_interrupts = false; - } // os_breakcheck() is slow, don't use it too often when // inside a mapping. But call it each time for typed // characters. if (typebuf.tb_maplen) { line_breakcheck(); } else { + // os_breakcheck() can call input_enqueue() + if ((mapped_ctrl_c | curbuf->b_mapped_ctrl_c) & get_real_state()) { + ctrl_c_interrupts = false; + } os_breakcheck(); // check for CTRL-C + ctrl_c_interrupts = true; } - ctrl_c_interrupts = true; int keylen = 0; if (got_int) { // flush all input @@ -2585,8 +2585,8 @@ static int vgetorpeek(bool advance) // get a character: 3. from the user - get it if (typebuf.tb_len == 0) { - // timedout may have been set while waiting for a mapping - // that has a <Nop> RHS. + // timedout may have been set if a mapping with empty RHS + // fully matched while longer mappings timed out. timedout = false; } @@ -2839,8 +2839,8 @@ int fix_input_buffer(char_u *buf, int len) /// the final `lhs` exceeds `MAXMAPLEN`, `lhs_len` will be set equal to the /// original larger length and `lhs` will be truncated. /// -/// If RHS is equal to "<Nop>", `rhs` will be the empty string, `rhs_len` -/// will be zero, and `rhs_is_noop` will be set to true. +/// If RHS should be <Nop>, `rhs` will be an empty string, `rhs_len` will be +/// zero, and `rhs_is_noop` will be set to true. /// /// Any memory allocated by @ref replace_termcodes is freed before this function /// returns. @@ -2898,8 +2898,9 @@ void set_maparg_lhs_rhs(const char *const orig_lhs, const size_t orig_lhs_len, replaced = replace_termcodes(orig_rhs, orig_rhs_len, &rhs_buf, REPTERM_DO_LT, NULL, cpo_flags); mapargs->rhs_len = STRLEN(replaced); - // XXX: even when orig_rhs is non-empty, replace_termcodes may produce an empty string. - mapargs->rhs_is_noop = orig_rhs[0] != NUL && mapargs->rhs_len == 0; + // XXX: replace_termcodes may produce an empty string even if orig_rhs is non-empty + // (e.g. a single ^V, see :h map-empty-rhs) + mapargs->rhs_is_noop = orig_rhs_len != 0 && mapargs->rhs_len == 0; mapargs->rhs = xcalloc(mapargs->rhs_len + 1, sizeof(char_u)); STRLCPY(mapargs->rhs, replaced, mapargs->rhs_len + 1); } |