diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-07 21:13:09 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-04-07 21:42:07 +0800 |
commit | 2a574f7aaaf5cd0803faa9e4337bf3e21e8b8d2a (patch) | |
tree | 25196ecabe19a4d834e79a48ea54115c8d4579f1 /src/nvim/getchar.c | |
parent | dc9e436986bec15b027c2a8d78782f514c046a8b (diff) | |
download | rneovim-2a574f7aaaf5cd0803faa9e4337bf3e21e8b8d2a.tar.gz rneovim-2a574f7aaaf5cd0803faa9e4337bf3e21e8b8d2a.tar.bz2 rneovim-2a574f7aaaf5cd0803faa9e4337bf3e21e8b8d2a.zip |
fix(input): fix clearing of reg_executing
vim-patch:8.2.4705
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r-- | src/nvim/getchar.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index eddd5ccd14..12c08baead 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2060,7 +2060,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth) } /// unget one character (can only be done once!) -/// If the character was stuffed, vgetc() will get it next time it was called. +/// If the character was stuffed, vgetc() will get it next time it is called. /// Otherwise vgetc() will only get it when the stuff buffer is empty. void vungetc(int c) { @@ -2072,6 +2072,20 @@ void vungetc(int c) old_KeyStuffed = KeyStuffed; } +/// When peeking and not getting a character, reg_executing cannot be cleared +/// yet, so set a flag to clear it later. +static void check_end_reg_executing(bool advance) +{ + if (reg_executing != 0 && (typebuf.tb_maplen == 0 || pending_end_reg_executing)) { + if (advance) { + reg_executing = 0; + pending_end_reg_executing = false; + } else { + pending_end_reg_executing = true; + } + } +} + /// Gets a byte: /// 1. from the stuffbuffer /// This is used for abbreviated commands like "D" -> "d$". @@ -2126,9 +2140,7 @@ static int vgetorpeek(bool advance) init_typebuf(); start_stuff(); - if (advance && typebuf.tb_maplen == 0) { - reg_executing = 0; - } + check_end_reg_executing(advance); do { // get a character: 1. from the stuffbuffer if (typeahead_char != 0) { @@ -2155,6 +2167,7 @@ static int vgetorpeek(bool advance) // If a mapped key sequence is found we go back to the start to // try re-mapping. for (;;) { + check_end_reg_executing(advance); // os_breakcheck() is slow, don't use it too often when // inside a mapping. But call it each time for typed // characters. |