To: vim_dev@googlegroups.com Subject: Patch 8.1.1936 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1936 Problem: Not enough tests for text property popup window. Solution: Add a few more tests. Make negative offset work. Close all popups when window closes. Files: src/popupwin.c, src/testdir/test_popupwin_textprop.vim, src/testdir/dumps/Test_popup_textprop_07.dump, src/testdir/dumps/Test_popup_textprop_off_1.dump, src/testdir/dumps/Test_popup_textprop_off_2.dump, src/testdir/dumps/Test_popup_textprop_corn_5.dump, src/testdir/dumps/Test_popup_textprop_corn_6.dump *** ../vim-8.1.1935/src/popupwin.c 2019-08-28 22:17:56.295041456 +0200 --- src/popupwin.c 2019-08-29 19:56:36.352360093 +0200 *************** *** 33,38 **** --- 33,39 ---- /* * Get option value for "key", which is "line" or "col". * Handles "cursor+N" and "cursor-N". + * Returns MAXCOL if the entry is not present. */ static int popup_options_one(dict_T *dict, char_u *key) *************** *** 45,51 **** di = dict_find(dict, key, -1); if (di == NULL) ! return 0; val = tv_get_string(&di->di_tv); if (STRNCMP(val, "cursor", 6) != 0) --- 46,52 ---- di = dict_find(dict, key, -1); if (di == NULL) ! return MAXCOL; val = tv_get_string(&di->di_tv); if (STRNCMP(val, "cursor", 6) != 0) *************** *** 408,417 **** wp->w_maxheight = nr; nr = popup_options_one(d, (char_u *)"line"); ! if (nr > 0) wp->w_wantline = nr; nr = popup_options_one(d, (char_u *)"col"); ! if (nr > 0) wp->w_wantcol = nr; di = dict_find(d, (char_u *)"fixed", -1); --- 409,418 ---- wp->w_maxheight = nr; nr = popup_options_one(d, (char_u *)"line"); ! if (nr != MAXCOL) wp->w_wantline = nr; nr = popup_options_one(d, (char_u *)"col"); ! if (nr != MAXCOL) wp->w_wantcol = nr; di = dict_find(d, (char_u *)"fixed", -1); *************** *** 1114,1120 **** } else { ! if (wantline != 0 && (wp->w_popup_pos == POPPOS_TOPLEFT || wp->w_popup_pos == POPPOS_TOPRIGHT)) { wp->w_winrow = wantline - 1; --- 1115,1121 ---- } else { ! if (wantline > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT || wp->w_popup_pos == POPPOS_TOPRIGHT)) { wp->w_winrow = wantline - 1; *************** *** 1124,1131 **** if (wantcol == 0) center_hor = TRUE; ! else if (wp->w_popup_pos == POPPOS_TOPLEFT ! || wp->w_popup_pos == POPPOS_BOTLEFT) { wp->w_wincol = wantcol - 1; if (wp->w_wincol >= Columns - 3) --- 1125,1132 ---- if (wantcol == 0) center_hor = TRUE; ! else if (wantcol > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT ! || wp->w_popup_pos == POPPOS_BOTLEFT)) { wp->w_wincol = wantcol - 1; if (wp->w_wincol >= Columns - 3) *************** *** 3587,3607 **** int popup_win_closed(win_T *win) { ! win_T *wp; ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) ! if (wp->w_popup_prop_win == win) ! { ! popup_close_with_retval(wp, -1); ! return TRUE; ! } ! for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) ! if (wp->w_popup_prop_win == win) { ! popup_close_with_retval(wp, -1); ! return TRUE; } ! return FALSE; } /* --- 3588,3610 ---- int popup_win_closed(win_T *win) { ! int round; ! win_T *wp; ! win_T *next; ! int ret = FALSE; ! for (round = 1; round <= 2; ++round) ! for (wp = round == 1 ? first_popupwin : curtab->tp_first_popupwin; ! wp != NULL; wp = next) { ! next = wp->w_next; ! if (wp->w_popup_prop_win == win) ! { ! popup_close_with_retval(wp, -1); ! ret = TRUE; ! } } ! return ret; } /* *** ../vim-8.1.1935/src/testdir/test_popupwin_textprop.vim 2019-08-28 22:38:03.293572851 +0200 --- src/testdir/test_popupwin_textprop.vim 2019-08-29 19:44:11.008242202 +0200 *************** *** 45,50 **** --- 45,53 ---- call term_sendkeys(buf, "k2dd") call VerifyScreenDump(buf, 'Test_popup_textprop_06', {}) + call term_sendkeys(buf, "4\") + call VerifyScreenDump(buf, 'Test_popup_textprop_07', {}) + " clean up call StopVimInTerminal(buf) call delete('XtestTextpropPopup') *************** *** 99,108 **** --- 102,173 ---- call term_sendkeys(buf, ":\") call VerifyScreenDump(buf, 'Test_popup_textprop_corn_4', {}) + call term_sendkeys(buf, ":vsplit foo\") + call VerifyScreenDump(buf, 'Test_popup_textprop_corn_5', {}) + + call term_sendkeys(buf, ":only!\") + call VerifyScreenDump(buf, 'Test_popup_textprop_corn_6', {}) + " clean up call StopVimInTerminal(buf) call delete('XtestTextpropPopupCorners') endfunc + func Test_textprop_popup_offsets() + let lines =<< trim END + call setline(1, range(1, 100)) + call setline(50, 'now working with some longer text here') + 50 + normal zz + set scrolloff=0 + call prop_type_add('popupMarker', #{highlight: 'DiffAdd'}) + call prop_add(50, 23, #{ + \ length: 6, + \ type: 'popupMarker', + \ }) + let winid = popup_create('bottom left', #{ + \ pos: 'botleft', + \ line: -1, + \ col: 2, + \ textprop: 'popupMarker', + \ padding: [0,1,0,1], + \ }) + let winid = popup_create('bottom right', #{ + \ pos: 'botright', + \ line: -1, + \ col: -2, + \ textprop: 'popupMarker', + \ border: [], + \ padding: [0,1,0,1], + \ }) + let winid = popup_create('top left', #{ + \ pos: 'topleft', + \ line: 1, + \ col: 2, + \ textprop: 'popupMarker', + \ border: [], + \ padding: [0,1,0,1], + \ }) + let winid = popup_create('top right', #{ + \ pos: 'topright', + \ line: 1, + \ col: -2, + \ textprop: 'popupMarker', + \ padding: [0,1,0,1], + \ }) + END + call writefile(lines, 'XtestTextpropPopupOffset') + let buf = RunVimInTerminal('-S XtestTextpropPopupOffset', #{rows: 12}) + call VerifyScreenDump(buf, 'Test_popup_textprop_off_1', {}) + + " test that removing the text property closes the popups + call term_sendkeys(buf, ":call prop_clear(50)\") + call VerifyScreenDump(buf, 'Test_popup_textprop_off_2', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('XtestTextpropPopupOffset') + endfunc + " vim: shiftwidth=2 sts=2 *** ../vim-8.1.1935/src/testdir/dumps/Test_popup_textprop_07.dump 2019-08-29 20:01:04.310970014 +0200 --- src/testdir/dumps/Test_popup_textprop_07.dump 2019-08-29 19:24:11.970742296 +0200 *************** *** 0 **** --- 1,10 ---- + >5+0&#ffffff0|1| @72 + |5|2| @72 + |5|3| @72 + |5|4| @72 + |5@1| @72 + |5|6| @72 + |5|7| @72 + |5|8| @72 + |5|9| @72 + @57|5|0|,|1| @9|5|4|%| *** ../vim-8.1.1935/src/testdir/dumps/Test_popup_textprop_off_1.dump 2019-08-29 20:01:04.314969991 +0200 --- src/testdir/dumps/Test_popup_textprop_off_1.dump 2019-08-29 19:36:28.366683054 +0200 *************** *** 0 **** --- 1,12 ---- + |4+0&#ffffff0|5| @72 + |4|6| @1|╔+0#0000001#ffd7ff255|═@13|╗| +0#0000000#ffffff0@54 + |4|7| @1|║+0#0000001#ffd7ff255| |b|o|t@1|o|m| |r|i|g|h|t| |║| +0#0000000#ffffff0@54 + |4|8| @1|╚+0#0000001#ffd7ff255|═@13|╝| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255|b|o|t@1|o|m| |l|e|f|t| | +0#0000000#ffffff0@31 + |4|9| @72 + >n|o|w| |w|o|r|k|i|n|g| |w|i|t|h| |s|o|m|e| |l+0fd7ff255|o|n|g|e|r| +0&#ffffff0|t|e|x|t| |h|e|r|e| @36 + |5|1| @72 + |5|2| @6| +0#0000001#ffd7ff255|t|o|p| |r|i|g|h|t| | +0#0000000#ffffff0@9|╔+0#0000001#ffd7ff255|═@9|╗| +0#0000000#ffffff0@32 + |5|3| @27|║+0#0000001#ffd7ff255| |t|o|p| |l|e|f|t| |║| +0#0000000#ffffff0@32 + |5|4| @27|╚+0#0000001#ffd7ff255|═@9|╝| +0#0000000#ffffff0@32 + |5@1| @72 + @57|5|0|,|1| @9|4|9|%| *** ../vim-8.1.1935/src/testdir/dumps/Test_popup_textprop_off_2.dump 2019-08-29 20:01:04.318969973 +0200 --- src/testdir/dumps/Test_popup_textprop_off_2.dump 2019-08-29 19:39:58.653568487 +0200 *************** *** 0 **** --- 1,12 ---- + |4+0&#ffffff0|5| @72 + |4|6| @72 + |4|7| @72 + |4|8| @72 + |4|9| @72 + >n|o|w| |w|o|r|k|i|n|g| |w|i|t|h| |s|o|m|e| |l|o|n|g|e|r| |t|e|x|t| |h|e|r|e| @36 + |5|1| @72 + |5|2| @72 + |5|3| @72 + |5|4| @72 + |5@1| @72 + |:|c|a|l@1| |p|r|o|p|_|c|l|e|a|r|(|5|0|)| @36|5|0|,|1| @9|4|9|%| *** ../vim-8.1.1935/src/testdir/dumps/Test_popup_textprop_corn_5.dump 2019-08-29 20:01:04.318969973 +0200 --- src/testdir/dumps/Test_popup_textprop_corn_5.dump 2019-08-29 19:57:17.540146299 +0200 *************** *** 0 **** --- 1,12 ---- + > +0&#ffffff0@36||+1&&|4+0&&|5| @34 + |~+0#4040ff13&| @35||+1#0000000&|4+0&&|6| @34 + |~+0#4040ff13&| @35||+1#0000000&|4+0&&|7|╔+0#0000001#ffd7ff255|═@13|╗| +0#0000000#ffffff0@18 + |~+0#4040ff13&| @35||+1#0000000&|4+0&&|8|║+0#0000001#ffd7ff255| |b|o|t@1|o|m| |r|i|g|h|t| |║| +0#0000000#ffffff0@18 + |~+0#4040ff13&| @35||+1#0000000&|4+0&&|9|╚+0#0000001#ffd7ff255|═@13|╝| +0#0000000#ffffff0@5| +0#0000001#ffd7ff255|b|o|t@1|o|m| |l|e|f|t| + |~+0#4040ff13#ffffff0| @35||+1#0000000&|w+0&&|o|r|k|i|n|g| |w|i|t|h| |s|o|m|e| |l+0fd7ff255|o|n|g|e|r| +0&#ffffff0|t|e|x|t| |h|e|r|e| @2 + |~+0#4040ff13&| @35||+1#0000000&|5+0&&|1| @4| +0#0000001#ffd7ff255|t|o|p| |r|i|g|h|t| | +0#0000000#ffffff0@5|╔+0#0000001#ffd7ff255|═@9|╗| +0#0000000#ffffff0 + |~+0#4040ff13&| @35||+1#0000000&|5+0&&|2| @21|║+0#0000001#ffd7ff255| |t|o|p| |l|e|f|t| |║| +0#0000000#ffffff0 + |~+0#4040ff13&| @35||+1#0000000&|5+0&&|3| @21|╚+0#0000001#ffd7ff255|═@9|╝| +0#0000000#ffffff0 + |~+0#4040ff13&| @35||+1#0000000&|5+0&&|4| @34 + |f+3&&|o@1| @15|0|,|0|-|1| @9|A|l@1| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @5|4|6|,|1| @10|4|8|% + |"+0&&|f|o@1|"| |[|N|e|w| |F|i|l|e|]| @58 *** ../vim-8.1.1935/src/testdir/dumps/Test_popup_textprop_corn_6.dump 2019-08-29 20:01:04.322969952 +0200 --- src/testdir/dumps/Test_popup_textprop_corn_6.dump 2019-08-29 19:57:18.596140819 +0200 *************** *** 0 **** --- 1,12 ---- + > +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |:+0#0000000&|o|n|l|y|!| @50|0|,|0|-|1| @8|A|l@1| *** ../vim-8.1.1935/src/version.c 2019-08-28 22:38:03.293572851 +0200 --- src/version.c 2019-08-29 19:46:16.111587823 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1936, /**/ -- hundred-and-one symptoms of being an internet addict: 130. You can't get out of your desk even if it's time to eat or time to go to the bathroom. /// 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 ///