To: vim_dev@googlegroups.com Subject: Patch 8.1.2210 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2210 Problem: Using negative offset for popup_create() does not work. Solution: Use -1 instead of zero. (closes #5111) Files: src/popupwin.c, src/popupwin.vim, src/testdir/test_popupwin.vim, src/testdir/dumps/Test_popupwin_corners.dump *** ../vim-8.1.2209/src/popupwin.c 2019-10-20 18:45:59.716195126 +0200 --- src/popupwin.c 2019-10-24 19:21:14.328032634 +0200 *************** *** 71,78 **** else // "col" n = screen_screencol() + 1 + n; ! if (n < 1) ! n = 1; return n; } --- 71,79 ---- else // "col" n = screen_screencol() + 1 + n; ! // Zero means "not set", use -1 instead. ! if (n == 0) ! n = -1; return n; } *************** *** 222,228 **** { drag_start_row = mouse_row; drag_start_col = mouse_col; ! if (wp->w_wantline == 0) drag_start_wantline = wp->w_winrow + 1; else drag_start_wantline = wp->w_wantline; --- 223,229 ---- { drag_start_row = mouse_row; drag_start_col = mouse_col; ! if (wp->w_wantline <= 0) drag_start_wantline = wp->w_winrow + 1; else drag_start_wantline = wp->w_wantline; *************** *** 1081,1087 **** --- 1082,1090 ---- int org_leftoff = wp->w_popup_leftoff; int minwidth; int wantline = wp->w_wantline; // adjusted for textprop + int use_wantline = wantline != 0; int wantcol = wp->w_wantcol; // adjusted for textprop + int use_wantcol = wantcol != 0; wp->w_winrow = 0; wp->w_wincol = 0; *************** *** 1097,1102 **** --- 1100,1110 ---- // If no line was specified default to vertical centering. if (wantline == 0) center_vert = TRUE; + else if (wantline < 0) + // If "wantline" is negative it actually means zero. + wantline = 0; + if (wantcol < 0) + wantcol = 0; if (wp->w_popup_prop_type > 0 && win_valid(wp->w_popup_prop_win)) { *************** *** 1161,1167 **** } else { ! if (wantline > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT || wp->w_popup_pos == POPPOS_TOPRIGHT)) { wp->w_winrow = wantline - 1; --- 1169,1175 ---- } else { ! if (use_wantline && (wp->w_popup_pos == POPPOS_TOPLEFT || wp->w_popup_pos == POPPOS_TOPRIGHT)) { wp->w_winrow = wantline - 1; *************** *** 1169,1175 **** wp->w_winrow = Rows - 1; } ! if (wantcol == 0) center_hor = TRUE; else if (wantcol > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT || wp->w_popup_pos == POPPOS_BOTLEFT)) --- 1177,1183 ---- wp->w_winrow = Rows - 1; } ! if (!use_wantcol) center_hor = TRUE; else if (wantcol > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT || wp->w_popup_pos == POPPOS_BOTLEFT)) *************** *** 1372,1379 **** // bottom aligned: may move down wp->w_winrow = wantline - (wp->w_height + extra_height); else ! // not enough space, make top aligned ! wp->w_winrow = wantline + 1; } if (wp->w_winrow >= Rows) wp->w_winrow = Rows - 1; --- 1380,1387 ---- // bottom aligned: may move down wp->w_winrow = wantline - (wp->w_height + extra_height); else ! // Not enough space, make top aligned. ! wp->w_winrow = (wantline < 0 ? 0 : wantline) + 1; } if (wp->w_winrow >= Rows) wp->w_winrow = Rows - 1; *** ../vim-8.1.2209/src/testdir/test_popupwin.vim 2019-10-20 18:45:59.716195126 +0200 --- src/testdir/test_popupwin.vim 2019-10-24 19:09:38.202201451 +0200 *************** *** 278,284 **** \ border: [], \ padding: [], \ }) ! normal 25|r@ let winid1 = popup_create(['First', 'SeconD'], #{ \ line: 'cursor+1', \ col: 'cursor', --- 278,284 ---- \ border: [], \ padding: [], \ }) ! normal 24|r@ let winid1 = popup_create(['First', 'SeconD'], #{ \ line: 'cursor+1', \ col: 'cursor', *************** *** 286,292 **** \ border: [], \ padding: [], \ }) ! normal 9G29|r% let winid1 = popup_create(['fiRSt', 'seCOnd'], #{ \ line: 'cursor-1', \ col: 'cursor', --- 286,292 ---- \ border: [], \ padding: [], \ }) ! normal 9G27|r% let winid1 = popup_create(['fiRSt', 'seCOnd'], #{ \ line: 'cursor-1', \ col: 'cursor', *************** *** 294,300 **** \ border: [], \ padding: [], \ }) ! normal 51|r& let winid1 = popup_create(['FIrsT', 'SEcoND'], #{ \ line: 'cursor-1', \ col: 'cursor', --- 294,300 ---- \ border: [], \ padding: [], \ }) ! normal 48|r& let winid1 = popup_create(['FIrsT', 'SEcoND'], #{ \ line: 'cursor-1', \ col: 'cursor', *************** *** 302,307 **** --- 302,315 ---- \ border: [], \ padding: [], \ }) + normal 1G51|r* + let winid1 = popup_create(['one', 'two'], #{ + \ line: 'cursor-1', + \ col: 'cursor', + \ pos: 'botleft', + \ border: [], + \ padding: [], + \ }) END call writefile(lines, 'XtestPopupCorners') let buf = RunVimInTerminal('-S XtestPopupCorners', #{rows: 12}) *** ../vim-8.1.2209/src/testdir/dumps/Test_popupwin_corners.dump 2019-06-02 15:34:15.458696427 +0200 --- src/testdir/dumps/Test_popupwin_corners.dump 2019-10-24 19:16:06.184846687 +0200 *************** *** 1,12 **** ! |-+0&#ffffff0@59| @14 ! |-@1|#|-@20|@|-@34| @14 ! |-@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@2|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@2|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@2|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@8| @14 ! |-@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@8| @14 ! |-@1|║+0#0000001#ffd7ff255| |f|i|r|s|t| @1|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |F|i|r|s|t| @1|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |f|i|R|S|t| @1|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |F|I|r|s|T| @1|║|-+0#0000000#ffffff0@8| @14 ! |-@1|║+0#0000001#ffd7ff255| |s|e|c|o|n|d| |║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |S|e|c|o|n|D| |║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |s|e|C|O|n|d| |║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |S|E|c|o|N|D| |║|-+0#0000000#ffffff0@8| @14 ! |-@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@8| @14 ! |-@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@2|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@2|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@2|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@8| @14 ! |-@27|%|-@20>&|-@8| @14 |-@59| @14 |-@59| @14 ! @57|9|,|5|1| @9|T|o|p| --- 1,12 ---- ! |-+0&#ffffff0@49>*|-@8| @14 ! |-@1|#|-@19|@|-@25|╔+0#0000001#ffd7ff255|═@4|╗|-+0#0000000#ffffff0@2| @14 ! |-@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @4|║|-+0#0000000#ffffff0@2| @14 ! |-@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |o|n|e| |║|-+0#0000000#ffffff0@2| @14 ! |-@1|║+0#0000001#ffd7ff255| |f|i|r|s|t| @1|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |F|i|r|s|t| @1|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |f|i|R|S|t| @1|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |F|I|r|s|T| @1|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |t|w|o| |║|-+0#0000000#ffffff0@2| @14 ! |-@1|║+0#0000001#ffd7ff255| |s|e|c|o|n|d| |║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |S|e|c|o|n|D| |║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |s|e|C|O|n|d| |║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |S|E|c|o|N|D| |║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @4|║|-+0#0000000#ffffff0@2| @14 ! |-@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@4|╝|-+0#0000000#ffffff0@2| @14 ! |-@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@11| @14 ! |-@25|%|-@19|&|-@11| @14 |-@59| @14 |-@59| @14 ! @57|1|,|5|1| @9|T|o|p| *** ../vim-8.1.2209/src/version.c 2019-10-24 17:48:44.872831126 +0200 --- src/version.c 2019-10-24 18:30:47.118677682 +0200 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 2210, /**/ -- Back off man, I'm a scientist. -- Peter, Ghostbusters /// 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 ///