From 2bfe2018d652e4bbf444795b2544d7d2af4e7243 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 8 Oct 2020 18:52:18 -0400 Subject: [PATCH] vim-patch:8.2.0007: popup menu positioned wrong with folding in two tabs Problem: Popup menu positioned wrong with folding in two tabs. Solution: Update the cursor line height. (closes vim/vim#5353) https://github.com/vim/vim/commit/09dd2bb3364cc8fb5a8f2507bc2f4ceba481db3d --- src/nvim/move.c | 2 +- src/nvim/popupmnu.c | 1 + src/nvim/testdir/test_ins_complete.vim | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/nvim/move.c b/src/nvim/move.c index 4e9d42ed7b..e2a304efa5 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -641,7 +641,7 @@ void validate_virtcol_win(win_T *wp) /* * Validate curwin->w_cline_height only. */ -static void validate_cheight(void) +void validate_cheight(void) { check_cursor_moved(curwin); if (!(curwin->w_valid & VALID_CHEIGHT)) { diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index c712762bdf..3beada5bc9 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -226,6 +226,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, pum_above = false; // Leave two lines of context if possible + validate_cheight(); if (curwin->w_cline_row + curwin->w_cline_height - curwin->w_wrow >= 3) { context_lines = 3; } else { diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 1c275d5bd1..1339a9f25d 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -1,3 +1,5 @@ +source screendump.vim +source check.vim " Test for insert expansion func Test_ins_complete() @@ -338,3 +340,27 @@ func Test_compl_in_cmdwin() delcom GetInput set wildmenu& wildchar& endfunc + +func Test_pum_with_folds_two_tabs() + CheckScreendump + + let lines =<< trim END + set fdm=marker + call setline(1, ['" x {{{1', '" a some text']) + call setline(3, range(&lines)->map({_, val -> '" a' .. val})) + norm! zm + tab sp + call feedkeys('2Gzv', 'xt') + call feedkeys("0fa", 'xt') + END + + call writefile(lines, 'Xpumscript') + let buf = RunVimInTerminal('-S Xpumscript', #{rows: 10}) + call term_wait(buf, 100) + call term_sendkeys(buf, "a\") + call VerifyScreenDump(buf, 'Test_pum_with_folds_two_tabs', {}) + + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) + call delete('Xpumscript') +endfunc