vim-patch:9.2.0855: 'showcmd' not redrawn with empty mapping triggered on timeout

Problem:  'showcmd' not redrawn with empty mapping triggered on timeout.
Solution: Don't postpone redraw when inside vgetorpeek(). Also move test
          for tabline 'showcmd' to test_tabline.vim.

fixes:  vim/vim#20839
closes: vim/vim#20840

2e9687647a
This commit is contained in:
zeertzjq
2026-07-26 06:59:54 +08:00
parent a56f4d221e
commit 7ee1bf91ad
6 changed files with 64 additions and 28 deletions

View File

@@ -2054,7 +2054,7 @@ static void display_showcmd(void)
showcmd_update_clear_state();
if (*p_sloc == 's') {
if (showcmd_is_clear) {
if (showcmd_is_clear && !vgetc_busy) {
curwin->w_redr_status = true;
} else {
win_redr_status(curwin);
@@ -2063,7 +2063,7 @@ static void display_showcmd(void)
return;
}
if (*p_sloc == 't') {
if (showcmd_is_clear) {
if (showcmd_is_clear && !vgetc_busy) {
redraw_tabline = true;
} else {
draw_tabline();

View File

@@ -136,4 +136,17 @@ describe('statusline', function()
: |
]])
end)
-- oldtest: Test_statusline_showcmd_nop_map()
it('showcmdloc=statusline is redrawn with timeout and <Nop> mapping', function()
exec([[
set timeoutlen=500 showcmd showcmdloc=statusline laststatus=2
nnoremap <space> <nop>
nnoremap <space><space> <nop>
]])
feed(' ')
screen:expect({ any = '<20>', timeout = 400 })
vim.uv.sleep(500)
screen:expect({ none = '<20>', timeout = 400 })
end)
end)

View File

@@ -85,4 +85,16 @@ describe('tabline', function()
: |
]])
end)
-- oldtest: Test_tabline_showcmd_redraw_tabline()
it('clears showcmd rendered by tabline redraw', function()
exec([[
set showcmd showcmdloc=tabline showtabline=2 tabline=%S timeoutlen=0
nnoremap g :redraw<CR>
nnoremap gc <Nop>
]])
feed('g')
screen:expect({ any = ':redraw', none = '{2::' })
t.eq('', n.api.nvim_eval_statusline('%S', {}).str)
end)
end)

View File

@@ -884,15 +884,6 @@ describe('statusline', function()
]])
end)
it('clears showcmd rendered by tabline redraw', function()
command('set showcmd showcmdloc=tabline showtabline=2 tabline=%S timeoutlen=0')
command('nnoremap g :redraw<CR>')
command('nnoremap gc <Nop>')
feed('g')
screen:expect({ any = ':redraw', none = '{2::' })
eq('', api.nvim_eval_statusline('%S', {}).str)
end)
it('showcmdloc=statusline works with vertical splits', function()
command('rightbelow vsplit')
command('set showcmd showcmdloc=statusline')

View File

@@ -667,23 +667,6 @@ func Test_statusline_showcmd()
call StopVimInTerminal(buf)
endfunc
func Test_statusline_showcmd_redraw_tabline()
CheckRunVimInTerminal
let lines =<< trim END
set showcmd showcmdloc=tabline showtabline=2 tabline=%S timeoutlen=0
nnoremap g :redraw<CR>
nnoremap gc <Nop>
END
call writefile(lines, 'XTest_statusline_showcmd_redraw', 'D')
let buf = RunVimInTerminal('-S XTest_statusline_showcmd_redraw', #{rows: 6, cols: 40})
call term_sendkeys(buf, 'g')
call WaitForAssert({-> assert_match(':redraw', term_getline(buf, 6))})
call WaitForAssert({-> assert_notmatch('^:', term_getline(buf, 1))})
call StopVimInTerminal(buf)
endfunc
func Test_statusline_showcmd_cmd_mapping()
set showcmd
set statusline=AAA%SBBB
@@ -708,6 +691,25 @@ func Test_statusline_showcmd_cmd_mapping()
endtry
endfunc
func Test_statusline_showcmd_nop_map()
CheckRunVimInTerminal
let lines =<< trim END
set timeoutlen=500 showcmdloc=statusline laststatus=2
nnoremap <space> <nop>
nnoremap <space><space> <nop>
END
call writefile(lines, 'XTest_statusline_showcmd_nop', 'D')
let buf = RunVimInTerminal('-S XTest_statusline_showcmd_nop', {'rows': 6})
call term_sendkeys(buf, ' ')
call WaitForAssert({-> assert_match('<20>', term_getline(buf, 5))}, 400)
sleep 500m
call WaitForAssert({-> assert_notmatch('<20>', term_getline(buf, 5))}, 400)
call StopVimInTerminal(buf)
endfunc
func Test_statusline_highlight_group_cleared()
CheckScreendump

View File

@@ -204,6 +204,24 @@ func Test_tabline_showcmd()
call StopVimInTerminal(buf)
endfunc
func Test_tabline_showcmd_redraw_tabline()
CheckRunVimInTerminal
let lines =<< trim END
set showcmd showcmdloc=tabline showtabline=2 tabline=%S timeoutlen=0
nnoremap g :redraw<CR>
nnoremap gc <Nop>
END
call writefile(lines, 'XTest_tabline_showcmd_redraw', 'D')
let buf = RunVimInTerminal('-S XTest_tabline_showcmd_redraw', #{rows: 6, cols: 40})
call term_sendkeys(buf, 'g')
call WaitForAssert({-> assert_match(':redraw', term_getline(buf, 6))})
call WaitForAssert({-> assert_notmatch('^:', term_getline(buf, 1))})
call StopVimInTerminal(buf)
endfunc
func TruncTabLine()
return '%1T口口%2Ta' .. repeat('b', &columns - 4) .. '%999X%#TabLine#c'
endfunc