Skip to content

Commit dcd40cf

Browse files
luukvbaalbrammool
authored andcommitted
patch 9.0.1480: using popup menu may leave text in the command line
Problem: Using popup menu may leave text in the command line. Solution: Clear the command line if the popup menu covered it. (Luuk van Baal, closes vim#12286)
1 parent f39d9e9 commit dcd40cf

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

src/popupmenu.c

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static int pum_selected; // index of selected item or -1
1818
static int pum_first = 0; // index of top item
1919

2020
static int call_update_screen = FALSE;
21+
static int pum_in_cmdline = FALSE;
2122

2223
static int pum_height; // nr of displayed pum items
2324
static int pum_width; // width of displayed pum items
@@ -1067,6 +1068,11 @@ pum_undisplay(void)
10671068
pum_array = NULL;
10681069
redraw_all_later(UPD_NOT_VALID);
10691070
redraw_tabline = TRUE;
1071+
if (pum_in_cmdline)
1072+
{
1073+
clear_cmdline = TRUE;
1074+
pum_in_cmdline = FALSE;
1075+
}
10701076
status_redraw_all();
10711077
#if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)
10721078
// hide any popup info window
@@ -1193,6 +1199,8 @@ pum_position_at_mouse(int min_width)
11931199
pum_row = mouse_row + 1;
11941200
if (pum_height > Rows - pum_row)
11951201
pum_height = Rows - pum_row;
1202+
if (pum_row + pum_height > cmdline_row)
1203+
pum_in_cmdline = TRUE;
11961204
}
11971205
else
11981206
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
>a+0&#ffffff0|b|c|d|e| @69
2+
|a|b|c|d|e| @69
3+
|a|b|c|d|e| @69
4+
@57|1|,|1| @10|T|o|p|

src/testdir/test_menu.vim

+21
Original file line numberDiff line numberDiff line change
@@ -594,4 +594,25 @@ func Test_unmenu_while_listing_menus()
594594
call StopVimInTerminal(buf)
595595
endfunc
596596

597+
" Test for opening a menu drawn in the cmdline area
598+
func Test_popupmenu_cmdline()
599+
CheckRunVimInTerminal
600+
601+
let lines =<< trim END
602+
set mousemodel=popup
603+
menu PopUp.Test1 :<CR>
604+
menu PopUp.Test2 :<CR>
605+
menu PopUp.Test3 :<CR>
606+
call setline(1, repeat(['abcde'], 5))
607+
END
608+
call writefile(lines, 'Xpopupcmdline', 'D')
609+
let buf = RunVimInTerminal('-S Xpopupcmdline', {'rows': 4})
610+
611+
" cmdline area should be cleared when popupmenu that covered it is closed
612+
call term_sendkeys(buf, "\<RightMouse>\<RightRelease>\<Esc>")
613+
call VerifyScreenDump(buf, 'Test_popupmenu_cmdline_1', {})
614+
615+
call StopVimInTerminal(buf)
616+
endfunc
617+
597618
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1480,
698700
/**/
699701
1479,
700702
/**/

0 commit comments

Comments
 (0)