comparison src/testdir/test_popupwin.vim @ 17107:0001d10a7661 v8.1.1553

patch 8.1.1553: not easy to change the text in a popup window commit https://github.com/vim/vim/commit/dc2ce58b5ac72e2af765385eb426660104816344 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 16 15:32:14 2019 +0200 patch 8.1.1553: not easy to change the text in a popup window Problem: Not easy to change the text in a popup window. Solution: Add popup_settext(). (Ben Jackson, closes https://github.com/vim/vim/issues/4549) Also display a space for an empty popup.
author Bram Moolenaar <Bram@vim.org>
date Sun, 16 Jun 2019 15:45:05 +0200
parents 1a23650f8da5
children 7ef5283ace3c
comparison
equal deleted inserted replaced
17106:32af152d94b1 17107:0001d10a7661
914 914
915 func Test_popup_empty() 915 func Test_popup_empty()
916 let winid = popup_create('', {'padding': [2,2,2,2]}) 916 let winid = popup_create('', {'padding': [2,2,2,2]})
917 redraw 917 redraw
918 let pos = popup_getpos(winid) 918 let pos = popup_getpos(winid)
919 call assert_equal(4, pos.width) 919 call assert_equal(5, pos.width)
920 call assert_equal(5, pos.height) 920 call assert_equal(5, pos.height)
921 921
922 let winid = popup_create([], {'border': []}) 922 let winid = popup_create([], {'border': []})
923 redraw 923 redraw
924 let pos = popup_getpos(winid) 924 let pos = popup_getpos(winid)
925 call assert_equal(2, pos.width) 925 call assert_equal(3, pos.width)
926 call assert_equal(3, pos.height) 926 call assert_equal(3, pos.height)
927 endfunc 927 endfunc
928 928
929 func Test_popup_never_behind() 929 func Test_popup_never_behind()
930 if !CanRunVimInTerminal() 930 if !CanRunVimInTerminal()
1229 1229
1230 " clean up 1230 " clean up
1231 call StopVimInTerminal(buf) 1231 call StopVimInTerminal(buf)
1232 call delete('XtestNotifications') 1232 call delete('XtestNotifications')
1233 endfunc 1233 endfunc
1234
1235 function Test_popup_settext()
1236 if !CanRunVimInTerminal()
1237 throw 'Skipped: cannot make screendumps'
1238 endif
1239
1240 let lines =<< trim END
1241 let opts = {'wrap': 0}
1242 let p = popup_create('test', opts)
1243 call popup_settext(p, 'this is a text')
1244 END
1245
1246 call writefile( lines, 'XtestPopupSetText' )
1247 let buf = RunVimInTerminal('-S XtestPopupSetText', {'rows': 10})
1248 call VerifyScreenDump(buf, 'Test_popup_settext_01', {})
1249
1250 " Setting to empty string clears it
1251 call term_sendkeys(buf, ":call popup_settext(p, '')\<CR>")
1252 call VerifyScreenDump(buf, 'Test_popup_settext_02', {})
1253
1254 " Setting a list
1255 call term_sendkeys(buf, ":call popup_settext(p, ['a','b','c'])\<CR>")
1256 call VerifyScreenDump(buf, 'Test_popup_settext_03', {})
1257
1258 " Shrinking with a list
1259 call term_sendkeys(buf, ":call popup_settext(p, ['a'])\<CR>")
1260 call VerifyScreenDump(buf, 'Test_popup_settext_04', {})
1261
1262 " Growing with a list
1263 call term_sendkeys(buf, ":call popup_settext(p, ['a','b','c'])\<CR>")
1264 call VerifyScreenDump(buf, 'Test_popup_settext_03', {})
1265
1266 " Empty list clears
1267 call term_sendkeys(buf, ":call popup_settext(p, [])\<CR>")
1268 call VerifyScreenDump(buf, 'Test_popup_settext_05', {})
1269
1270 " Dicts
1271 call term_sendkeys(buf, ":call popup_settext(p, [{'text': 'aaaa'}, {'text': 'bbbb'}, {'text': 'cccc'}])\<CR>")
1272 call VerifyScreenDump(buf, 'Test_popup_settext_06', {})
1273
1274 " clean up
1275 call StopVimInTerminal(buf)
1276 call delete('XtestPopupSetText')
1277 endfunction