Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit801faea

Browse files
authored
fix(input): use correct grid when restoring cursor for <expr> mapping (#19047)
1 parentc943252 commit801faea

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

‎src/nvim/getchar.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2122,6 +2122,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
21222122
constboolsave_may_garbage_collect=may_garbage_collect;
21232123
constintsave_cursor_row=ui_current_row();
21242124
constintsave_cursor_col=ui_current_col();
2125+
consthandle_Tsave_cursor_grid=ui_cursor_grid();
21252126
constintprev_did_emsg=did_emsg;
21262127

21272128
vgetc_busy=0;
@@ -2135,7 +2136,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
21352136

21362137
// The mapping may do anything, but we expect it to take care of
21372138
// redrawing. Do put the cursor back where it was.
2138-
ui_cursor_goto(save_cursor_row,save_cursor_col);
2139+
ui_grid_cursor_goto(save_cursor_grid,save_cursor_row,save_cursor_col);
21392140
ui_flush();
21402141

21412142
// If an error was displayed and the expression returns an empty

‎src/nvim/ui.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,11 @@ int ui_current_col(void)
495495
returncursor_col;
496496
}
497497

498+
handle_Tui_cursor_grid(void)
499+
{
500+
returncursor_grid_handle;
501+
}
502+
498503
voidui_flush(void)
499504
{
500505
cmdline_ui_flush();

‎test/functional/ex_cmds/map_spec.lua‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ n asdf1 qwert
8686
end)
8787
end)
8888

89-
describe(':*map cursor and redrawing',function()
89+
describe('Screen',function()
9090
localscreen
9191
before_each(function()
9292
clear()
@@ -149,6 +149,18 @@ describe(':*map cursor and redrawing', function()
149149
]])
150150
end)
151151

152+
it('cursor position does not move after empty-string :cmap <expr> #19046',function()
153+
command([[cnoremap <expr> <F2> '']])
154+
feed(':<F2>')
155+
screen:expect([[
156+
|
157+
~ |
158+
~ |
159+
~ |
160+
:^ |
161+
]])
162+
end)
163+
152164
it('cursor is restored after :map <expr> which redraws statusline vim-patch:8.1.2336',function()
153165
exec([[
154166
call setline(1, ['one', 'two', 'three'])
@@ -157,12 +169,12 @@ describe(':*map cursor and redrawing', function()
157169
hi! link StatusLine ErrorMsg
158170
noremap <expr> <C-B> Func()
159171
func Func()
160-
let g:on = !get(g:, 'on', 0)
161-
redraws
162-
return ''
172+
let g:on = !get(g:, 'on', 0)
173+
redraws
174+
return ''
163175
endfunc
164176
func Status()
165-
return get(g:, 'on', 0) ? '[on]' : ''
177+
return get(g:, 'on', 0) ? '[on]' : ''
166178
endfunc
167179
set stl=%{Status()}
168180
]])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp