0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.0.1161: popup menu drawing problem when resizing terminal

Problem:    Popup menu drawing problem when resizing terminal.
Solution:   Redraw after resizing also when a popup menu is visible. (Ozaki
            Kiichi, closes #2110)
This commit is contained in:
Bram Moolenaar 2017-09-29 22:42:33 +02:00
parent 816968defc
commit a5e6621aad
5 changed files with 214 additions and 173 deletions

View File

@ -64,7 +64,8 @@ pum_display(
win_T *pvwin;
#endif
redo:
do
{
def_width = PUM_DEF_WIDTH;
max_width = 0;
kind_width = 0;
@ -72,8 +73,8 @@ redo:
above_row = 0;
below_row = cmdline_row;
/* Pretend the pum is already there to avoid that must_redraw is set when
* 'cuc' is on. */
/* Pretend the pum is already there to avoid that must_redraw is set
* when 'cuc' is on. */
pum_array = (pumitem_T *)1;
validate_cursor_col();
pum_array = NULL;
@ -103,8 +104,8 @@ redo:
if (p_ph > 0 && pum_height > p_ph)
pum_height = p_ph;
/* Put the pum below "row" if possible. If there are few lines decide on
* where there is more room. */
/* Put the pum below "row" if possible. If there are few lines decide
* on where there is more room. */
if (row + 2 >= below_row - pum_height
&& row - above_row > (below_row - above_row) / 2)
{
@ -137,7 +138,8 @@ redo:
/* pum below "row" */
/* Leave two lines of context if possible */
if (curwin->w_cline_row + curwin->w_cline_height - curwin->w_wrow >= 3)
if (curwin->w_cline_row
+ curwin->w_cline_height - curwin->w_wrow >= 3)
context_lines = 3;
else
context_lines = curwin->w_cline_row
@ -259,11 +261,10 @@ redo:
pum_array = array;
pum_size = size;
/* Set selected item and redraw. If the window size changed need to redo
* the positioning. Limit this to two times, when there is not much
* room the window size will keep changing. */
if (pum_set_selected(selected, redo_count) && ++redo_count <= 2)
goto redo;
/* Set selected item and redraw. If the window size changed need to
* redo the positioning. Limit this to two times, when there is not
* much room the window size will keep changing. */
} while (pum_set_selected(selected, redo_count) && ++redo_count <= 2);
}
/*

View File

@ -3271,9 +3271,8 @@ set_shellsize(int width, int height, int mustset)
if (pum_visible())
{
redraw_later(NOT_VALID);
ins_compl_show_pum(); /* This includes the redraw. */
ins_compl_show_pum();
}
else
#endif
update_screen(NOT_VALID);
if (redrawing())

View File

@ -1,5 +1,10 @@
" Functions shared by several tests.
" Only load this script once.
if exists('*WaitFor')
finish
endif
" Get the name of the Python executable.
" Also keeps it in s:python.
func PythonProg()

View File

@ -1,5 +1,7 @@
" Test for completion menu
source shared.vim
let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
let g:setting = ''
@ -36,6 +38,7 @@ endfu
func! Test_popup_complete()
new
inoremap <f5> <c-r>=ListMonths()<cr>
set belloff=all
" <C-E> - select original typed text before the completion started
call feedkeys("aJu\<f5>\<down>\<c-e>\<esc>", 'tx')
@ -212,6 +215,7 @@ func! Test_popup_complete()
call feedkeys("aM\<f5>\<enter>\<esc>", 'tx')
call assert_equal(["March", "M", "March"], getline(1,4))
%d
set belloff&
endfu
@ -513,6 +517,7 @@ endfunc
func Test_completion_respect_bs_option()
new
set belloff=all
let li = ["aaa", "aaa12345", "aaaabcdef", "aaaABC"]
set bs=indent,eol
@ -528,6 +533,7 @@ func Test_completion_respect_bs_option()
call feedkeys("A\<C-X>\<C-N>\<C-P>\<BS>\<BS>\<BS>\<Esc>", "tx")
call assert_equal('', getline(1))
set belloff&
bw!
endfunc
@ -614,6 +620,7 @@ endfunc
func Test_complete_CTRLN_startofbuffer()
new
set belloff=all
call setline(1, [ 'organize(cupboard, 3, 2);',
\ 'prioritize(bureau, 8, 7);',
\ 'realize(bannister, 4, 4);',
@ -624,6 +631,33 @@ func Test_complete_CTRLN_startofbuffer()
\ 'railing.moralize(3,9);']
call feedkeys("qai\<c-n>\<c-n>.\<esc>3wdW\<cr>q3@a", 'tx')
call assert_equal(expected, getline(1,'$'))
set belloff&
bwipe!
endfunc
func Test_popup_and_window_resize()
if !has('terminal') || has('gui_running')
return
endif
let h = winheight(0)
if h < 15
return
endif
let g:buf = term_start([$VIMPROG, '--clean', '-c', 'set noswapfile'], {'term_rows': h / 3})
call term_sendkeys(g:buf, (h / 3 - 1)."o\<esc>G")
call term_sendkeys(g:buf, "i\<c-x>")
call term_wait(g:buf, 100)
call term_sendkeys(g:buf, "\<c-v>")
call term_wait(g:buf, 100)
call assert_match('^!\s*$', term_getline(g:buf, 1))
exe 'resize +' . (h - 1)
call term_wait(g:buf, 100)
redraw!
call WaitFor('"" == term_getline(g:buf, 1)')
call assert_equal('', term_getline(g:buf, 1))
sleep 100m
call WaitFor('"^!" =~ term_getline(g:buf, term_getcursor(g:buf)[0] + 1)')
call assert_match('^!\s*$', term_getline(g:buf, term_getcursor(g:buf)[0] + 1))
bwipe!
endfunc

View File

@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1161,
/**/
1160,
/**/