]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1480: using popup menu may leave text in the command line v9.0.1480
authorLuuk van Baal <luukvbaal@gmail.com>
Sun, 23 Apr 2023 15:24:08 +0000 (16:24 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 23 Apr 2023 15:24:08 +0000 (16:24 +0100)
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 #12286)

src/popupmenu.c
src/testdir/dumps/Test_popupmenu_cmdline_1.dump [new file with mode: 0644]
src/testdir/test_menu.vim
src/version.c

index d713ed42836cd45ba6f7654d2bc4c2d7ae9c4c5d..36d3b9944e9b5b0fb2b8876469d402e8eb4cd937 100644 (file)
@@ -18,6 +18,7 @@ static int pum_selected;              // index of selected item or -1
 static int pum_first = 0;              // index of top item
 
 static int call_update_screen = FALSE;
+static int pum_in_cmdline = FALSE;
 
 static int pum_height;                 // nr of displayed pum items
 static int pum_width;                  // width of displayed pum items
@@ -1067,6 +1068,11 @@ pum_undisplay(void)
     pum_array = NULL;
     redraw_all_later(UPD_NOT_VALID);
     redraw_tabline = TRUE;
+    if (pum_in_cmdline)
+    {
+       clear_cmdline = TRUE;
+       pum_in_cmdline = FALSE;
+    }
     status_redraw_all();
 #if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)
     // hide any popup info window
@@ -1193,6 +1199,8 @@ pum_position_at_mouse(int min_width)
        pum_row = mouse_row + 1;
        if (pum_height > Rows - pum_row)
            pum_height = Rows - pum_row;
+       if (pum_row + pum_height > cmdline_row)
+           pum_in_cmdline = TRUE;
     }
     else
     {
diff --git a/src/testdir/dumps/Test_popupmenu_cmdline_1.dump b/src/testdir/dumps/Test_popupmenu_cmdline_1.dump
new file mode 100644 (file)
index 0000000..2ffcc46
--- /dev/null
@@ -0,0 +1,4 @@
+>a+0&#ffffff0|b|c|d|e| @69
+|a|b|c|d|e| @69
+|a|b|c|d|e| @69
+@57|1|,|1| @10|T|o|p| 
index 9929dd5e742c45371fa824b3feded1508df73871..22292289eef07b9ff2d027593fdea6d96e83d596 100644 (file)
@@ -594,4 +594,25 @@ func Test_unmenu_while_listing_menus()
   call StopVimInTerminal(buf)
 endfunc
 
+" Test for opening a menu drawn in the cmdline area
+func Test_popupmenu_cmdline()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+    set mousemodel=popup
+    menu PopUp.Test1 :<CR>
+    menu PopUp.Test2 :<CR>
+    menu PopUp.Test3 :<CR>
+    call setline(1, repeat(['abcde'], 5))
+  END
+  call writefile(lines, 'Xpopupcmdline', 'D')
+  let buf = RunVimInTerminal('-S Xpopupcmdline', {'rows': 4})
+
+  " cmdline area should be cleared when popupmenu that covered it is closed
+  call term_sendkeys(buf, "\<RightMouse>\<RightRelease>\<Esc>")
+  call VerifyScreenDump(buf, 'Test_popupmenu_cmdline_1', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index b8cc4d99bd2a7f026fce9445354c68f4e4a2dcfc..c17109c44ff10710f5d8a043faa80533514c1373 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1480,
 /**/
     1479,
 /**/