diff options
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r-- | test/functional/ui/float_spec.lua | 916 |
1 files changed, 812 insertions, 104 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 3be2182eb4..a567fbb941 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -5,6 +5,7 @@ local clear, feed = helpers.clear, helpers.feed local command, feed_command = helpers.command, helpers.feed_command local eval = helpers.eval local eq = helpers.eq +local insert = helpers.insert local meths = helpers.meths local curbufmeths = helpers.curbufmeths local funcs = helpers.funcs @@ -29,9 +30,27 @@ describe('floating windows', function() [10] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta}, [11] = {bold = true, foreground = Screen.colors.Magenta}, [12] = {background = Screen.colors.Red, bold = true, foreground = Screen.colors.Blue1}, - [13] = {background = Screen.colors.WebGray} + [13] = {background = Screen.colors.WebGray}, + [14] = {foreground = Screen.colors.Brown}, + [15] = {background = Screen.colors.Grey20}, + [16] = {background = Screen.colors.Grey20, bold = true, foreground = Screen.colors.Blue1}, + [17] = {background = Screen.colors.Yellow}, } + it('behavior', function() + -- Create three windows and test that ":wincmd <direction>" changes to the + -- first window, if the previous window is invalid. + command('split') + meths.open_win(0, true, {width=10, height=10, relative='editor', row=0, col=0}) + eq(1002, funcs.win_getid()) + eq('editor', meths.win_get_config(1002).relative) + command([[ + call nvim_win_close(1001, v:false) + wincmd j + ]]) + eq(1000, funcs.win_getid()) + end) + local function with_ext_multigrid(multigrid) local screen before_each(function() @@ -42,13 +61,11 @@ describe('floating windows', function() it('can be created and reconfigured', function() local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, 20, 2, {relative='editor', row=2, col=5}) - meths.win_set_option(win , 'winhl', 'Normal:PMenu') + local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) local expected_pos = { [3]={{id=1001}, 'NW', 1, 2, 5, true}, } - if multigrid then screen:expect{grid=[[ ## grid 1 @@ -83,7 +100,7 @@ describe('floating windows', function() end - meths.win_config(win,0,0,{relative='editor', row=0, col=10}) + meths.win_set_config(win, {relative='editor', row=0, col=10}) expected_pos[3][4] = 0 expected_pos[3][5] = 10 if multigrid then @@ -151,20 +168,226 @@ describe('floating windows', function() end end) + it('return their configuration', function() + local buf = meths.create_buf(false, false) + local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=3, col=5}) + local expected = {anchor='NW', col=5, external=false, focusable=true, height=2, relative='editor', row=3, width=20} + eq(expected, meths.win_get_config(win)) + + eq({relative='', external=false, focusable=true}, meths.win_get_config(0)) + + if multigrid then + meths.win_set_config(win, {external=true, width=10, height=1}) + eq({external=true,focusable=true,width=10,height=1,relative=''}, meths.win_get_config(win)) + end + end) + + it('defaults to nonumber and NormalFloat highlight', function() + command('set number') + command('hi NormalFloat guibg=#333333') + feed('ix<cr>y<cr><esc>gg') + local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + {14: 1 }^x | + {14: 2 }y | + {14: 3 } | + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {15:x }| + {15:y }| + {15: }| + {16:~ }| + ]], float_pos={[3] = {{id = 1001}, "NW", 1, 4, 10, true}}} + else + screen:expect([[ + {14: 1 }^x | + {14: 2 }y | + {14: 3 } {15:x } | + {0:~ }{15:y }{0: }| + {0:~ }{15: }{0: }| + {0:~ }{16:~ }{0: }| + | + ]]) + end + + local buf = meths.create_buf(false, true) + meths.win_set_buf(win, buf) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + {14: 1 }^x | + {14: 2 }y | + {14: 3 } | + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {15: }| + {16:~ }| + {16:~ }| + {16:~ }| + ]], float_pos={[3] = {{id = 1001}, "NW", 1, 4, 10, true}}} + else + screen:expect([[ + {14: 1 }^x | + {14: 2 }y | + {14: 3 } {15: } | + {0:~ }{16:~ }{0: }| + {0:~ }{16:~ }{0: }| + {0:~ }{16:~ }{0: }| + | + ]]) + end + end) + + it('can have minimum size', function() + insert("the background text") + local buf = meths.create_buf(false, true) + meths.buf_set_lines(buf, 0, -1, true, {'x'}) + local win = meths.open_win(buf, false, {relative='win', width=1, height=1, row=0, col=4, focusable=false}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + the background tex^t | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 4 + {1:x}| + ]], float_pos={ + [4] = {{id = 1002}, "NW", 2, 0, 4, false} + }} + else + screen:expect([[ + the {1:x}ackground tex^t | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + + meths.win_set_config(win, {relative='win', row=0, col=15}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + the background tex^t | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 4 + {1:x}| + ]], float_pos={ + [4] = {{id = 1002}, "NW", 2, 0, 15, false} + }} + else + screen:expect([[ + the background {1:x}ex^t | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + + meths.win_close(win,false) + if multigrid then + screen:expect([[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + the background tex^t | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ]]) + else + screen:expect([[ + the background tex^t | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + end) + it('API has proper error messages', function() local buf = meths.create_buf(false,false) - eq({false, "Invalid options key 'bork'"}, - meth_pcall(meths.open_win,buf, false, 20, 2, {bork=true})) - eq({false, "'win' option is only valid with relative='win'"}, - meth_pcall(meths.open_win,buf, false, 20, 2, {relative='editor',row=0,col=0,win=0})) - eq({false, "Only one of 'relative' and 'external' should be used"}, - meth_pcall(meths.open_win,buf, false, 20, 2, {relative='editor',row=0,col=0,external=true})) - eq({false, "Invalid value of 'relative' option"}, - meth_pcall(meths.open_win,buf, false, 20, 2, {relative='shell',row=0,col=0})) - eq({false, "Invalid value of 'anchor' option"}, - meth_pcall(meths.open_win,buf, false, 20, 2, {relative='editor',row=0,col=0,anchor='bottom'})) + eq({false, "Invalid key 'bork'"}, + meth_pcall(meths.open_win,buf, false, {width=20,height=2,bork=true})) + eq({false, "'win' key is only valid with relative='win'"}, + meth_pcall(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0})) + eq({false, "Only one of 'relative' and 'external' must be used"}, + meth_pcall(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true})) + eq({false, "Invalid value of 'relative' key"}, + meth_pcall(meths.open_win,buf, false, {width=20,height=2,relative='shell',row=0,col=0})) + eq({false, "Invalid value of 'anchor' key"}, + meth_pcall(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'})) eq({false, "All of 'relative', 'row', and 'col' has to be specified at once"}, - meth_pcall(meths.open_win,buf, false, 20, 2, {relative='editor'})) + meth_pcall(meths.open_win,buf, false, {width=20,height=2,relative='editor'})) + eq({false, "'width' key must be a positive Integer"}, + meth_pcall(meths.open_win,buf, false, {width=-1,height=2,relative='editor'})) + eq({false, "'height' key must be a positive Integer"}, + meth_pcall(meths.open_win,buf, false, {width=20,height=-1,relative='editor'})) + eq({false, "'height' key must be a positive Integer"}, + meth_pcall(meths.open_win,buf, false, {width=20,height=0,relative='editor'})) + eq({false, "Must specify 'width' and 'height'"}, + meth_pcall(meths.open_win,buf, false, {relative='editor'})) end) it('can be placed relative window or cursor', function() @@ -210,8 +433,7 @@ describe('floating windows', function() local buf = meths.create_buf(false,false) -- no 'win' arg, relative default window - local win = meths.open_win(buf, false, 20, 2, {relative='win', row=0, col=10}) - meths.win_set_option(win, 'winhl', 'Normal:PMenu') + local win = meths.open_win(buf, false, {relative='win', width=20, height=2, row=0, col=10}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -252,7 +474,7 @@ describe('floating windows', function() ]]) end - meths.win_config(win, -1, -1, {relative='cursor', row=1, col=-2}) + meths.win_set_config(win, {relative='cursor', row=1, col=-2}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -293,7 +515,7 @@ describe('floating windows', function() ]]) end - meths.win_config(win, -1, -1, {relative='cursor', row=0, col=0, anchor='SW'}) + meths.win_set_config(win, {relative='cursor', row=0, col=0, anchor='SW'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -335,7 +557,7 @@ describe('floating windows', function() end - meths.win_config(win, -1, -1, {relative='win', win=oldwin, row=1, col=10, anchor='NW'}) + meths.win_set_config(win, {relative='win', win=oldwin, row=1, col=10, anchor='NW'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -376,7 +598,7 @@ describe('floating windows', function() ]]) end - meths.win_config(win, -1, -1, {relative='win', win=oldwin, row=3, col=39, anchor='SE'}) + meths.win_set_config(win, {relative='win', win=oldwin, row=3, col=39, anchor='SE'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -417,7 +639,7 @@ describe('floating windows', function() ]]) end - meths.win_config(win, -1, -1, {relative='win', win=0, row=0, col=50, anchor='NE'}) + meths.win_set_config(win, {relative='win', win=0, row=0, col=50, anchor='NE'}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -459,6 +681,66 @@ describe('floating windows', function() end end) + it('validates cursor even when window is not entered', function() + screen:try_resize(30,5) + command("set nowrap") + insert([[some text that is wider than the window]]) + if multigrid then + screen:expect([[ + ## grid 1 + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + | + ## grid 2 + that is wider than the windo^w | + {0:~ }| + {0:~ }| + {0:~ }| + ]]) + else + screen:expect([[ + that is wider than the windo^w | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + + local buf = meths.create_buf(false,true) + meths.buf_set_lines(buf, 0, -1, true, {'some floaty text'}) + meths.open_win(buf, false, {relative='editor', width=20, height=1, row=3, col=1}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + | + ## grid 2 + that is wider than the windo^w | + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 4 + {1:some floaty text }| + ]], float_pos={ + [4] = {{id = 1002}, "NW", 1, 3, 1, true} + }} + else + screen:expect([[ + that is wider than the windo^w | + {0:~ }| + {0:~ }| + {0:~}{1:some floaty text }{0: }| + | + ]]) + end + end) + if multigrid then pending("supports second UI without multigrid", function() local session2 = helpers.connect(eval('v:servername')) @@ -467,8 +749,7 @@ describe('floating windows', function() screen2:attach(nil, session2) screen2:set_default_attr_ids(attrs) local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, true, 20, 2, {relative='editor', row=2, col=5}) - meths.win_set_option(win, 'winhl', 'Normal:PMenu') + meths.open_win(buf, true, {relative='editor', width=20, height=2, row=2, col=5}) local expected_pos = { [2]={{id=1001}, 'NW', 1, 2, 5} } @@ -501,8 +782,7 @@ describe('floating windows', function() it('handles resized screen', function() local buf = meths.create_buf(false,false) meths.buf_set_lines(buf, 0, -1, true, {'such', 'very', 'float'}) - local win = meths.open_win(buf, false, 15, 4, {relative='editor', row=2, col=10}) - meths.win_set_option(win , 'winhl', 'Normal:PMenu') + local win = meths.open_win(buf, false, {relative='editor', width=15, height=4, row=2, col=10}) local expected_pos = { [4]={{id=1002}, 'NW', 1, 2, 10, true}, } @@ -673,15 +953,15 @@ describe('floating windows', function() screen:expect([[ | {0:~ }| + {0:~ }{1:such }{0: }| {0:~ }{1:very }{0: }| {0:~ }{1:^float }{0: }| - {0:~ }| - {0:~ }| + {0:~ }{2:~ }{0: }| | ]]) end - meths.win_config(win, -1, 3, {}) + meths.win_set_config(win, {height=3}) feed('gg') if multigrid then screen:expect{grid=[[ @@ -1010,10 +1290,126 @@ describe('floating windows', function() screen:expect([[ | {0:~ }| - {0:~ }{1:^such }{0: }| + {0:~ }{1:^such }{0: }| + {0:~ }{1:very }{0: }| + {0:~ }{1:float }{0: }| {0:~ }| + | + ]]) + end + end) + + it('does not crash with inccommand #9379', function() + local expected_pos = { + [3]={{id=1001}, 'NW', 1, 2, 0, true}, + } + + command("set inccommand=split") + command("set laststatus=2") + + local buf = meths.create_buf(false,false) + meths.open_win(buf, true, {relative='editor', width=30, height=3, row=2, col=0}) + + insert([[ + foo + bar + ]]) + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {5:[No Name] }| + | + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:foo }| + {1:bar }| + {1:^ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + | {0:~ }| + {1:foo }{0: }| + {1:bar }{0: }| + {1:^ }{0: }| + {5:[No Name] }| + | + ]]) + end + + feed(':%s/.') + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {5:[Preview] }| + :%s/.^ | + ## grid 2 + | + ## grid 3 + {17:f}{1:oo }| + {17:b}{1:ar }| + {1: }| + ]], float_pos=expected_pos} + else + screen:expect([[ + | + {5:[No Name] }| + {17:f}{1:oo } | + {17:b}{1:ar } | + {1: }{0: }| + {5:[Preview] }| + :%s/.^ | + ]]) + end + + feed('<Esc>') + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {5:[No Name] }| + | + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:foo }| + {1:bar }| + {1:^ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + | {0:~ }| + {1:foo }{0: }| + {1:bar }{0: }| + {1:^ }{0: }| + {5:[No Name] }| | ]]) end @@ -1021,7 +1417,7 @@ describe('floating windows', function() it('does not crash when set cmdheight #9680', function() local buf = meths.create_buf(false,false) - meths.open_win(buf, false, 20, 2, {relative='editor', row=2, col=5}) + meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) command("set cmdheight=2") eq(1, meths.eval('1')) end) @@ -1029,7 +1425,7 @@ describe('floating windows', function() describe('and completion', function() before_each(function() local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, true, 12, 4, {relative='editor', row=2, col=5}) + local win = meths.open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5}) meths.win_set_option(win , 'winhl', 'Normal:ErrorMsg') if multigrid then screen:expect{grid=[[ @@ -1266,7 +1662,7 @@ describe('floating windows', function() ]], float_pos={ [3] = {{ id = 1001 }, "NW", 1, 2, 5, true}, }, popupmenu={ - anchor = {0, 2, 3}, items = items, pos = 0 + anchor = {3, 0, 2}, items = items, pos = 0 }} else screen:expect{grid=[[ @@ -1278,7 +1674,7 @@ describe('floating windows', function() {0:~ }{12:~ }{0: }| {3:-- INSERT --} | ]], popupmenu={ - anchor = {2, 7}, items = items, pos = 0 + anchor = {1, 2, 7}, items = items, pos = 0 }} end @@ -1348,7 +1744,7 @@ describe('floating windows', function() ]], float_pos={ [3] = {{ id = 1001 }, "NW", 1, 2, 5, true}, }, popupmenu={ - anchor = {0, 0, 2}, items = items, pos = 0 + anchor = {2, 0, 0}, items = items, pos = 0 }} else screen:expect{grid=[[ @@ -1360,7 +1756,7 @@ describe('floating windows', function() {0:~ }{12:~ }{0: }| {3:-- INSERT --} | ]], popupmenu={ - anchor = {0, 0}, items = items, pos = 0 + anchor = {1, 0, 0}, items = items, pos = 0 }} end @@ -1402,9 +1798,233 @@ describe('floating windows', function() ]]) end end) - end) + describe('float shown after pum', function() + local win + before_each(function() + command('hi NormalFloat guibg=#333333') + feed('i') + funcs.complete(1, {'aa', 'word', 'longtext'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {13:aa }| + {1:word }| + {1:longtext }| + ]], float_pos={ + [3] = {{id = -1}, "NW", 2, 1, 0, false}} + } + else + screen:expect([[ + aa^ | + {13:aa }{0: }| + {1:word }{0: }| + {1:longtext }{0: }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + + local buf = meths.create_buf(false,true) + meths.buf_set_lines(buf,0,-1,true,{"some info", "about item"}) + win = meths.open_win(buf, false, {relative='cursor', width=12, height=2, row=1, col=10}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {13:aa }| + {1:word }| + {1:longtext }| + ## grid 5 + {15:some info }| + {15:about item }| + ]], float_pos={ + [3] = {{id = -1}, "NW", 2, 1, 0, false}, + [5] = {{id = 1002}, "NW", 2, 1, 12, true}, + }} + else + screen:expect([[ + aa^ | + {13:aa }{15:e info }{0: }| + {1:word }{15:ut item }{0: }| + {1:longtext }{0: }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + end) + + it('and close pum first', function() + feed('<c-y>') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 5 + {15:some info }| + {15:about item }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 2, 1, 12, true}, + }} + else + screen:expect([[ + aa^ | + {0:~ }{15:some info }{0: }| + {0:~ }{15:about item }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + + meths.win_close(win, false) + if multigrid then + screen:expect([[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ]]) + else + screen:expect([[ + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + end) + + it('and close float first', function() + meths.win_close(win, false) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {13:aa }| + {1:word }| + {1:longtext }| + ]], float_pos={ + [3] = {{id = -1}, "NW", 2, 1, 0, false}, + }} + else + screen:expect([[ + aa^ | + {13:aa }{0: }| + {1:word }{0: }| + {1:longtext }{0: }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + + feed('<c-y>') + if multigrid then + screen:expect([[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ]]) + else + screen:expect([[ + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + end) + end) describe("handles :wincmd", function() local win @@ -1415,9 +2035,8 @@ describe('floating windows', function() command("set hidden") meths.buf_set_lines(0,0,-1,true,{"x"}) local buf = meths.create_buf(false,false) - win = meths.open_win(buf, false, 20, 2, {relative='editor', row=2, col=5}) + win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) meths.buf_set_lines(buf,0,-1,true,{"y"}) - meths.win_set_option(win , 'winhl', 'Normal:PMenu') expected_pos = { [3]={{id=1001}, 'NW', 1, 2, 5, true} } @@ -1526,7 +2145,7 @@ describe('floating windows', function() end) it("w with focusable=false", function() - meths.win_config(win, -1, -1, {focusable=false}) + meths.win_set_config(win, {focusable=false}) expected_pos[3][6] = false feed("<c-w>wi") -- i to provoke redraw if multigrid then @@ -1740,7 +2359,7 @@ describe('floating windows', function() end) it("focus by mouse (focusable=false)", function() - meths.win_config(win, -1, -1, {focusable=false}) + meths.win_set_config(win, {focusable=false}) meths.buf_set_lines(0, -1, -1, true, {"a"}) expected_pos[3][6] = false if multigrid then @@ -2074,39 +2693,6 @@ describe('floating windows', function() {1:y }| {2:~ }| ## grid 4 - {1:^y }| - {2:~ }| - ]], float_pos=expected_pos} - else - screen:expect([[ - {1:^y }| - {2:~ }| - {4:[No N}{1:y }{4: }| - x {2:~ } | - {0:~ }| - {5:[No Name] [+] }| - | - ]]) - end - - feed(":set winhighlight=<cr><c-l>") - if multigrid then - screen:expect{grid=[[ - ## grid 1 - [4:----------------------------------------]| - [4:----------------------------------------]| - {4:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| - {5:[No Name] [+] }| - | - ## grid 2 - x | - {0:~ }| - ## grid 3 - {1:y }| - {2:~ }| - ## grid 4 ^y | {0:~ }| ]], float_pos=expected_pos} @@ -2122,7 +2708,6 @@ describe('floating windows', function() ]]) end - feed("<c-w>j") if multigrid then screen:expect{grid=[[ @@ -2405,6 +2990,119 @@ describe('floating windows', function() eq(exited, true) end) + it(':quit two floats in a row', function() + -- enter first float + feed('<c-w><c-w>') + -- enter second float + meths.open_win(0, true, {relative='editor', width=20, height=2, row=4, col=8}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:y }| + {2:~ }| + ## grid 4 + {1:^y }| + {2:~ }| + ]], float_pos={ + [3] = {{id = 1001}, "NW", 1, 2, 5, true}, + [4] = {{id = 1002}, "NW", 1, 4, 8, true} + }} + else + screen:expect([[ + x | + {0:~ }| + {0:~ }{1:y }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }{1:^y }{0: }| + {0:~ }{2:~ }{0: }| + | + ]]) + end + + feed(':quit<cr>') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {5:[No Name] [+] }| + :quit | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + {2:~ }| + ]], float_pos={ + [3] = {{id = 1001}, "NW", 1, 2, 5, true}, + }} + else + screen:expect([[ + x | + {0:~ }| + {0:~ }{1:^y }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {5:[No Name] [+] }| + :quit | + ]]) + end + + feed(':quit<cr>') + if multigrid then + screen:expect([[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + :quit | + ## grid 2 + ^x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ]]) + else + screen:expect([[ + ^x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + :quit | + ]]) + end + + eq(2, eval('1+1')) + end) + it("o (:only) non-float", function() feed("<c-w>o") if multigrid then @@ -2659,23 +3357,23 @@ describe('floating windows', function() x | {0:~ }| ## grid 3 - {1:^y }| - {2:~ }| + ^y | + {0:~ }| ]]} else screen:expect([[ x | {0:~ }| {5:[No Name] [+] }| - {1:^y }| - {2:~ }| + ^y | + {0:~ }| {4:[No Name] [+] }| | ]]) end if multigrid then - meths.win_config(0,-1,-1,{external=true}) + meths.win_set_config(0, {external=true, width=30, height=2}) expected_pos = {[3]={external=true}} screen:expect{grid=[[ ## grid 1 @@ -2693,12 +3391,12 @@ describe('floating windows', function() {0:~ }| {0:~ }| ## grid 3 - {1:^y }| - {2:~ }| + ^y | + {0:~ }| ]], float_pos=expected_pos} else eq({false, "UI doesn't support external windows"}, - meth_pcall(meths.win_config, 0,-1,-1,{external=true})) + meth_pcall(meths.win_set_config, 0, {external=true, width=30, height=2})) return end @@ -2717,11 +3415,10 @@ describe('floating windows', function() x | {0:~ }| ## grid 3 - {1:^y }| - {2:~ }| + ^y | + {0:~ }| ]]) end - end) it('movements with nested split layout', function() @@ -2786,8 +3483,8 @@ describe('floating windows', function() 4 | {0:~ }| ## grid 3 - ^5 | - {0:~ }| + {1:^5 }| + {2:~ }| ## grid 4 2 | {0:~ }| @@ -2802,8 +3499,8 @@ describe('floating windows', function() screen:expect([[ 1 {5:│}2 | {0:~ }{5:│}{0:~ }| - {5:[No N}^5 {5:ame] [+] }| - 3 {0:~ } | + {5:[No N}{1:^5 }{5:ame] [+] }| + 3 {2:~ } | {0:~ }{5:│}{0:~ }| {5:[No Name] [+] [No Name] [+] }| :enew | @@ -2895,13 +3592,14 @@ describe('floating windows', function() [2:----------------------------------------]| [2:----------------------------------------]| [2:----------------------------------------]| - {4:[No Name] [+] }| + [2:----------------------------------------]| :tabnext | ## grid 2 ^x | {0:~ }| {0:~ }| {0:~ }| + {0:~ }| ## grid 3 {1:y }| {2:~ }| @@ -2919,7 +3617,7 @@ describe('floating windows', function() {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| {0:~ }| - {4:[No Name] [+] }| + {0:~ }| :tabnext | ]]) end @@ -2940,6 +3638,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| + {0:~ }| ## grid 3 {1:y }| {2:~ }| @@ -2965,7 +3664,8 @@ describe('floating windows', function() it(":tabnew and :tabnext (external)", function() if multigrid then - meths.win_config(win,-1,-1,{external=true}) + -- also test external window wider than main screen + meths.win_set_config(win, {external=true, width=65, height=4}) expected_pos = {[3]={external=true}} feed(":tabnew<cr>") screen:expect{grid=[[ @@ -2985,8 +3685,10 @@ describe('floating windows', function() {0:~ }| {0:~ }| ## grid 3 - {1:y }| - {2:~ }| + y | + {0:~ }| + {0:~ }| + {0:~ }| ## grid 4 ^ | {0:~ }| @@ -2996,7 +3698,7 @@ describe('floating windows', function() ]], float_pos=expected_pos} else eq({false, "UI doesn't support external windows"}, - meth_pcall(meths.win_config, 0,-1,-1,{external=true})) + meth_pcall(meths.win_set_config, 0, {external=true, width=65, height=4})) end feed(":tabnext<cr>") @@ -3008,16 +3710,19 @@ describe('floating windows', function() [2:----------------------------------------]| [2:----------------------------------------]| [2:----------------------------------------]| - {4:[No Name] [+] }| + [2:----------------------------------------]| :tabnext | ## grid 2 ^x | {0:~ }| {0:~ }| {0:~ }| + {0:~ }| ## grid 3 - {1:y }| - {2:~ }| + y | + {0:~ }| + {0:~ }| + {0:~ }| ## grid 4 | {0:~ }| @@ -3036,21 +3741,25 @@ describe('floating windows', function() [4:----------------------------------------]| [4:----------------------------------------]| [4:----------------------------------------]| - {4:[No Name] }| + [4:----------------------------------------]| :tabnext | ## grid 2 x | {0:~ }| {0:~ }| {0:~ }| + {0:~ }| ## grid 3 - {1:y }| - {2:~ }| + y | + {0:~ }| + {0:~ }| + {0:~ }| ## grid 4 ^ | {0:~ }| {0:~ }| {0:~ }| + {0:~ }| ]], float_pos=expected_pos} end end) @@ -3063,6 +3772,5 @@ describe('floating windows', function() describe('without ext_multigrid', function() with_ext_multigrid(false) end) - end) |