diff options
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r-- | src/nvim/getchar.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 9f223bf750..7f783fd72f 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -990,31 +990,16 @@ int ins_typebuf(char *str, int noremap, int offset, bool nottyped, bool silent) /// Can be used for a character obtained by vgetc() that needs to be put back. /// Uses cmd_silent, KeyTyped and KeyNoremap to restore the flags belonging to /// the char. +/// /// @return the length of what was inserted -int ins_char_typebuf(int c, int modifier) +int ins_char_typebuf(int c, int modifiers) { char_u buf[MB_MAXBYTES * 3 + 4]; - int len = 0; - if (modifier != 0) { - buf[0] = K_SPECIAL; - buf[1] = KS_MODIFIER; - buf[2] = (char_u)modifier; - buf[3] = NUL; - len = 3; - } - if (IS_SPECIAL(c)) { - buf[len] = K_SPECIAL; - buf[len + 1] = (char_u)K_SECOND(c); - buf[len + 2] = (char_u)K_THIRD(c); - buf[len + 3] = NUL; - len += 3; - } else { - char_u *end = add_char2buf(c, buf + len); - *end = NUL; - len = (int)(end - buf); - } + unsigned int len = special_to_buf(c, modifiers, true, buf); + assert(len < sizeof(buf)); + buf[len] = NUL; (void)ins_typebuf((char *)buf, KeyNoremap, 0, !KeyTyped, cmd_silent); - return len; + return (int)len; } /// Return TRUE if the typeahead buffer was changed (while waiting for a |