vim-patch:9.0.1694: wrong mapping applied when replaying a char search (#24670)

Problem: wrong mapping applied when replaying a char search
Solution: Store a NOP after the ESC

closes: vim/vim#12708
closes: vim/vim#6350

bacc83009b
This commit is contained in:
zeertzjq
2023-08-12 06:50:52 +08:00
committed by GitHub
parent 8c5d81997e
commit 72cf94fc0e
3 changed files with 57 additions and 24 deletions

View File

@@ -1147,6 +1147,13 @@ static void gotchars(const uint8_t *chars, size_t len)
maptick++;
}
/// Record a <Nop> key.
void gotchars_nop(void)
{
uint8_t nop_buf[3] = { K_SPECIAL, KS_EXTRA, KE_NOP };
gotchars(nop_buf, 3);
}
/// Undo the last gotchars() for "len" bytes. To be used when putting a typed
/// character back into the typeahead buffer, thus gotchars() will be called
/// again.
@@ -2745,14 +2752,9 @@ static int vgetorpeek(bool advance)
}
if (timedout && c == ESC) {
uint8_t nop_buf[3];
// When recording there will be no timeout. Add a <Nop> after the ESC
// to avoid that it forms a key code with following characters.
nop_buf[0] = K_SPECIAL;
nop_buf[1] = KS_EXTRA;
nop_buf[2] = KE_NOP;
gotchars(nop_buf, 3);
gotchars_nop();
}
vgetc_busy--;