summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-29 20:02:11 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-29 20:02:11 +0200
commit1fb0831a0e9f9b6f18f1f8b549191bd547d0e095 (patch)
treeb16ad034de403accb4d2cd0e27a1a4e73e7b4b99
parent57441d6fa0ba44be8dc16d6469a8659afc2f3b81 (diff)
downloadvim-git-1fb0831a0e9f9b6f18f1f8b549191bd547d0e095.tar.gz
patch 8.1.1936: not enough tests for text property popup windowv8.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.
-rw-r--r--src/popupwin.c39
-rw-r--r--src/testdir/dumps/Test_popup_textprop_07.dump10
-rw-r--r--src/testdir/dumps/Test_popup_textprop_corn_5.dump12
-rw-r--r--src/testdir/dumps/Test_popup_textprop_corn_6.dump12
-rw-r--r--src/testdir/dumps/Test_popup_textprop_off_1.dump12
-rw-r--r--src/testdir/dumps/Test_popup_textprop_off_2.dump12
-rw-r--r--src/testdir/test_popupwin_textprop.vim65
-rw-r--r--src/version.c2
8 files changed, 146 insertions, 18 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index 4dadee6ef..dfc0c89de 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -33,6 +33,7 @@ static void popup_adjust_position(win_T *wp);
/*
* 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,7 +46,7 @@ popup_options_one(dict_T *dict, char_u *key)
di = dict_find(dict, key, -1);
if (di == NULL)
- return 0;
+ return MAXCOL;
val = tv_get_string(&di->di_tv);
if (STRNCMP(val, "cursor", 6) != 0)
@@ -408,10 +409,10 @@ apply_move_options(win_T *wp, dict_T *d)
wp->w_maxheight = nr;
nr = popup_options_one(d, (char_u *)"line");
- if (nr > 0)
+ if (nr != MAXCOL)
wp->w_wantline = nr;
nr = popup_options_one(d, (char_u *)"col");
- if (nr > 0)
+ if (nr != MAXCOL)
wp->w_wantcol = nr;
di = dict_find(d, (char_u *)"fixed", -1);
@@ -1114,7 +1115,7 @@ popup_adjust_position(win_T *wp)
}
else
{
- if (wantline != 0 && (wp->w_popup_pos == POPPOS_TOPLEFT
+ if (wantline > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT
|| wp->w_popup_pos == POPPOS_TOPRIGHT))
{
wp->w_winrow = wantline - 1;
@@ -1124,8 +1125,8 @@ popup_adjust_position(win_T *wp)
if (wantcol == 0)
center_hor = TRUE;
- else if (wp->w_popup_pos == POPPOS_TOPLEFT
- || wp->w_popup_pos == POPPOS_BOTLEFT)
+ 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,21 +3588,23 @@ popup_hide_info(void)
int
popup_win_closed(win_T *win)
{
- win_T *wp;
+ int round;
+ win_T *wp;
+ win_T *next;
+ int ret = FALSE;
- 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)
+ for (round = 1; round <= 2; ++round)
+ for (wp = round == 1 ? first_popupwin : curtab->tp_first_popupwin;
+ wp != NULL; wp = next)
{
- popup_close_with_retval(wp, -1);
- return TRUE;
+ next = wp->w_next;
+ if (wp->w_popup_prop_win == win)
+ {
+ popup_close_with_retval(wp, -1);
+ ret = TRUE;
+ }
}
- return FALSE;
+ return ret;
}
/*
diff --git a/src/testdir/dumps/Test_popup_textprop_07.dump b/src/testdir/dumps/Test_popup_textprop_07.dump
new file mode 100644
index 000000000..2950ddc8c
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_textprop_07.dump
@@ -0,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|%|
diff --git a/src/testdir/dumps/Test_popup_textprop_corn_5.dump b/src/testdir/dumps/Test_popup_textprop_corn_5.dump
new file mode 100644
index 000000000..c79e8986a
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_textprop_corn_5.dump
@@ -0,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+0&#5fd7ff255|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
diff --git a/src/testdir/dumps/Test_popup_textprop_corn_6.dump b/src/testdir/dumps/Test_popup_textprop_corn_6.dump
new file mode 100644
index 000000000..7e6426c69
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_textprop_corn_6.dump
@@ -0,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|
diff --git a/src/testdir/dumps/Test_popup_textprop_off_1.dump b/src/testdir/dumps/Test_popup_textprop_off_1.dump
new file mode 100644
index 000000000..33f297822
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_textprop_off_1.dump
@@ -0,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+0&#5fd7ff255|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|%|
diff --git a/src/testdir/dumps/Test_popup_textprop_off_2.dump b/src/testdir/dumps/Test_popup_textprop_off_2.dump
new file mode 100644
index 000000000..1896c641c
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_textprop_off_2.dump
@@ -0,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|%|
diff --git a/src/testdir/test_popupwin_textprop.vim b/src/testdir/test_popupwin_textprop.vim
index 2a4eb2cd0..8a68f15d7 100644
--- a/src/testdir/test_popupwin_textprop.vim
+++ b/src/testdir/test_popupwin_textprop.vim
@@ -45,6 +45,9 @@ func Test_textprop_popup()
call term_sendkeys(buf, "k2dd")
call VerifyScreenDump(buf, 'Test_popup_textprop_06', {})
+ call term_sendkeys(buf, "4\<C-E>")
+ call VerifyScreenDump(buf, 'Test_popup_textprop_07', {})
+
" clean up
call StopVimInTerminal(buf)
call delete('XtestTextpropPopup')
@@ -99,10 +102,72 @@ func Test_textprop_popup_corners()
call term_sendkeys(buf, ":\<CR>")
call VerifyScreenDump(buf, 'Test_popup_textprop_corn_4', {})
+ call term_sendkeys(buf, ":vsplit foo\<CR>")
+ call VerifyScreenDump(buf, 'Test_popup_textprop_corn_5', {})
+
+ call term_sendkeys(buf, ":only!\<CR>")
+ 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)\<CR>")
+ call VerifyScreenDump(buf, 'Test_popup_textprop_off_2', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XtestTextpropPopupOffset')
+endfunc
+
" vim: shiftwidth=2 sts=2
diff --git a/src/version.c b/src/version.c
index f798b8f4b..2151002f4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1936,
+/**/
1935,
/**/
1934,