From 6cac77016b1636e04073e8348b7cee02259ef928 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 4 Jan 2022 18:01:21 +0000 Subject: patch 8.2.4002: first char typed in Select mode can be wrong Problem: First char typed in Select mode can be wrong. Solution: Escape special bytes in the input buffer. (closes #9469) --- src/getchar.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/getchar.c') diff --git a/src/getchar.c b/src/getchar.c index fa8c574d9f..6fecc1a289 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -1121,7 +1121,7 @@ ins_typebuf( int ins_char_typebuf(int c, int modifier) { - char_u buf[MB_MAXBYTES + 4]; + char_u buf[MB_MAXBYTES * 3 + 4]; int len = 0; if (modifier != 0) @@ -1142,8 +1142,18 @@ ins_char_typebuf(int c, int modifier) } else { - len += (*mb_char2bytes)(c, buf + len); - buf[len] = NUL; + char_u *p = buf + len; + int char_len = (*mb_char2bytes)(c, p); +#ifdef FEAT_GUI + int save_gui_in_use = gui.in_use; + + gui.in_use = FALSE; +#endif + // if the character contains CSI or K_SPECIAL bytes they need escaping + len += fix_input_buffer(p, char_len); +#ifdef FEAT_GUI + gui.in_use = save_gui_in_use; +#endif } (void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent); return len; @@ -3644,7 +3654,6 @@ fix_input_buffer(char_u *buf, int len) p += 2; i -= 2; } -# ifndef MSWIN // When the GUI is not used CSI needs to be escaped. else if (!gui.in_use && p[0] == CSI) { @@ -3654,7 +3663,6 @@ fix_input_buffer(char_u *buf, int len) *p = (int)KE_CSI; len += 2; } -# endif else #endif if (p[0] == NUL || (p[0] == K_SPECIAL -- cgit v1.2.3