diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 026d09d9a9..30f77c7248 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -148,7 +148,7 @@ void nvim_win_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err) switchwin_T switchwin; switch_win(&switchwin, win, NULL, true); update_topline(curwin); - validate_cursor(curwin); + setcursor_mayforce(true); restore_win(&switchwin, true); redraw_later(win, UPD_VALID); diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index a10c8f48ef..721148faaa 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -219,6 +219,21 @@ describe('API/win', function() -- curwin didn't change back neq(win, curwin()) + + -- shows updated position after getchar() #20793 + feed(':call getchar()') + api.nvim_win_set_cursor(win, { 1, 5 }) + screen:expect { + grid = [[ + | + {1:~ }|*2 + {2:[No Name] }| + prolo^gue | + |*2 + {3:[No Name] [+] }| + :call getchar() | + ]], + } end) it('remembers what column it wants to be in', function()