patch 8.2.3993: when recording a change in Select mode char appears twice
Problem: When recording a change in Select mode the first typed character
appears twice.
Solution: When putting the character back into typeahead remove it from
recorded characters. (closes #9462)
diff --git a/src/normal.c b/src/normal.c
index cd9b0a9..553ed24 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -592,12 +592,19 @@
&& VIsual_select
&& (vim_isprintc(c) || c == NL || c == CAR || c == K_KENTER))
{
+ int len;
+
// Fake a "c"hange command. When "restart_edit" is set (e.g., because
// 'insertmode' is set) fake a "d"elete command, Insert mode will
// restart automatically.
// Insert the typed character in the typeahead buffer, so that it can
// be mapped in Insert mode. Required for ":lmap" to work.
- ins_char_typebuf(vgetc_char, vgetc_mod_mask);
+ len = ins_char_typebuf(vgetc_char, vgetc_mod_mask);
+
+ // When recording the character will be recorded again, remove the
+ // previously recording.
+ ungetchars(len);
+
if (restart_edit != 0)
c = 'd';
else