aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/getchar.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-02-17 07:18:10 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-02-17 08:44:58 +0800
commitc90cf8c77b96cda0fd40dbf4aa2c1762cd09dab3 (patch)
tree9f2b538618f1563ad64798520d77763b01b936d7 /src/nvim/getchar.c
parent3230b314862e50899d68b3944134cbffaa797cde (diff)
downloadrneovim-c90cf8c77b96cda0fd40dbf4aa2c1762cd09dab3.tar.gz
rneovim-c90cf8c77b96cda0fd40dbf4aa2c1762cd09dab3.tar.bz2
rneovim-c90cf8c77b96cda0fd40dbf4aa2c1762cd09dab3.zip
vim-patch:8.1.2336: when an expr mapping moves the cursor it is not restored
Problem: When an expr mapping moves the cursor it is not restored. Solution: Position the cursor after an expr mapping. (closes vim/vim#5256) https://github.com/vim/vim/commit/4ebe0e62d097d68c5312f9c32714fb41a4c947a3
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r--src/nvim/getchar.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 741fc6d803..ac5d587c1e 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -1949,8 +1949,10 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
// expression. Also save and restore the command line
// for "normal :".
if (mp->m_expr) {
- int save_vgetc_busy = vgetc_busy;
+ const int save_vgetc_busy = vgetc_busy;
const bool save_may_garbage_collect = may_garbage_collect;
+ const int save_cursor_row = ui_current_row();
+ const int save_cursor_col = ui_current_col();
vgetc_busy = 0;
may_garbage_collect = false;
@@ -1960,6 +1962,12 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
save_m_str = vim_strsave(mp->m_str);
}
map_str = eval_map_expr(mp, NUL);
+
+ // The mapping may do anything, but we expect it to take care of
+ // redrawing. Do put the cursor back where it was.
+ ui_cursor_goto(save_cursor_row, save_cursor_col);
+ ui_flush();
+
vgetc_busy = save_vgetc_busy;
may_garbage_collect = save_may_garbage_collect;
} else {