0
0
mirror of https://github.com/vim/vim.git synced 2025-10-28 09:27:14 -04:00

patch 9.1.1621: flicker in popup menu during cmdline autocompletion

Problem:  When the popup menu (PUM) occupies more than half the screen
          height, it flickers whenever a character is typed or erased.
          This happens because the PUM is cleared and the screen is
          redrawn before a new PUM is rendered. The extra redraw between
          menu updates causes visible flicker.
Solution: A complete, non-hacky fix would require removing the
          CmdlineChanged event from the loop and letting autocompletion
          manage the process end-to-end. This is because screen redraws
          after any cmdline change are necessary for other features to
          work.
          This change modifies wildtrigger() so that the next typed
          character defers the screen update instead of redrawing
          immediately. This removes the intermediate redraw, eliminating
          flicker and making cmdline autocompletion feel smooth
          (Girish Palya).

Trade-offs:
This behavior change in wildtrigger() is tailored specifically for
:h cmdline-autocompletion. wildtrigger() now has no general-purpose use
outside this scenario.

closes: #17932

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Girish Palya
2025-08-08 08:26:03 +02:00
committed by Christian Brabandt
parent 4fca92faa2
commit da9c966893
8 changed files with 101 additions and 12 deletions

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @6| +0#0000001#ffd7ff255|a|b|c|1| @10| +0#4040ff13#ffffff0@50
|~| @6| +0#0000001#ffd7ff255|a|b|c|2| @10| +0#4040ff13#ffffff0@50
|~| @6| +0#0000001#ffd7ff255|a|b|c|3| @10| +0#4040ff13#ffffff0@50
|~| @6| +0#0000001#ffd7ff255|a|b|c|4| @10| +0#4040ff13#ffffff0@50
|~| @6| +0#0000001#ffd7ff255|a|b|c|5| @10| +0#4040ff13#ffffff0@50
|:+0#0000000&|T|e|s|t|C|m|d| |a> @64

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @6| +0#0000001#ffd7ff255|a|b|c|1| @10| +0#4040ff13#ffffff0@50
|~| @6| +0#0000001#ffd7ff255|a|b|c|2| @10| +0#4040ff13#ffffff0@50
|~| @6| +0#0000001#ffd7ff255|a|b|c|3| @10| +0#4040ff13#ffffff0@50
|~| @6| +0#0000001#ffd7ff255|a|b|c|4| @10| +0#4040ff13#ffffff0@50
|~| @6| +0#0000001#ffd7ff255|a|b|c|5| @10| +0#4040ff13#ffffff0@50
|:+0#0000000&|T|e|s|t|C|m|d| |a|x> @63

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|:+0#0000000&|T|e|s|t|C|m|d| |a|x> @45|0|,|0|-|1| @8|A|l@1|

View File

@@ -4822,4 +4822,41 @@ func Test_cmdline_changed()
call test_override("char_avail", 0)
endfunc
func Test_wildtrigger_update_screen()
CheckScreendump
let lines =<< trim [SCRIPT]
command! -nargs=* -complete=customlist,TestFn TestCmd echo
func TestFn(cmdarg, b, c)
if a:cmdarg == 'ax'
return []
else
return map(range(1, 5), 'printf("abc%d", v:val)')
endif
endfunc
set wildmode=noselect,full
set wildoptions=pum
set wildmenu
cnoremap <F8> <C-R>=wildtrigger()[-1]<CR>
[SCRIPT]
call writefile(lines, 'XTest_wildtrigger', 'D')
let buf = RunVimInTerminal('-S XTest_wildtrigger', {'rows': 10})
call term_sendkeys(buf, ":TestCmd a\<F8>")
call VerifyScreenDump(buf, 'Test_wildtrigger_update_screen_1', {})
" Typing a character when pum is open does not close the pum window
" This is needed to prevent pum window from flickering during
" ':h cmdline-autocompletion'.
call term_sendkeys(buf, "x")
call VerifyScreenDump(buf, 'Test_wildtrigger_update_screen_2', {})
" pum window is closed when no completion candidates are available
call term_sendkeys(buf, "\<F8>")
call VerifyScreenDump(buf, 'Test_wildtrigger_update_screen_3', {})
call term_sendkeys(buf, "\<esc>")
call StopVimInTerminal(buf)
cnoremap <buffer> <F8> <C-R>=wildtrigger()[-1]<CR>
endfunc
" vim: shiftwidth=2 sts=2 expandtab