To: vim_dev@googlegroups.com Subject: Patch 8.1.1945 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1945 Problem: Popup window "firstline" cannot be reset. Solution: Allow for setting "firstline" to zero. Fix that the text jumps to the top when using win_execute(). (closes #4876) Files: src/popupwin.c, src/testdir/test_popupwin.vim, src/testdir/dumps/Test_popupwin_scroll_5.dump, src/testdir/dumps/Test_popupwin_scroll_6.dump *** ../vim-8.1.1944/src/popupwin.c 2019-08-29 20:01:42.582771699 +0200 --- src/popupwin.c 2019-08-30 17:10:45.697609808 +0200 *************** *** 610,617 **** di = dict_find(dict, (char_u *)"firstline", -1); if (di != NULL) wp->w_firstline = dict_get_number(dict, (char_u *)"firstline"); ! if (wp->w_firstline < 1) ! wp->w_firstline = 1; di = dict_find(dict, (char_u *)"scrollbar", -1); if (di != NULL) --- 610,617 ---- di = dict_find(dict, (char_u *)"firstline", -1); if (di != NULL) wp->w_firstline = dict_get_number(dict, (char_u *)"firstline"); ! if (wp->w_firstline < 0) ! wp->w_firstline = 0; di = dict_find(dict, (char_u *)"scrollbar", -1); if (di != NULL) *************** *** 3192,3199 **** --- 3192,3208 ---- // Draw the popup text, unless it's off screen. if (wp->w_winrow < screen_Rows && wp->w_wincol < screen_Columns) + { win_update(wp); + // move the cursor into the visible lines, otherwise executing + // commands with win_execute() may cause the text to jump. + if (wp->w_cursor.lnum < wp->w_topline) + wp->w_cursor.lnum = wp->w_topline; + else if (wp->w_cursor.lnum >= wp->w_botline) + wp->w_cursor.lnum = wp->w_botline - 1; + } + wp->w_winrow -= top_off; wp->w_wincol -= left_extra; *** ../vim-8.1.1944/src/testdir/test_popupwin.vim 2019-08-24 18:23:06.423390821 +0200 --- src/testdir/test_popupwin.vim 2019-08-30 17:31:11.333251901 +0200 *************** *** 333,338 **** --- 333,368 ---- call assert_equal(3, popup_getoptions(winid).firstline) call popup_setoptions(winid, #{firstline: 1}) call assert_equal(1, popup_getoptions(winid).firstline) + call popup_close(winid) + + let winid = popup_create(['xxx']->repeat(50), #{ + \ maxheight: 3, + \ firstline: 11, + \ }) + redraw + call assert_equal(11, popup_getoptions(winid).firstline) + call assert_equal(11, popup_getpos(winid).firstline) + + " Normal command changes what is displayed but not "firstline" + call win_execute(winid, "normal! \") + call assert_equal(11, popup_getoptions(winid).firstline) + call assert_equal(10, popup_getpos(winid).firstline) + + " Making some property change applies "firstline" again + call popup_setoptions(winid, #{line: 4}) + call assert_equal(11, popup_getoptions(winid).firstline) + call assert_equal(11, popup_getpos(winid).firstline) + + " Remove "firstline" property and scroll + call popup_setoptions(winid, #{firstline: 0}) + call win_execute(winid, "normal! \") + call assert_equal(0, popup_getoptions(winid).firstline) + call assert_equal(10, popup_getpos(winid).firstline) + + " Making some property change has no side effect + call popup_setoptions(winid, #{line: 3}) + call assert_equal(0, popup_getoptions(winid).firstline) + call assert_equal(10, popup_getpos(winid).firstline) call popup_close(winid) endfunc *************** *** 1678,1684 **** call term_sendkeys(buf, ":\") call VerifyScreenDump(buf, 'Test_popupwin_scroll_4', {}) ! call term_sendkeys(buf, ":call popup_setoptions(winid, #{scrollbarhighlight: 'ScrollBar', thumbhighlight: 'ScrollThumb'})\") call term_sendkeys(buf, ":call ScrollUp()\") call VerifyScreenDump(buf, 'Test_popupwin_scroll_5', {}) --- 1708,1714 ---- call term_sendkeys(buf, ":\") call VerifyScreenDump(buf, 'Test_popupwin_scroll_4', {}) ! call term_sendkeys(buf, ":call popup_setoptions(winid, #{scrollbarhighlight: 'ScrollBar', thumbhighlight: 'ScrollThumb', firstline: 5})\") call term_sendkeys(buf, ":call ScrollUp()\") call VerifyScreenDump(buf, 'Test_popupwin_scroll_5', {}) *** ../vim-8.1.1944/src/testdir/dumps/Test_popupwin_scroll_5.dump 2019-06-26 05:13:51.799753098 +0200 --- src/testdir/dumps/Test_popupwin_scroll_5.dump 2019-08-30 17:17:17.011088458 +0200 *************** *** 1,10 **** >1+0&#ffffff0| @73 |2| @73 |3| @73 ! |4| @31|o+0#0000001#ffd7ff255|n|e| @4| +0#0000000#4040ff13| +0&#ffffff0@32 ! |5| @31|t+0#0000001#ffd7ff255|w|o| @4| +0#0000000#4040ff13| +0&#ffffff0@32 ! |6| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#ff404010| +0&#ffffff0@32 ! |7| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#ff404010| +0&#ffffff0@32 |8| @73 |9| @73 |:|c|a|l@1| |S|c|r|o|l@1|U|p|(|)| @40|1|,|1| @10|T|o|p| --- 1,10 ---- >1+0&#ffffff0| @73 |2| @73 |3| @73 ! |4| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#ff404010| +0&#ffffff0@32 ! |5| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32 ! |6| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#4040ff13| +0&#ffffff0@32 ! |7| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#ff404010| +0&#ffffff0@32 |8| @73 |9| @73 |:|c|a|l@1| |S|c|r|o|l@1|U|p|(|)| @40|1|,|1| @10|T|o|p| *** ../vim-8.1.1944/src/testdir/dumps/Test_popupwin_scroll_6.dump 2019-06-26 05:13:51.799753098 +0200 --- src/testdir/dumps/Test_popupwin_scroll_6.dump 2019-08-30 17:17:18.067081770 +0200 *************** *** 1,10 **** >1+0&#ffffff0| @73 |2| @73 |3| @73 ! |4| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#ff404010| +0&#ffffff0@32 ! |5| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#4040ff13| +0&#ffffff0@32 ! |6| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32 ! |7| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#ff404010| +0&#ffffff0@32 |8| @73 |9| @73 |:|c|a|l@1| |S|c|r|o|l@1|D|o|w|n|(|)| @38|1|,|1| @10|T|o|p| --- 1,10 ---- >1+0&#ffffff0| @73 |2| @73 |3| @73 ! |4| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#ff404010| +0&#ffffff0@32 ! |5| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#ff404010| +0&#ffffff0@32 ! |6| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#4040ff13| +0&#ffffff0@32 ! |7| @31|n+0#0000001#ffd7ff255|i|n|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32 |8| @73 |9| @73 |:|c|a|l@1| |S|c|r|o|l@1|D|o|w|n|(|)| @38|1|,|1| @10|T|o|p| *** ../vim-8.1.1944/src/version.c 2019-08-30 16:29:56.211117894 +0200 --- src/version.c 2019-08-30 17:33:17.708371927 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1945, /**/ -- hundred-and-one symptoms of being an internet addict: 140. You'd rather catch a score on the web than watch the game as it is being played on tv. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///