Executing the following script (e.g. by saving it into a file called
do.vim and executing "vim -u NONE -S do.vim") while in src directory
containing Vim sources should give an incorrectly placed pop-up menu.

#v+
set nocompatible
syntax on
filetype plugin indent on
e ex_docmd.c
set lines=76
set scrolloff=0
set nosplitbelow
1647
normal zt
1687
call feedkeys("o\<CR>if (ea.\<C-x>\<C-o>\<C-e>\<C-x>\<C-o>", 'n')
#v-

If you scroll through the entries by pressing <C-n> or <C-p> you will
notice that the part of the menu above the line containing the cursor is
only an image of a previously drawn menu which should have in fact been
cleared.

The attached patch fixes the problem.

The source of the problem:

The function ins_compl_show_pum() is called twice:
- once by ins_compl_next() which is called by ins_complete(),
- once by ins_complete() itself.

ins_compl_show_pum() calls pum_display() which uses the value of
curwin->w_wrow to calculate the position of the pop-up menu.
curwin->w_wrow is different in the two calls to ins_compl_show_pum().

NOTE:
- being able to reproduce the problem depends on the size of the screen
  (hence "set lines=76"),
- it is not possible to make the check for w_wrow in
  ins_compl_upd_pum(), as it would not work for gvim (setcursor()
  is called in ins_compl_next()).

-- 
Cheers,
Lech

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/edit.c b/src/edit.c
index 43058f8..e983369 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -4684,6 +4684,7 @@ ins_complete(c)
     int		startcol = 0;	    /* column where searched text starts */
     colnr_T	curs_col;	    /* cursor column */
     int		n;
+    int		saved_w_wrow;
 
     compl_direction = ins_compl_key2dir(c);
     if (!compl_started)
@@ -5067,6 +5068,7 @@ ins_complete(c)
     /*
      * Find next match (and following matches).
      */
+    saved_w_wrow = curwin->w_wrow;
     n = ins_compl_next(TRUE, ins_compl_key2count(c), ins_compl_use_match(c));
 
     /* may undisplay the popup menu */
@@ -5220,6 +5222,9 @@ ins_complete(c)
 	/* RedrawingDisabled may be set when invoked through complete(). */
 	n = RedrawingDisabled;
 	RedrawingDisabled = 0;
+	setcursor(); /* will update curwin->w_wrow */
+	if (saved_w_wrow != curwin->w_wrow)
+	    ins_compl_del_pum();
 	ins_compl_show_pum();
 	setcursor();
 	RedrawingDisabled = n;

Raspunde prin e-mail lui