patch 8.1.1410: popup_move() is not implemented yet
Problem: Popup_move() is not implemented yet.
Solution: Implement it. (Yasuhiro Matsumoto, closes #4441) Improve the
positioning and resizing.
diff --git a/src/testdir/dumps/Test_popupwin_05.dump b/src/testdir/dumps/Test_popupwin_05.dump
new file mode 100644
index 0000000..bfb50f0
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_05.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @6|o+0#0000001#ffd7ff255|t|h|e|r| |t|a|b| @5| +0#4040ff13#ffffff0@51
+|~| @6|a+0#0000001#ffd7ff255| |c+0#ff404010&|o|m@1|e|n|t| +0#0000001&|l|i|n|e| | +0#4040ff13#ffffff0@51
+|~| @6|~+0&#ffd7ff255| @13| +0&#ffffff0@51
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|r|e|d|r|a|w| @49|0|,|0|-|1| @8|A|l@1|
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index f1394fb..756ad68 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -16,8 +16,8 @@
\ "hi PopupColor2 ctermbg=lightcyan",
\ "hi Comment ctermfg=red",
\ "call prop_type_add('comment', {'highlight': 'Comment'})",
- \ "let winid = popup_create('hello there', {'line': 3, 'col': 11, 'highlight': 'PopupColor1'})",
- \ "let winid2 = popup_create(['another one', 'another two', 'another three'], {'line': 3, 'col': 25})",
+ \ "let winid = popup_create('hello there', {'line': 3, 'col': 11, 'minwidth': 20, 'highlight': 'PopupColor1'})",
+ \ "let winid2 = popup_create(['another one', 'another two', 'another three'], {'line': 3, 'col': 25, 'minwidth': 20})",
\ "call setwinvar(winid2, '&wincolor', 'PopupColor2')",
\], 'XtestPopup')
let buf = RunVimInTerminal('-S XtestPopup', {'rows': 10})
@@ -25,12 +25,12 @@
" Add a tabpage
call term_sendkeys(buf, ":tabnew\<CR>")
- call term_sendkeys(buf, ":call popup_create(["
+ call term_sendkeys(buf, ":let popupwin = popup_create(["
\ .. "{'text': 'other tab'},"
\ .. "{'text': 'a comment line', 'props': [{"
- \ .. "'col': 3, 'length': 7, 'type': 'comment'"
+ \ .. "'col': 3, 'length': 7, 'minwidth': 20, 'type': 'comment'"
\ .. "}]},"
- \ .. "], {'line': 4, 'col': 9})\<CR>")
+ \ .. "], {'line': 4, 'col': 9, 'minwidth': 20})\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_02', {})
" switch back to first tabpage
@@ -41,6 +41,11 @@
call term_sendkeys(buf, ":quit!\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_04', {})
+ " resize popup
+ call term_sendkeys(buf, ":call popup_move(popupwin, {'minwidth': 15, 'maxwidth': 25, 'minheight': 3, 'maxheight': 5})\<CR>")
+ call term_sendkeys(buf, ":redraw\<CR>")
+ call VerifyScreenDump(buf, 'Test_popupwin_05', {})
+
" clean up
call StopVimInTerminal(buf)
call delete('XtestPopup')
@@ -56,6 +61,7 @@
call popup_create('world', {
\ 'line': 1,
\ 'col': 1,
+ \ 'minwidth': 20,
\ 'time': 500,
\})
redraw
@@ -70,6 +76,7 @@
call popup_create('on the command line', {
\ 'line': &lines,
\ 'col': 10,
+ \ 'minwidth': 20,
\ 'time': 500,
\})
redraw
@@ -91,6 +98,7 @@
let winid = popup_create('world', {
\ 'line': 1,
\ 'col': 1,
+ \ 'minwidth': 20,
\})
redraw
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
@@ -121,3 +129,33 @@
bwipe!
endfunc
+
+func Test_popup_move()
+ topleft vnew
+ call setline(1, 'hello')
+
+ let winid = popup_create('world', {
+ \ 'line': 1,
+ \ 'col': 1,
+ \ 'minwidth': 20,
+ \})
+ redraw
+ let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
+ call assert_equal('world ', line)
+
+ call popup_move(winid, {'line': 2, 'col': 2})
+ redraw
+ let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
+ call assert_equal('hello ', line)
+ let line = join(map(range(1, 6), 'screenstring(2, v:val)'), '')
+ call assert_equal('~world', line)
+
+ call popup_move(winid, {'line': 1})
+ redraw
+ let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
+ call assert_equal('hworld', line)
+
+ call popup_close(winid)
+
+ bwipe!
+endfunc