summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-30 22:07:36 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-30 22:07:36 +0200
commit402502d0e4019ca97330eff40b9fb13736304896 (patch)
tree8990bb22a50b9375823c6f1f8ebd85bec48aae8f
parentac1f1bc222b7de3cb2d3f1f2aa076f11c75e69de (diff)
patch 8.1.1430: popup window option "wrap" not supportedv8.1.1430
Problem: Popup window option "wrap" not supported. Solution: Implement it.
-rw-r--r--src/popupwin.c14
-rw-r--r--src/testdir/dumps/Test_popupwin_nowrap.dump10
-rw-r--r--src/testdir/dumps/Test_popupwin_wrap.dump10
-rw-r--r--src/testdir/test_popupwin.vim97
-rw-r--r--src/version.c2
5 files changed, 109 insertions, 24 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index a5c14b0f74..ef4609add9 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -109,10 +109,9 @@ get_pos_options(win_T *wp, dict_T *dict)
static void
apply_options(win_T *wp, buf_T *buf UNUSED, dict_T *dict, int atcursor)
{
-#if defined(FEAT_TIMERS)
- int nr;
-#endif
- char_u *str;
+ int nr;
+ char_u *str;
+ dictitem_T *di;
wp->w_minwidth = dict_get_number(dict, (char_u *)"minwidth");
wp->w_minheight = dict_get_number(dict, (char_u *)"minheight");
@@ -158,10 +157,17 @@ apply_options(win_T *wp, buf_T *buf UNUSED, dict_T *dict, int atcursor)
}
#endif
+ // Option values resulting in setting an option.
str = dict_get_string(dict, (char_u *)"highlight", TRUE);
if (str != NULL)
set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
str, OPT_FREE|OPT_LOCAL, 0);
+ di = dict_find(dict, (char_u *)"wrap", -1);
+ if (di != NULL)
+ {
+ nr = dict_get_number(dict, (char_u *)"wrap");
+ wp->w_p_wrap = nr != 0;
+ }
}
/*
diff --git a/src/testdir/dumps/Test_popupwin_nowrap.dump b/src/testdir/dumps/Test_popupwin_nowrap.dump
new file mode 100644
index 0000000000..6088d3ba0a
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_nowrap.dump
@@ -0,0 +1,10 @@
+>1+0&#ffffff0| @73
+|2| @73
+|3| @17|a+0#0000001#ffd7ff255| |l|o|n|g| |l|i|n| +0#0000000#ffffff0@45
+|4| @73
+|5| @73
+|6| @73
+|7| @73
+|8| @73
+|9| @73
+@57|1|,|1| @10|T|o|p|
diff --git a/src/testdir/dumps/Test_popupwin_wrap.dump b/src/testdir/dumps/Test_popupwin_wrap.dump
new file mode 100644
index 0000000000..3f7b00004d
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_wrap.dump
@@ -0,0 +1,10 @@
+>1+0&#ffffff0| @73
+|2| @73
+|3| @17|a+0#0000001#ffd7ff255| |l|o|n|g| |l|i|n| +0#0000000#ffffff0@45
+|4| @17|e+0#0000001#ffd7ff255| |t|h|a|t| |w|o|n| +0#0000000#ffffff0@45
+|5| @17|t+0#0000001#ffd7ff255| |f|i|t| @4| +0#0000000#ffffff0@45
+|6| @73
+|7| @73
+|8| @73
+|9| @73
+@57|1|,|1| @10|T|o|p|
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index ee188e39c3..c5fdb6e875 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -84,18 +84,19 @@ func Test_popup_with_syntax_setbufvar()
if !CanRunVimInTerminal()
return
endif
- call writefile([
- \ "call setline(1, range(1, 100))",
- \ "hi PopupColor ctermbg=lightgrey",
- \ "let winid = popup_create([",
- \ "\\ '#include <stdio.h>',",
- \ "\\ 'int main(void)',",
- \ "\\ '{',",
- \ "\\ ' printf(567);',",
- \ "\\ '}',",
- \ "\\], {'line': 3, 'col': 21, 'highlight': 'PopupColor'})",
- \ "call setbufvar(winbufnr(winid), '&syntax', 'cpp')",
- \], 'XtestPopup')
+ let lines =<< trim END
+ call setline(1, range(1, 100))
+ hi PopupColor ctermbg=lightgrey
+ let winid = popup_create([
+ \ '#include <stdio.h>',
+ \ 'int main(void)',
+ \ '{',
+ \ ' printf(567);',
+ \ '}',
+ \], {'line': 3, 'col': 21, 'highlight': 'PopupColor'})
+ call setbufvar(winbufnr(winid), '&syntax', 'cpp')
+ END
+ call writefile(lines, 'XtestPopup')
let buf = RunVimInTerminal('-S XtestPopup', {'rows': 10})
call VerifyScreenDump(buf, 'Test_popupwin_11', {})
@@ -104,6 +105,44 @@ func Test_popup_with_syntax_setbufvar()
call delete('XtestPopup')
endfunc
+func Test_popup_with_wrap()
+ if !CanRunVimInTerminal()
+ return
+ endif
+ let lines =<< trim END
+ call setline(1, range(1, 100))
+ let winid = popup_create(
+ \ 'a long line that wont fit',
+ \ {'line': 3, 'col': 20, 'maxwidth': 10, 'wrap': 1})
+ END
+ call writefile(lines, 'XtestPopup')
+ let buf = RunVimInTerminal('-S XtestPopup', {'rows': 10})
+ call VerifyScreenDump(buf, 'Test_popupwin_wrap', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XtestPopup')
+endfunc
+
+func Test_popup_without_wrap()
+ if !CanRunVimInTerminal()
+ return
+ endif
+ let lines =<< trim END
+ call setline(1, range(1, 100))
+ let winid = popup_create(
+ \ 'a long line that wont fit',
+ \ {'line': 3, 'col': 20, 'maxwidth': 10, 'wrap': 0})
+ END
+ call writefile(lines, 'XtestPopup')
+ let buf = RunVimInTerminal('-S XtestPopup', {'rows': 10})
+ call VerifyScreenDump(buf, 'Test_popupwin_nowrap', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XtestPopup')
+endfunc
+
func Test_popup_time()
if !has('timers')
return
@@ -156,19 +195,19 @@ func Test_popup_hide()
redraw
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
call assert_equal('world', line)
- call assert_equal(1, popup_getposition(winid).visible)
+ call assert_equal(1, popup_getpos(winid).visible)
call popup_hide(winid)
redraw
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
call assert_equal('hello', line)
- call assert_equal(0, popup_getposition(winid).visible)
+ call assert_equal(0, popup_getpos(winid).visible)
call popup_show(winid)
redraw
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
call assert_equal('world', line)
- call assert_equal(1, popup_getposition(winid).visible)
+ call assert_equal(1, popup_getpos(winid).visible)
call popup_close(winid)
@@ -216,7 +255,7 @@ func Test_popup_move()
bwipe!
endfunc
-func Test_popup_getposition()
+func Test_popup_getpos()
let winid = popup_create('hello', {
\ 'line': 2,
\ 'col': 3,
@@ -224,7 +263,7 @@ func Test_popup_getposition()
\ 'minheight': 11,
\})
redraw
- let res = popup_getposition(winid)
+ let res = popup_getpos(winid)
call assert_equal(2, res.line)
call assert_equal(3, res.col)
call assert_equal(10, res.width)
@@ -246,7 +285,7 @@ func Test_popup_width_longest()
for test in tests
let winid = popup_create(test[0], {'line': 2, 'col': 3})
redraw
- let position = popup_getposition(winid)
+ let position = popup_getpos(winid)
call assert_equal(test[1], position.width)
call popup_close(winid)
endfor
@@ -262,12 +301,12 @@ func Test_popup_wraps()
let winid = popup_create(test[0],
\ {'line': 2, 'col': 3, 'maxwidth': 12})
redraw
- let position = popup_getposition(winid)
+ let position = popup_getpos(winid)
call assert_equal(test[1], position.width)
call assert_equal(test[2], position.height)
call popup_close(winid)
- call assert_equal({}, popup_getposition(winid))
+ call assert_equal({}, popup_getpos(winid))
endfor
endfunc
@@ -382,5 +421,23 @@ func Test_popup_atcursor()
call assert_equal('xvimxxxxxxxxxxxxx', line)
call popup_close(winid)
+ " just enough room above
+ call cursor(3, 3)
+ redraw
+ let winid = popup_atcursor(['vim', 'is great'], {})
+ redraw
+ let pos = popup_getpos(winid)
+ call assert_equal(1, pos.line)
+ call popup_close(winid)
+
+ " not enough room above, popup goes below the cursor
+ call cursor(3, 3)
+ redraw
+ let winid = popup_atcursor(['vim', 'is', 'great'], {})
+ redraw
+ let pos = popup_getpos(winid)
+ call assert_equal(4, pos.line)
+ call popup_close(winid)
+
bwipe!
endfunc
diff --git a/src/version.c b/src/version.c
index c3b96e9331..2f05cea8e7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -768,6 +768,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1430,
+/**/
1429,
/**/
1428,