To: vim_dev@googlegroups.com Subject: Patch 8.1.2288 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2288 Problem: Not using all space when popup with "topleft" flips to above. Solution: Recompute the height when a popup flips from below to above. (closes #5151) Files: src/popupwin.c, src/testdir/test_popupwin.vim, src/testdir/dumps/Test_popupwin_nospace.dump *** ../vim-8.1.2287/src/popupwin.c 2019-11-10 15:16:51.522429491 +0100 --- src/popupwin.c 2019-11-10 17:50:41.134108574 +0100 *************** *** 1102,1107 **** --- 1102,1108 ---- int left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3]; int extra_height = top_extra + bot_extra; int extra_width = left_extra + right_extra; + int w_height_before_limit; int org_winrow = wp->w_winrow; int org_wincol = wp->w_wincol; int org_width = wp->w_width; *************** *** 1399,1404 **** --- 1400,1406 ---- wp->w_height = wp->w_minheight; if (wp->w_maxheight > 0 && wp->w_height > wp->w_maxheight) wp->w_height = wp->w_maxheight; + w_height_before_limit = wp->w_height; if (wp->w_height > Rows - wp->w_winrow) wp->w_height = Rows - wp->w_winrow; if (wp->w_height != org_height) *************** *** 1434,1442 **** if (wantline + (wp->w_height + extra_height) - 1 > Rows && wantline * 2 > Rows && (wp->w_popup_flags & POPF_POSINVERT)) // top aligned and not enough space below but there is space above: ! // make bottom aligned wp->w_winrow = wantline - 2 - wp->w_height - extra_height; else wp->w_winrow = wantline - 1; } --- 1436,1452 ---- if (wantline + (wp->w_height + extra_height) - 1 > Rows && wantline * 2 > Rows && (wp->w_popup_flags & POPF_POSINVERT)) + { // top aligned and not enough space below but there is space above: ! // make bottom aligned and recompute the height ! wp->w_height = w_height_before_limit; wp->w_winrow = wantline - 2 - wp->w_height - extra_height; + if (wp->w_winrow < 0) + { + wp->w_height += wp->w_winrow; + wp->w_winrow = 0; + } + } else wp->w_winrow = wantline - 1; } *** ../vim-8.1.2287/src/testdir/test_popupwin.vim 2019-11-10 17:22:26.948204460 +0100 --- src/testdir/test_popupwin.vim 2019-11-10 17:45:41.999253141 +0100 *************** *** 389,397 **** \ border: [], \ }) " cursor in a line in top half, using "topleft" with popup that ! " doesn't fit and "posinvert" set: flips to below. normal 8G44|r% ! let winid1 = popup_create(['one', 'two', 'tee'], #{ \ line: 'cursor+1', \ col: 'cursor', \ pos: 'topleft', --- 389,397 ---- \ border: [], \ }) " cursor in a line in top half, using "topleft" with popup that ! " doesn't fit and "posinvert" set: flips to above. normal 8G44|r% ! let winid1 = popup_create(['one', 'two', 'tee', 'fou', 'fiv'], #{ \ line: 'cursor+1', \ col: 'cursor', \ pos: 'topleft', *** ../vim-8.1.2287/src/testdir/dumps/Test_popupwin_nospace.dump 2019-11-06 19:25:04.857696936 +0100 --- src/testdir/dumps/Test_popupwin_nospace.dump 2019-11-10 17:45:49.707224155 +0100 *************** *** 1,9 **** ! |-+0&#ffffff0|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@8|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@32| @14 ! |-|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|a@2|║|-+0#0000000#ffffff0@32| @14 ! |-|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|b@2|║|-+0#0000000#ffffff0@15|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@11| @14 ! |-|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|c@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@11| @14 ! |-|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|d@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1>*|-@8| @14 ! |-@14|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|e@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@4| @14 |-@14|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@15|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|a@2|║|-+0#0000000#ffffff0@4| @14 |-@14|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|*|-@5|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|b@2|║|-+0#0000000#ffffff0@4| @14 |-@14|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@8|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|c@2|║|-+0#0000000#ffffff0@4| @14 --- 1,9 ---- ! |-+0&#ffffff0|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@8|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@15|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@11| @14 ! |-|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|a@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@11| @14 ! |-|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|b@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@11| @14 ! |-|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|c@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@11| @14 ! |-|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|d@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|f|o|u|║|-+0#0000000#ffffff0@1>*|-@8| @14 ! |-@14|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|e@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|f|i|v|║|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@4| @14 |-@14|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@15|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|a@2|║|-+0#0000000#ffffff0@4| @14 |-@14|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|*|-@5|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|b@2|║|-+0#0000000#ffffff0@4| @14 |-@14|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@8|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|c@2|║|-+0#0000000#ffffff0@4| @14 *** ../vim-8.1.2287/src/version.c 2019-11-10 17:22:26.948204460 +0100 --- src/version.c 2019-11-10 17:51:14.173980156 +0100 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 2288, /**/ -- hundred-and-one symptoms of being an internet addict: 57. You begin to wonder how on earth your service provider is allowed to call 200 hours per month "unlimited." /// 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 ///