diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-09-24 22:57:31 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-09-24 22:57:31 +0200 |
commit | 10476521f51d5902d191f2189307781fc48a3a16 (patch) | |
tree | f0c026fcf929c281b52ac75a735956c214126df4 | |
parent | 531be47ac5522807b265c6287021a01c9b895ac9 (diff) | |
download | vim-git-10476521f51d5902d191f2189307781fc48a3a16.tar.gz |
patch 8.2.1737: cursor line highlight in popup window is not always updatedv8.2.1737
Problem: Cursor line highlight in popup window is not always updated.
Solution: Check if the cursor has moved. (closes #7010)
-rw-r--r-- | src/popupwin.c | 5 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popupwin_win_execute_cursorline.dump | 14 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 33 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 50 insertions, 4 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index 301c38240..09ef0a34e 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -3711,6 +3711,11 @@ update_popups(void (*win_update)(win_T *wp)) // Draw the popup text, unless it's off screen. if (wp->w_winrow < screen_Rows && wp->w_wincol < screen_Columns) { + // May need to update the "cursorline" highlighting, which may also + // change "topline" + if (wp->w_popup_last_curline != wp->w_cursor.lnum) + popup_highlight_curline(wp); + win_update(wp); // move the cursor into the visible lines, otherwise executing diff --git a/src/testdir/dumps/Test_popupwin_win_execute_cursorline.dump b/src/testdir/dumps/Test_popupwin_win_execute_cursorline.dump new file mode 100644 index 000000000..76f85dc0c --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_win_execute_cursorline.dump @@ -0,0 +1,14 @@ +> +0&#ffffff0@74 +|~+0#4040ff13&| @73 +|~| @34|1+0#0000001#ffd7ff255|4| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35 +|~| @34|1+0#0000001#ffd7ff255|5| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35 +|~| @34|1+0#0000001#ffd7ff255|6| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35 +|~| @34|1+0#0000001#e0e0e08|7| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35 +|~| @34|1+0#0000001#ffd7ff255|8| +0#0000000#0000001| +0#4040ff13#ffffff0@35 +|~| @34|1+0#0000001#ffd7ff255|9| +0#0000000#0000001| +0#4040ff13#ffffff0@35 +|~| @34|2+0#0000001#ffd7ff255|0| +0#0000000#0000001| +0#4040ff13#ffffff0@35 +|~| @34|2+0#0000001#ffd7ff255|1| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35 +|~| @34|2+0#0000001#ffd7ff255@1| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35 +|~| @73 +|~| @73 +|:+0#0000000&| @55|0|,|0|-|1| @8|A|l@1| diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 79eaca7c1..84362a25a 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -1556,16 +1556,41 @@ func Test_popup_filter_normal_cmd() call delete('XtestPopupNormal') endfunc -" this tests that we don't get stuck with an error in "win_execute()" +" test that cursor line highlight is updated after using win_execute() func Test_popup_filter_win_execute() CheckScreendump let lines =<< trim END + let lines = range(1, &lines * 2)->map({_, v -> string(v)}) + let g:id = popup_create(lines, #{ + \ minheight: &lines - 5, + \ maxheight: &lines - 5, + \ cursorline: 1, + \ }) + redraw + END + call writefile(lines, 'XtestPopupWinExecute') + let buf = RunVimInTerminal('-S XtestPopupWinExecute', #{rows: 14}) + + call term_sendkeys(buf, ":call win_execute(g:id, ['normal 17Gzz'])\<CR>") + call term_sendkeys(buf, ":\<CR>") + + call VerifyScreenDump(buf, 'Test_popupwin_win_execute_cursorline', {}) + + call StopVimInTerminal(buf) + call delete('XtestPopupWinExecute') +endfunc + +" this tests that we don't get stuck with an error in "win_execute()" +func Test_popup_filter_win_execute_error() + CheckScreendump + + let lines =<< trim END let g:winid = popup_create('some text', {'filter': 'invalidfilter'}) call timer_start(0, {-> win_execute(g:winid, 'invalidCommand')}) END - call writefile(lines, 'XtestPopupWinExecute') - let buf = RunVimInTerminal('-S XtestPopupWinExecute', #{rows: 10, wait_for_ruler: 0}) + call writefile(lines, 'XtestPopupWinExecuteError') + let buf = RunVimInTerminal('-S XtestPopupWinExecuteError', #{rows: 10, wait_for_ruler: 0}) call WaitFor({-> term_getline(buf, 9) =~ 'Not an editor command: invalidCommand'}) call term_sendkeys(buf, "\<CR>") @@ -1577,7 +1602,7 @@ func Test_popup_filter_win_execute() call VerifyScreenDump(buf, 'Test_popupwin_win_execute', {}) call StopVimInTerminal(buf) - call delete('XtestPopupWinExecute') + call delete('XtestPopupWinExecuteError') endfunc func ShowDialog(key, result) diff --git a/src/version.c b/src/version.c index a2383c9e7..24e30ff1d 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1737, +/**/ 1736, /**/ 1735, |