Hi Bram and list,
I found a few issues to the display position of the pop-up menu with preview
window.
1) Popup menu often drawing over the preview window.
2) Sometimes, popup menu is displayed in the narrow room side.
Preparation before reproduction on Linux:
- start terminal emulator (e.g. PuTTY) and set to size 80x24
- goto vim/src/ directory.
$ cd (yourvimpath)/vim/src
- Prepare test_vimrc.
$ cat test_vimrc
filetype plugin indent on
syntax on
colorscheme desert
set ttm=50
Step to reproduce for case 1:
- Start Vim
$ vim -Nu test_vimrc screen.c
- Type the following command.
:new|wincmd w|norm!2}
- Enter insert mode and start omni completion.
iex_<C-X><C-O>
Expected behavior:
- Popup menu doesn't drawing over the preview window.
See attached file: case1_expect.png
(We can see the preview window after type <Esc>)
Actual behavior:
- Popup menu drawing over the preview window.
See attached file: case1_actual.png
Step to reproduce for case 2:
- Start Vim
$ vim -Nu test_vimrc screen.c
- Type the following command.
:call feedkeys(":pedit +resize\\ 5\<CR>2}2\<C-E>")
- Enter insert mode and start omni completion.
iex_<C-X><C-O>
Expected behavior:
- popup menu is displayed in the above (narrow room side).
See attached file: case2_expect.png
Actual behavior:
- Popup menu is displayed in the below (wide room side).
See attached file: case2_actual.png
I wrote a patch.
Please check attached file.
NOTE:
I removed the following comment.
Because other case always popup menu drawing over the status line.
So my patch follow it.
[popupmnu.c : roughly 90 line]
/* When the preview window is at the bottom stop just above it.
* Also avoid drawing over the status line so that it's clear there
* is a window boundary. */
--
Best regards,
Hirohito Higashi (a.k.a. h_east)
--
--
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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/popupmnu.c b/src/popupmnu.c
index b479b00..6a75686 100644
--- a/src/popupmnu.c
+++ b/src/popupmnu.c
@@ -54,18 +54,21 @@ pum_display(
int kind_width;
int extra_width;
int i;
- int top_clear;
int row;
int context_lines;
int col;
- int above_row = cmdline_row;
+ int above_row;
+ int below_row;
int redo_count = 0;
+ win_T *pvwin;
redo:
def_width = PUM_DEF_WIDTH;
max_width = 0;
kind_width = 0;
extra_width = 0;
+ above_row = 0;
+ below_row = cmdline_row;
/* Pretend the pum is already there to avoid that must_redraw is set when
* 'cuc' is on. */
@@ -76,18 +79,16 @@ redo:
row = curwin->w_wrow + W_WINROW(curwin);
#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
- if (firstwin->w_p_pvw)
- top_clear = firstwin->w_height;
- else
-#endif
- top_clear = 0;
-
-#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
- /* When the preview window is at the bottom stop just above it. Also
- * avoid drawing over the status line so that it's clear there is a window
- * boundary. */
- if (lastwin->w_p_pvw)
- above_row -= lastwin->w_height + lastwin->w_status_height + 1;
+ FOR_ALL_WINDOWS(pvwin)
+ if (pvwin->w_p_pvw)
+ break;
+ if (pvwin != NULL)
+ {
+ if (W_WINROW(pvwin) < W_WINROW(curwin))
+ above_row = W_WINROW(pvwin) + pvwin->w_height;
+ else if (W_WINROW(pvwin) > W_WINROW(curwin) + curwin->w_height)
+ below_row = W_WINROW(pvwin);
+ }
#endif
/*
@@ -102,8 +103,7 @@ redo:
/* Put the pum below "row" if possible. If there are few lines decide on
* where there is more room. */
- if (row + 2 >= above_row - pum_height
- && row > (above_row - top_clear) / 2)
+ if (row - above_row >= below_row - row)
{
/* pum above "row" */
@@ -141,8 +141,8 @@ redo:
+ curwin->w_cline_height - curwin->w_wrow;
pum_row = row + context_lines;
- if (size > above_row - pum_row)
- pum_height = above_row - pum_row;
+ if (size > below_row - pum_row)
+ pum_height = below_row - pum_row;
else
pum_height = size;
if (p_ph > 0 && pum_height > p_ph)
@@ -154,13 +154,11 @@ redo:
return;
#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
- /* If there is a preview window at the top avoid drawing over it. */
- if (firstwin->w_p_pvw
- && pum_row < firstwin->w_height
- && pum_height > firstwin->w_height + 4)
+ /* If there is a preview window at the above avoid drawing over it. */
+ if (pvwin != NULL && pum_row < above_row && pum_height > above_row)
{
- pum_row += firstwin->w_height;
- pum_height -= firstwin->w_height;
+ pum_row += above_row;
+ pum_height -= above_row;
}
#endif