Skip to content

Commit f00f4d9

Browse files
committed
patch 9.1.0710: popup window may hide part of Command line
Problem: when a popup window covers the command line, the command line is not completely cleared on popup_hide() (yu3s) Solution: Check if the popup window covers the command line and if it does, set the clear_cmdline flag. fixes: #15608 closes: #15610 Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 3c07eb0 commit f00f4d9

5 files changed

Lines changed: 78 additions & 1 deletion

File tree

src/popupwin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,6 +2758,8 @@ popup_hide(win_T *wp)
27582758

27592759
wp->w_popup_flags |= POPF_HIDDEN;
27602760
// Do not decrement b_nwindows, we still reference the buffer.
2761+
if (wp->w_winrow + popup_height(wp) >= cmdline_row)
2762+
clear_cmdline = TRUE;
27612763
redraw_all_later(UPD_NOT_VALID);
27622764
popup_mask_refresh = TRUE;
27632765
}

src/testdir/dumps/Test_echowindow_9.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
|~| @73
55
|~| @73
66
|~| @73
7-
|:+0#0000000&|c|a|l@1| |H|i|d|e|W|i|n|(|)| @59
7+
| +0#0000000&@74
88
@57|0|,|0|-|1| @8|A|l@1|
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
>f+0&#ffffff0|o@1|b|a|r| |o|n|e| |t|w|o| |t|h|r|e@1| @54
2+
|f|o@1|b|a|r| |o|n|e| |t|w|o| |t|h|r|e@1| @54
3+
|f|o@1|b|a|r| |o|n|e| |t|w|o| |t|h|r|e@1| @54
4+
|f|o@1|b|a|r| |o|n|e| |t|w|o| |t|h|r|e@1| @54
5+
|f|o@1|b|a|r| |o|n|e| |t|w|o| |t|h|r|e@1| @54
6+
|f|o@1|b|a|r| |o|n|e| |t|w|o| |t|h|r|e@1| @54
7+
|f|o@1|b|a|r| |o|n|e| |t|w|o| |t|h|r|e@1| @54
8+
|f|o@1|b|a|r| |o|n|e| |t|w|o| |t|h|r|e@1| @54
9+
|f|o@1|b|a|r| |o|n|e| |t|w|o| |t|h|r|e@1| @54
10+
@57|1|,|1| @10|T|o|p|

src/testdir/test_popupwin.vim

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4315,4 +4315,67 @@ func Test_popupwin_setbufvar_changing_window_view()
43154315
bw!
43164316
endfunc
43174317

4318+
func Test_popupwin_clears_cmdline_on_hide()
4319+
" Test that the command line is properly cleared for overlong
4320+
" popup windows and using popup_hide()
4321+
CheckScreendump
4322+
4323+
let lines =<< trim END
4324+
vim9script
4325+
var id: number
4326+
def Filter(winid: number, key: string): bool
4327+
if key == 'q'
4328+
popup_hide(winid)
4329+
else
4330+
return false
4331+
endif
4332+
return true
4333+
enddef
4334+
setline(1, repeat(['foobar one two three'], &lines))
4335+
id = popup_create(1, {
4336+
col: 1,
4337+
minwidth: &columns,
4338+
maxwidth: &columns,
4339+
minheight: &lines,
4340+
maxheight: &lines,
4341+
filter: Filter,
4342+
})
4343+
END
4344+
call writefile(lines, 'XtestPopup_win', 'D')
4345+
let buf = RunVimInTerminal('-S XtestPopup_win', #{rows: 10})
4346+
call term_sendkeys(buf, "q")
4347+
call term_wait(buf)
4348+
call VerifyScreenDump(buf, 'Test_popupwin_hide_clear_cmdline_01', {})
4349+
call StopVimInTerminal(buf)
4350+
let lines =<< trim END
4351+
vim9script
4352+
var id: number
4353+
def Filter(winid: number, key: string): bool
4354+
if key == 'q'
4355+
popup_close(winid)
4356+
else
4357+
return false
4358+
endif
4359+
return true
4360+
enddef
4361+
setline(1, repeat(['foobar one two three'], &lines))
4362+
id = popup_create(1, {
4363+
col: 1,
4364+
minwidth: &columns,
4365+
maxwidth: &columns,
4366+
minheight: &lines,
4367+
maxheight: &lines,
4368+
filter: Filter,
4369+
})
4370+
END
4371+
call writefile(lines, 'XtestPopup_win2', 'D')
4372+
let buf = RunVimInTerminal('-S XtestPopup_win2', #{rows: 10})
4373+
call term_sendkeys(buf, "q")
4374+
call term_wait(buf)
4375+
call VerifyScreenDump(buf, 'Test_popupwin_hide_clear_cmdline_01', {})
4376+
4377+
" clean up
4378+
call StopVimInTerminal(buf)
4379+
endfunc
4380+
43184381
" vim: shiftwidth=2 sts=2

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
710,
707709
/**/
708710
709,
709711
/**/

0 commit comments

Comments
 (0)