diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-06-23 06:04:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-23 06:04:03 +0800 |
commit | 801faeaae263b545afc18b1cb6f2ad14dceb4c23 (patch) | |
tree | efc94c96267751079c947728b76abad8d95724e4 | |
parent | c94325288a1008b5eabe7ae0fd03aa906686ee1b (diff) | |
download | rneovim-801faeaae263b545afc18b1cb6f2ad14dceb4c23.tar.gz rneovim-801faeaae263b545afc18b1cb6f2ad14dceb4c23.tar.bz2 rneovim-801faeaae263b545afc18b1cb6f2ad14dceb4c23.zip |
fix(input): use correct grid when restoring cursor for <expr> mapping (#19047)
-rw-r--r-- | src/nvim/getchar.c | 3 | ||||
-rw-r--r-- | src/nvim/ui.c | 5 | ||||
-rw-r--r-- | test/functional/ex_cmds/map_spec.lua | 22 |
3 files changed, 24 insertions, 6 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 7f783fd72f..57d25e5c45 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2122,6 +2122,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth) 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(); + const handle_T save_cursor_grid = ui_cursor_grid(); const int prev_did_emsg = did_emsg; vgetc_busy = 0; @@ -2135,7 +2136,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth) // 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_grid_cursor_goto(save_cursor_grid, save_cursor_row, save_cursor_col); ui_flush(); // If an error was displayed and the expression returns an empty diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 96ce2c4cb1..a49e9df9ee 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -495,6 +495,11 @@ int ui_current_col(void) return cursor_col; } +handle_T ui_cursor_grid(void) +{ + return cursor_grid_handle; +} + void ui_flush(void) { cmdline_ui_flush(); diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua index eae36b9ae9..c6bdd017bd 100644 --- a/test/functional/ex_cmds/map_spec.lua +++ b/test/functional/ex_cmds/map_spec.lua @@ -86,7 +86,7 @@ n asdf1 qwert end) end) -describe(':*map cursor and redrawing', function() +describe('Screen', function() local screen before_each(function() clear() @@ -149,6 +149,18 @@ describe(':*map cursor and redrawing', function() ]]) end) + it('cursor position does not move after empty-string :cmap <expr> #19046', function() + command([[cnoremap <expr> <F2> '']]) + feed(':<F2>') + screen:expect([[ + | + ~ | + ~ | + ~ | + :^ | + ]]) + end) + it('cursor is restored after :map <expr> which redraws statusline vim-patch:8.1.2336', function() exec([[ call setline(1, ['one', 'two', 'three']) @@ -157,12 +169,12 @@ describe(':*map cursor and redrawing', function() hi! link StatusLine ErrorMsg noremap <expr> <C-B> Func() func Func() - let g:on = !get(g:, 'on', 0) - redraws - return '' + let g:on = !get(g:, 'on', 0) + redraws + return '' endfunc func Status() - return get(g:, 'on', 0) ? '[on]' : '' + return get(g:, 'on', 0) ? '[on]' : '' endfunc set stl=%{Status()} ]]) |