robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3local Screen =require ( 'test.functional.ui.screen' ) 4local os =require ( 'os' ) 5 6local describe , it , before_each , after_each , pending =t . describe , t . it , t . before_each , t . after_each , t . pending 7local clear , feed =n . clear , n . feed 8local assert_alive =n . assert_alive 9local command , feed_command =n . command , n . feed_command 10local eval =n . eval 11local eq =t . eq 12local neq =t . neq 13local matches =t . matches 14local expect =n . expect 15local exec =n . exec 16local exec_lua =n . exec_lua 17local insert =n . insert 18local api =n . api 19local fn =n . fn 20local run =n . run 21local pcall_err =t . pcall_err 22local tbl_contains =vim . tbl_contains 23local curbuf =n . api . nvim_get_current_buf 24local curwin =n . api . nvim_get_current_win 25local curtab =n . api . nvim_get_current_tabpage 26local NIL =vim . NIL 27 28describe ( 'float window' , function () 29before_each ( function () 30clear () 31command ( 'hi VertSplit gui=reverse' ) 32end ) 33 34it ( 'behavior' , function () 35-- Create three windows and test that ":wincmd <direction>" changes to the 36-- first window, if the previous window is invalid. 37command ( 'split' ) 38api . nvim_open_win ( 0 , true , { width =10 , height =10 , relative ='editor' , row =0 , col =0 } ) 39eq ( 1002 , fn . win_getid ()) 40eq ( 'editor' , api . nvim_win_get_config ( 1002 ). relative ) 41command ( [[ 42call nvim_win_close(1001, v:false) 43wincmd j 44]] ) 45eq ( 1000 , fn . win_getid ()) 46end ) 47 48it ( 'validation' , function () 49local buf =api . nvim_create_buf ( false , false ) 50eq ( "Invalid key: 'bork'" , pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , bork =true } )) 51eq ( "Required: 'relative' or 'external' when creating a float" , pcall_err ( api . nvim_open_win , buf , false , { win =0 } )) 52eq ( 53"Conflict: 'vertical' not allowed with floating windows" , 54pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , vertical =true } ) 55) 56eq ( 57"Conflict: 'split' not allowed with floating windows" , 58pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , split ='left' } ) 59) 60eq ( 61"Conflict: 'relative' not allowed with 'external'" , 62pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , external =true } ) 63) 64eq ( 65"Invalid 'relative': 'shell'" , 66pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='shell' , row =0 , col =0 } ) 67) 68eq ( 69"Invalid 'anchor': 'bottom'" , 70pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , anchor ='bottom' } ) 71) 72eq ( 73"Required: 'relative' requires 'row'/'col' or 'bufpos'" , 74pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' } ) 75) 76eq ( 77"Invalid 'width': expected positive Integer" , 78pcall_err ( api . nvim_open_win , buf , false , { width =- 1 , height =2 , relative ='editor' , row =0 , col =0 } ) 79) 80eq ( 81"Invalid 'height': expected positive Integer" , 82pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =- 1 , relative ='editor' , row =0 , col =0 } ) 83) 84eq ( 85"Invalid 'height': expected positive Integer" , 86pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =0 , relative ='editor' , row =0 , col =0 } ) 87) 88eq ( "Required: 'width'" , pcall_err ( api . nvim_open_win , buf , false , { relative ='editor' , row =0 , col =0 } )) 89eq ( "Required: 'height'" , pcall_err ( api . nvim_open_win , buf , false , { relative ='editor' , row =0 , col =0 , width =2 } )) 90 91eq ( "Invalid 'split': 'up'" , pcall_err ( api . nvim_open_win , buf , false , { split ='up' } )) 92eq ( 93"Invalid 'bufpos': expected [row, col] array" , 94pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , bufpos ={ 0 } } ) 95) 96eq ( 97"Invalid 'zindex': expected positive Integer" , 98pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , zindex =0 } ) 99) 100eq ( 101"Invalid 'zindex': expected positive Integer" , 102pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , zindex =- 1 } ) 103) 104eq ( 105"Invalid 'style': 'bogus'" , 106pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , style ='bogus' } ) 107) 108eq ( 109"Invalid 'border': 'bogus'" , 110pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , border ='bogus' } ) 111) 112eq ( 113"Invalid 'border': expected 1, 2, 4, or 8 chars" , 114pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , border ={ '' , '' , '' } } ) 115) 116eq ( 117"Invalid 'border': expected 1 or 2-item Array" , 118pcall_err ( 119api . nvim_open_win , 120buf , 121false , 122{ width =20 , height =2 , relative ='editor' , row =0 , col =0 , border ={ { 'a' , 'b' , 'c' } } } 123) 124) 125eq ( 126"Invalid 'border': expected Array of Strings" , 127pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , border ={ { 1 } } } ) 128) 129eq ( 130"Invalid 'border': expected String or Array, got Integer" , 131pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , border ={ 42 } } ) 132) 133eq ( 134"Invalid 'border': expected only one-cell chars" , 135pcall_err ( api . nvim_open_win , buf , false , { width =20 , height =2 , relative ='editor' , row =0 , col =0 , border ={ 'aa' } } ) 136) 137eq ( 138"Invalid 'border': expected corner char between edge chars" , 139pcall_err ( 140api . nvim_open_win , 141buf , 142false , 143{ width =20 , height =2 , relative ='editor' , row =0 , col =0 , border ={ '' , '-' , '' , '|' , '' , '-' , '' , '|' } } 144) 145) 146 147-- title_pos/footer_pos validation 148eq ( 149"Invalid 'title_pos': 'bogus'" , 150pcall_err ( 151api . nvim_open_win , 152buf , 153false , 154{ width =20 , height =2 , relative ='editor' , row =0 , col =0 , border ='single' , title ='T' , title_pos ='bogus' } 155) 156) 157eq ( 158"Invalid 'footer_pos': 'bogus'" , 159pcall_err ( 160api . nvim_open_win , 161buf , 162false , 163{ width =20 , height =2 , relative ='editor' , row =0 , col =0 , border ='single' , footer ='F' , footer_pos ='bogus' } 164) 165) 166eq ( 167"Required: 'footer' requires 'footer_pos'" , 168pcall_err ( 169api . nvim_open_win , 170buf , 171false , 172{ relative ='editor' , width =9 , height =2 , row =2 , col =5 , border ='single' , footer_pos ='left' } 173) 174) 175eq ( 176"Required: 'title' requires 'title_pos'" , 177pcall_err ( 178api . nvim_open_win , 179buf , 180false , 181{ relative ='editor' , width =9 , height =2 , row =2 , col =5 , border ='single' , title_pos ='left' } 182) 183) 184end ) 185 186it ( 'validation: split window' , function () 187local buf =api . nvim_create_buf ( false , true ) 188eq ( "Conflict: 'zindex' not allowed with non-float window" , pcall_err ( api . nvim_open_win , buf , false , { split ='left' , zindex =100 } )) 189eq ( "Conflict: 'title' not allowed with non-float window" , pcall_err ( api . nvim_open_win , buf , false , { split ='left' , title ='T' } )) 190eq ( "Conflict: 'footer' not allowed with non-float window" , pcall_err ( api . nvim_open_win , buf , false , { split ='left' , footer ='F' } )) 191eq ( 192"Conflict: 'border' not allowed with non-float window" , 193pcall_err ( api . nvim_open_win , buf , false , { split ='left' , border ='single' } ) 194) 195eq ( "Conflict: 'row' not allowed with non-float window" , pcall_err ( api . nvim_open_win , buf , true , { split ='right' , row =10 } )) 196eq ( "Conflict: 'col' not allowed with non-float window" , pcall_err ( api . nvim_open_win , buf , true , { split ='right' , col =10 } )) 197eq ( 198"Conflict: 'bufpos' not allowed with non-float window" , 199pcall_err ( api . nvim_open_win , buf , true , { split ='right' , bufpos ={ 0 , 0 } } ) 200) 201 202local winid =api . nvim_open_win ( buf , true , { split ='right' } ) 203eq ( "Conflict: 'row' not allowed with non-float window" , pcall_err ( api . nvim_win_set_config , winid , { split ='right' , row =10 } )) 204eq ( "Conflict: 'col' not allowed with non-float window" , pcall_err ( api . nvim_win_set_config , winid , { split ='right' , col =10 } )) 205eq ( 206"Conflict: 'bufpos' not allowed with non-float window" , 207pcall_err ( api . nvim_win_set_config , winid , { split ='right' , bufpos ={ 0 , 0 } } ) 208) 209 210-- Reconfiguring split 211local not_allowed ={ hide =true , zindex =1 , title ='' , footer ='' , border ='single' } 212for k , v in pairs ( not_allowed ) do 213local err =( "Conflict: '%s' not allowed with non-float window" ): format ( k ) 214eq ( err , pcall_err ( api . nvim_win_set_config , winid , { [ k ] =v } )) 215end 216end ) 217 218it ( 'win_execute() should work' , function () 219local buf =api . nvim_create_buf ( false , false ) 220api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'the floatwin' , 'abc' , 'def' } ) 221local win =api . nvim_open_win ( buf , false , { relative ='win' , width =16 , height =1 , row =0 , col =10 } ) 222local line =fn . win_execute ( win , 'echo getline(1)' ) 223eq ( '\nthe floatwin' , line ) 224eq ( '\n1' , fn . win_execute ( win , 'echo line(".",' .. win .. ')' )) 225eq ( '\n3' , fn . win_execute ( win , 'echo line("$",' .. win .. ')' )) 226eq ( '\n0' , fn . win_execute ( win , 'echo line("$", 123456)' )) 227fn . win_execute ( win , 'bwipe!' ) 228end ) 229 230it ( "win_execute() call commands that are not allowed when 'hidden' is not set" , function () 231command ( 'set nohidden' ) 232local buf =api . nvim_create_buf ( false , false ) 233api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'the floatwin' } ) 234local win =api . nvim_open_win ( buf , true , { relative ='win' , width =16 , height =1 , row =0 , col =10 } ) 235eq ( 'Vim(close):E37: No write since last change (add ! to override)' , pcall_err ( fn . win_execute , win , 'close' )) 236eq ( 'Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)' , pcall_err ( fn . win_execute , win , 'bdelete' )) 237fn . win_execute ( win , 'bwipe!' ) 238end ) 239 240it ( 'closed immediately by autocmd #11383' , function () 241eq ( 242'Window was closed immediately' , 243pcall_err ( 244exec_lua , 245[[ 246local api = vim.api 247local function crashes(contents) 248local buf = api.nvim_create_buf(false, true) 249local floatwin = api.nvim_open_win(buf, true, { 250relative = 'cursor'; 251style = 'minimal'; 252row = 0; col = 0; 253height = #contents; 254width = 10; 255}) 256api.nvim_buf_set_lines(buf, 0, -1, true, contents) 257local winnr = vim.fn.win_id2win(floatwin) 258api.nvim_command('wincmd p') 259api.nvim_command('autocmd BufEnter * ++once '..winnr..'wincmd c') 260return buf, floatwin 261end 262crashes{'foo'} 263crashes{'bar'} 264]] 265) 266) 267assert_alive () 268end ) 269 270it ( 'closed immediately by autocmd after win_enter #15548' , function () 271eq ( 272'Window was closed immediately' , 273pcall_err ( 274exec_lua , 275[[ 276vim.cmd "autocmd BufLeave * ++once quit!" 277local buf = vim.api.nvim_create_buf(true, true) 278vim.api.nvim_open_win(buf, true, { 279relative = "win", 280row = 0, col = 0, 281width = 1, height = 1, 282noautocmd = false, 283}) 284]] 285) 286) 287assert_alive () 288end ) 289 290it ( 'open with WinNew autocmd' , function () 291local new_triggered_before_enter , new_curwin , win =unpack ( exec_lua ( [[ 292local enter_triggered = false 293local new_triggered_before_enter = false 294local new_curwin 295local buf = vim.api.nvim_create_buf(true, true) 296vim.api.nvim_create_autocmd('WinEnter', { 297callback = function() 298enter_triggered = true 299end 300}) 301vim.api.nvim_create_autocmd('WinNew', { 302callback = function() 303new_triggered_before_enter = not enter_triggered 304new_curwin = vim.api.nvim_get_current_win() 305end 306}) 307local opts = { relative = "win", row = 0, col = 0, width = 1, height = 1, noautocmd = false } 308local win = vim.api.nvim_open_win(buf, true, opts) 309return {new_triggered_before_enter, new_curwin, win} 310]] )) 311eq ( true , new_triggered_before_enter ) 312eq ( win , new_curwin ) 313end ) 314 315it ( 'opened with correct height' , function () 316local height =exec_lua ( [[ 317vim.go.winheight = 20 318local bufnr = vim.api.nvim_create_buf(false, true) 319local opts = { height = 10, col = 5, row = 1, relative = 'editor', style = 'minimal', width = 15 } 320local win_id = vim.api.nvim_open_win(bufnr, true, opts) 321return vim.api.nvim_win_get_height(win_id) 322]] ) 323eq ( 10 , height ) 324end ) 325 326it ( 'opened with correct width' , function () 327local width =exec_lua ( [[ 328vim.go.winwidth = 20 329local bufnr = vim.api.nvim_create_buf(false, true) 330local opts = { height = 10, col = 5, row = 1, relative = 'editor', style = 'minimal', width = 10 } 331local win_id = vim.api.nvim_open_win(bufnr, true, opts) 332return vim.api.nvim_win_get_width(win_id) 333]] ) 334eq ( 10 , width ) 335end ) 336 337it ( 'opened with correct position' , function () 338local pos =exec_lua ( [[ 339local bufnr = vim.api.nvim_create_buf(false, true) 340local opts = { width = 10, height = 10, col = 7, row = 9, relative = 'editor', style = 'minimal' } 341local win_id = vim.api.nvim_open_win(bufnr, false, opts) 342return vim.api.nvim_win_get_position(win_id) 343]] ) 344eq ( { 9 , 7 } , { pos [ 1 ], pos [ 2 ] } ) 345end ) 346 347it ( 'opened with correct position relative to the mouse' , function () 348api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 10 , 10 ) 349local pos =exec_lua ( [[ 350local bufnr = vim.api.nvim_create_buf(false, true) 351local opts = { width = 10, height = 10, col = 1, row = 2, relative = 'mouse', style = 'minimal' } 352local win_id = vim.api.nvim_open_win(bufnr, false, opts) 353return vim.api.nvim_win_get_position(win_id) 354]] ) 355eq ( { 12 , 11 } , { pos [ 1 ], pos [ 2 ] } ) 356end ) 357 358it ( 'opened with correct position relative to the cursor' , function () 359local pos =exec_lua ( [[ 360local lines = {} 361for _ = 1, 100 do lines[#lines + 1] = 'foo' end 362vim.api.nvim_buf_set_lines(0, 0, -1, false, lines) 363vim.api.nvim_win_set_cursor(0, { 50, 0 }) 364vim.cmd('normal! zz') 365 366local view = vim.fn.winsaveview() 367vim.api.nvim_win_set_cursor(0, { 1, 0 }) 368vim.fn.winrestview(view) 369 370local bufnr = vim.api.nvim_create_buf(false, true) 371local opts = { width = 10, height = 10, col = 7, row = 9, relative = 'cursor', style = 'minimal' } 372local win_id = vim.api.nvim_open_win(bufnr, false, opts) 373return { vim.api.nvim_win_get_position(win_id), vim.fn.winline() - 1 } 374]] ) 375eq ( pos [ 2 ] + 9 , pos [ 1 ][ 1 ]) 376eq ( 7 , pos [ 1 ][ 2 ]) 377end ) 378 379it ( 'opened with correct position relative to another window' , function () 380local pos =exec_lua ( [[ 381local bufnr = vim.api.nvim_create_buf(false, true) 382local par_opts = { width = 50, height = 50, col = 7, row = 9, relative = 'editor', style = 'minimal' } 383local par_win_id = vim.api.nvim_open_win(bufnr, false, par_opts) 384local opts = { width = 10, height = 10, col = 7, row = 9, relative = 'win', style = 'minimal', win = par_win_id } 385local win_id = vim.api.nvim_open_win(bufnr, false, opts) 386return vim.api.nvim_win_get_position(win_id) 387]] ) 388eq ( { 18 , 14 } , { pos [ 1 ], pos [ 2 ] } ) 389end ) 390 391it ( 'opened with correct position relative to another relative window' , function () 392local pos =exec_lua ( [[ 393local bufnr = vim.api.nvim_create_buf(false, true) 394local root_opts = { width = 50, height = 50, col = 7, row = 9, relative = 'editor', style = 'minimal' } 395local root_win_id = vim.api.nvim_open_win(bufnr, false, root_opts) 396local par_opts = { width = 20, height = 20, col = 2, row = 3, relative = 'win', win = root_win_id, style = 'minimal' } 397local par_win_id = vim.api.nvim_open_win(bufnr, false, par_opts) 398local opts = { width = 10, height = 10, col = 3, row = 2, relative = 'win', win = par_win_id, style = 'minimal' } 399local win_id = vim.api.nvim_open_win(bufnr, false, opts) 400return vim.api.nvim_win_get_position(win_id) 401]] ) 402 403eq ( { 14 , 12 } , { pos [ 1 ], pos [ 2 ] } ) 404end ) 405 406it ( 'error when reconfig missing relative field' , function () 407local bufnr =api . nvim_create_buf ( false , true ) 408local opts ={ width =10 , height =10 , col =5 , row =5 , relative ='editor' , style ='minimal' } 409local winid =api . nvim_open_win ( bufnr , true , opts ) 410eq ( 411"Required: 'relative' when reconfiguring floating window 1001" , 412pcall_err ( api . nvim_win_set_config , winid , { width =3 , height =3 , row =10 , col =10 } ) 413) 414end ) 415 416it ( 'no error message when reconfig relative field on closed win' , function () 417command ( 'split' ) 418local winid =api . nvim_open_win ( 0 , false , { relative ='win' , width =1 , height =1 , col =1 , row =1 } ) 419eq ( 1001 , api . nvim_win_get_config ( winid ). win ) 420-- But unrelated config doesn't clear parent win #34286 421api . nvim_win_set_config ( winid , { title ='foo' } ) 422eq ( 1001 , api . nvim_win_get_config ( winid ). win ) 423command ( 'close' ) 424api . nvim_win_set_config ( winid , { title ='bar' } ) 425api . nvim_win_set_config ( winid , { relative ='editor' , row =1 , col =1 } ) 426eq ( nil , api . nvim_win_get_config ( winid ). win ) 427end ) 428 429it ( 'is not operated on by windo when non-focusable #15374' , function () 430command ( [[ 431let winids = [] 432windo call add(winids, win_getid()) 433]] ) 434local windo_count_before =eval ( 'len(winids)' ) 435local winid =exec_lua ( [[ 436local bufnr = vim.api.nvim_create_buf(false, true) 437local opts = { relative = 'editor', focusable = false, height = 5, width = 5, col = 5, row = 5 } 438return vim.api.nvim_open_win(bufnr, false, opts) 439]] ) 440command ( [[ 441let winids = [] 442windo call add(winids, win_getid()) 443]] ) 444local windo_count_after =eval ( 'len(winids)' ) 445eq ( windo_count_before , windo_count_after ) 446eq ( false , tbl_contains ( eval ( 'winids' ), winid )) 447end ) 448 449it ( 'is operated on by windo when focusable' , function () 450command ( [[ 451let winids = [] 452windo call add(winids, win_getid()) 453]] ) 454local windo_count_before =eval ( 'len(winids)' ) 455local winid =exec_lua ( [[ 456local bufnr = vim.api.nvim_create_buf(false, true) 457local opts = { relative = 'editor', focusable = true, height = 5, width = 5, col = 5, row = 5 } 458return vim.api.nvim_open_win(bufnr, false, opts) 459]] ) 460command ( [[ 461let winids = [] 462windo call add(winids, win_getid()) 463]] ) 464local windo_count_after =eval ( 'len(winids)' ) 465eq ( windo_count_before + 1 , windo_count_after ) 466eq ( true , tbl_contains ( eval ( 'winids' ), winid )) 467end ) 468 469it ( 'is not active after windo when non-focusable #15374' , function () 470local winid =exec_lua ( [[ 471local bufnr = vim.api.nvim_create_buf(false, true) 472local opts = { relative = 'editor', focusable = false, height = 5, width = 5, col = 5, row = 5 } 473return vim.api.nvim_open_win(bufnr, false, opts) 474]] ) 475command ( 'windo echo' ) 476neq ( winid , eval ( 'win_getid()' )) 477end ) 478 479it ( 'is active after windo when focusable' , function () 480local winid =exec_lua ( [[ 481local bufnr = vim.api.nvim_create_buf(false, true) 482local opts = { relative = 'editor', focusable = true, height = 5, width = 5, col = 5, row = 5 } 483return vim.api.nvim_open_win(bufnr, false, opts) 484]] ) 485command ( 'windo echo' ) 486eq ( winid , eval ( 'win_getid()' )) 487end ) 488 489it ( 'is not active after closing window when non-focusable #28454' , function () 490command ( 'copen' ) 491local winid =exec_lua ( [[ 492local bufnr = vim.api.nvim_create_buf(false, true) 493local opts = { relative = 'editor', focusable = false, height = 5, width = 5, col = 5, row = 5 } 494return vim.api.nvim_open_win(bufnr, false, opts) 495]] ) 496command ( 'wincmd t' ) 497command ( 'wincmd q' ) 498neq ( winid , curwin ()) 499end ) 500 501it ( 'supports windo with focusable and non-focusable floats' , function () 502local winids =exec_lua ( [[ 503local result = {vim.api.nvim_get_current_win()} 504local bufnr = vim.api.nvim_create_buf(false, true) 505local opts = { relative = 'editor', focusable = false, height = 5, width = 5, col = 5, row = 5 } 506vim.api.nvim_open_win(bufnr, false, opts) 507opts.focusable = true 508table.insert(result, vim.api.nvim_open_win(bufnr, false, opts)) 509opts.focusable = false 510vim.api.nvim_open_win(bufnr, false, opts) 511opts.focusable = true 512table.insert(result, vim.api.nvim_open_win(bufnr, false, opts)) 513opts.focusable = false 514vim.api.nvim_open_win(bufnr, false, opts) 515return result 516]] ) 517table . sort ( winids ) 518command ( [[ 519let winids = [] 520windo call add(winids, win_getid()) 521call sort(winids) 522]] ) 523eq ( winids , eval ( 'winids' )) 524end ) 525 526it ( 'open does not trigger BufEnter #15300' , function () 527local res =exec_lua [[ 528local times = {} 529local buf = vim.api.nvim_create_buf(fasle, true) 530vim.api.nvim_create_autocmd('BufEnter', { 531callback = function(opt) 532if opt.buf == buf then 533times[#times + 1] = 1 534end 535end 536}) 537local win_id 538local fconfig = { relative = 'editor', row = 10, col = 10, width = 10, height = 10 } 539--enter is false doesn't trigger 540win_id = vim.api.nvim_open_win(buf, false, fconfig) 541vim.api.nvim_win_close(win_id, true) 542times[#times + 1] = #times == 0 and true or nil 543 544--enter is true trigger 545win_id = vim.api.nvim_open_win(buf, true, fconfig) 546vim.api.nvim_win_close(win_id, true) 547times[#times + 1] = #times == 2 and true or nil 548 549--enter is true and fconfig.noautocmd is true doesn't trigger 550fconfig.noautocmd = true 551win_id = vim.api.nvim_open_win(buf, true, fconfig) 552vim.api.nvim_win_close(win_id, true) 553times[#times + 1] = #times == 2 and true or nil 554 555return times 556]] 557eq ( { true , 1 , true } , res ) 558end ) 559 560it ( 'no crash with bufpos and non-existent window' , function () 561command ( 'new' ) 562local closed_win =api . nvim_get_current_win () 563command ( 'close' ) 564local buf =api . nvim_create_buf ( false , false ) 565eq ( 566'Invalid window id: ' .. closed_win , 567pcall_err ( api . nvim_open_win , buf , true , { relative ='win' , win =closed_win , width =1 , height =1 , bufpos ={ 0 , 0 } } ) 568) 569assert_alive () 570end ) 571 572it ( "no segfault when setting minimal style after clearing local 'fillchars' #19510" , function () 573local float_opts ={ relative ='editor' , row =1 , col =1 , width =1 , height =1 } 574local float_win =api . nvim_open_win ( 0 , true , float_opts ) 575api . nvim_set_option_value ( 'fillchars' , NIL , { win =float_win } ) 576float_opts . style ='minimal' 577api . nvim_win_set_config ( float_win , float_opts ) 578assert_alive () 579end ) 580 581it ( "should not leak 'style' option values to normal windows" , function () 582local buf =api . nvim_create_buf ( true , false ) 583local buf2 =api . nvim_create_buf ( true , false ) 584local float_opts ={ style ='minimal' , relative ='editor' , row =1 , col =1 , width =1 , height =1 } 585local float_win =api . nvim_open_win ( buf , true , float_opts ) 586-- minimal float should preserve its own options when switching buffers 587api . nvim_set_option_value ( 'listchars' , 'extends:…,precedes:…' , { win =float_win , scope ='local' } ) 588api . nvim_win_set_buf ( float_win , buf2 ) 589api . nvim_win_set_buf ( float_win , buf ) 590eq ( 'extends:…,precedes:…' , api . nvim_get_option_value ( 'listchars' , { win =float_win , scope ='local' } )) 591-- closing the float should not leak minimal style options to normal windows 592api . nvim_win_close ( float_win , true ) 593api . nvim_set_option_value ( 'number' , true , { win =0 } ) 594command ( 'bnext' ) 595eq ( true , api . nvim_get_option_value ( 'number' , { win =0 } )) 596end ) 597 598it ( 'style=minimal options should not leak to other windows via wininfo' , function () 599command ( 'set noswapfile cursorline' ) 600command ( 'edit foo' ) 601local foo_buf =api . nvim_get_current_buf () 602fn . setline ( 1 , 'foo' ) 603command ( 'edit bar' ) 604local bar_buf =api . nvim_get_current_buf () 605fn . setline ( 1 , 'bar' ) 606local float_opts ={ style ='minimal' , relative ='editor' , row =5 , col =5 , width =5 , height =5 } 607local minimal_win =api . nvim_open_win ( foo_buf , false , float_opts ) 608eq ( false , api . nvim_get_option_value ( 'cursorline' , { win =minimal_win } )) 609api . nvim_win_set_buf ( minimal_win , bar_buf ) 610eq ( '' , api . nvim_win_get_config ( 0 ). relative ) 611command ( 'split foo' ) 612eq ( true , api . nvim_get_option_value ( 'cursorline' , { win =0 } )) 613end ) 614 615it ( "should not re-apply 'style' when missing" , function () 616local float_opts ={ style ='minimal' , relative ='editor' , row =1 , col =1 , width =1 , height =1 } 617local float_win =api . nvim_open_win ( 0 , true , float_opts ) 618api . nvim_set_option_value ( 'number' , true , { win =float_win } ) 619float_opts . row =2 620float_opts . style =nil 621api . nvim_win_set_config ( float_win , float_opts ) 622eq ( true , api . nvim_get_option_value ( 'number' , { win =float_win } )) 623end ) 624 625it ( "'scroll' is computed correctly when opening float with splitkeep=screen #20684" , function () 626api . nvim_set_option_value ( 'splitkeep' , 'screen' , {} ) 627local float_opts ={ relative ='editor' , row =1 , col =1 , width =10 , height =10 } 628local float_win =api . nvim_open_win ( 0 , true , float_opts ) 629eq ( 5 , api . nvim_get_option_value ( 'scroll' , { win =float_win } )) 630end ) 631 632it ( "lines('w$') after nvim_win_set_height with 'splitkeep=screen' #36056" , function () 633api . nvim_set_option_value ( 'splitkeep' , 'screen' , {} ) 634local buf =api . nvim_create_buf ( false , true ) 635local win =api . nvim_open_win ( buf , false , { width =5 , height =1 , col =0 , row =0 , relative ='cursor' } ) 636api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { ( '1' ): rep ( 10 ), ( '2' ): rep ( 10 ) } ) 637local line =exec_lua ( function () 638vim . api . nvim_win_set_height ( win , vim . api . nvim_win_get_height ( win ) + 3 ) 639return vim . fn . line ( 'w$' , win ) 640end ) 641eq ( 2 , line ) 642end ) 643 644it ( ':unhide works when there are floating windows' , function () 645local float_opts ={ relative ='editor' , row =1 , col =1 , width =5 , height =5 } 646local w0 =curwin () 647api . nvim_open_win ( 0 , false , float_opts ) 648api . nvim_open_win ( 0 , false , float_opts ) 649eq ( 3 , # api . nvim_list_wins ()) 650command ( 'unhide' ) 651eq ( { w0 } , api . nvim_list_wins ()) 652end ) 653 654it ( ':all works when there are floating windows' , function () 655command ( 'args Xa.txt' ) 656local float_opts ={ relative ='editor' , row =1 , col =1 , width =5 , height =5 } 657local w0 =curwin () 658api . nvim_open_win ( 0 , false , float_opts ) 659api . nvim_open_win ( 0 , false , float_opts ) 660eq ( 3 , # api . nvim_list_wins ()) 661command ( 'all' ) 662eq ( { w0 } , api . nvim_list_wins ()) 663end ) 664 665it ( 'win_splitmove() can move float into a split' , function () 666command ( 'split' ) 667eq ( { 'col' , { { 'leaf' , 1001 } , { 'leaf' , 1000 } } } , fn . winlayout ()) 668 669local win1 =api . nvim_open_win ( 0 , true , { relative ='editor' , row =1 , col =1 , width =5 , height =5 } ) 670fn . win_splitmove ( win1 , 1001 , { vertical =true } ) 671eq ( { 'col' , { { 'row' , { { 'leaf' , win1 } , { 'leaf' , 1001 } } } , { 'leaf' , 1000 } } } , fn . winlayout ()) 672eq ( '' , api . nvim_win_get_config ( win1 ). relative ) 673 674-- Should be unable to create a split relative to a float, though. 675local win2 =api . nvim_open_win ( 0 , true , { relative ='editor' , row =1 , col =1 , width =5 , height =5 } ) 676eq ( 'Vim:E957: Invalid window number' , pcall_err ( fn . win_splitmove , win1 , win2 , { vertical =true } )) 677end ) 678 679it ( 'tp_curwin updated if external window is moved into split' , function () 680local _ =Screen . new ( 20 , 7 , { ext_multigrid =true } ) 681 682command ( 'tabnew' ) 683local external_win =api . nvim_open_win ( 0 , true , { external =true , width =5 , height =5 } ) 684eq ( external_win , api . nvim_get_current_win ()) 685eq ( 2 , fn . tabpagenr ()) 686command ( 'tabfirst' ) 687api . nvim_set_current_win ( external_win ) 688eq ( external_win , api . nvim_get_current_win ()) 689eq ( 1 , fn . tabpagenr ()) 690 691command ( 'wincmd J' ) 692eq ( external_win , api . nvim_get_current_win ()) 693eq ( false , api . nvim_win_get_config ( external_win ). external ) 694command ( 'tabnext' ) 695eq ( 2 , fn . tabpagenr ()) 696neq ( external_win , api . nvim_get_current_win ()) 697end ) 698 699it ( 'no crash with relative="win" after %bdelete #30569' , function () 700exec ( [[ 701botright vsplit 702%bdelete 703]] ) 704api . nvim_open_win ( 0 , false , { relative ='win' , win =0 , row =0 , col =5 , width =5 , height =5 } ) 705assert_alive () 706end ) 707 708describe ( 'with only one tabpage,' , function () 709local float_opts ={ relative ='editor' , row =1 , col =1 , width =1 , height =1 } 710local old_buf , old_win 711before_each ( function () 712insert ( 'foo' ) 713old_buf =curbuf () 714old_win =curwin () 715end ) 716describe ( 'closing the last non-floating window gives E444' , function () 717before_each ( function () 718api . nvim_open_win ( old_buf , true , float_opts ) 719end ) 720it ( 'if called from non-floating window' , function () 721api . nvim_set_current_win ( old_win ) 722eq ( 'Vim:E444: Cannot close last window' , pcall_err ( api . nvim_win_close , old_win , false )) 723-- Start with many tab pages, but make autocommands from closing floats leave us with just 724-- one (where we're now the last window). 725command ( 'tabnew | autocmd WinClosed * ++once tabonly' ) 726api . nvim_open_win ( 0 , false , float_opts ) 727eq ( 'Vim:E444: Cannot close last window' , pcall_err ( api . nvim_win_close , 0 , true )) 728end ) 729it ( 'if called from floating window' , function () 730eq ( 'Vim:E444: Cannot close last window' , pcall_err ( api . nvim_win_close , old_win , false )) 731end ) 732end ) 733describe ( "deleting the last non-floating window's buffer" , function () 734describe ( 'leaves one window with an empty buffer when there is only one buffer' , function () 735local same_buf_float 736before_each ( function () 737same_buf_float =api . nvim_open_win ( old_buf , false , float_opts ) 738end ) 739after_each ( function () 740eq ( old_win , curwin ()) 741expect ( '' ) 742eq ( 1 , # api . nvim_list_wins ()) 743end ) 744it ( 'if called from non-floating window' , function () 745api . nvim_buf_delete ( old_buf , { force =true } ) 746end ) 747it ( 'if called from floating window' , function () 748api . nvim_set_current_win ( same_buf_float ) 749command ( 'autocmd WinLeave * let g:win_leave = nvim_get_current_win()' ) 750command ( 'autocmd WinEnter * let g:win_enter = nvim_get_current_win()' ) 751api . nvim_buf_delete ( old_buf , { force =true } ) 752eq ( same_buf_float , eval ( 'g:win_leave' )) 753eq ( old_win , eval ( 'g:win_enter' )) 754end ) 755end ) 756describe ( 'closes other windows with that buffer when there are other buffers' , function () 757local same_buf_float , other_buf , other_buf_float 758before_each ( function () 759same_buf_float =api . nvim_open_win ( old_buf , false , float_opts ) 760other_buf =api . nvim_create_buf ( true , false ) 761other_buf_float =api . nvim_open_win ( other_buf , true , float_opts ) 762insert ( 'bar' ) 763api . nvim_set_current_win ( old_win ) 764end ) 765after_each ( function () 766eq ( other_buf , curbuf ()) 767expect ( 'bar' ) 768eq ( 2 , # api . nvim_list_wins ()) 769end ) 770it ( 'if called from non-floating window' , function () 771api . nvim_buf_delete ( old_buf , { force =true } ) 772eq ( old_win , curwin ()) 773end ) 774it ( 'if called from floating window with the same buffer' , function () 775api . nvim_set_current_win ( same_buf_float ) 776command ( 'autocmd WinLeave * let g:win_leave = nvim_get_current_win()' ) 777command ( 'autocmd WinEnter * let g:win_enter = nvim_get_current_win()' ) 778api . nvim_buf_delete ( old_buf , { force =true } ) 779eq ( same_buf_float , eval ( 'g:win_leave' )) 780eq ( old_win , eval ( 'g:win_enter' )) 781eq ( old_win , curwin ()) 782end ) 783it ( 'if called from floating window with another buffer' , function () 784api . nvim_set_current_win ( other_buf_float ) 785api . nvim_buf_delete ( old_buf , { force =true } ) 786eq ( other_buf_float , curwin ()) 787end ) 788end ) 789describe ( 'creates an empty buffer when there is only one listed buffer' , function () 790local same_buf_float , unlisted_buf_float 791before_each ( function () 792same_buf_float =api . nvim_open_win ( old_buf , false , float_opts ) 793local unlisted_buf =api . nvim_create_buf ( true , false ) 794unlisted_buf_float =api . nvim_open_win ( unlisted_buf , true , float_opts ) 795insert ( 'unlisted' ) 796command ( 'set nobuflisted' ) 797api . nvim_set_current_win ( old_win ) 798end ) 799it ( 'if called from non-floating window' , function () 800api . nvim_buf_delete ( old_buf , { force =true } ) 801eq ( old_win , curwin ()) 802expect ( '' ) 803eq ( 2 , # api . nvim_list_wins ()) 804end ) 805it ( 'if called from floating window with the same buffer' , function () 806api . nvim_set_current_win ( same_buf_float ) 807command ( 'autocmd WinLeave * let g:win_leave = nvim_get_current_win()' ) 808command ( 'autocmd WinEnter * let g:win_enter = nvim_get_current_win()' ) 809api . nvim_buf_delete ( old_buf , { force =true } ) 810eq ( same_buf_float , eval ( 'g:win_leave' )) 811eq ( old_win , eval ( 'g:win_enter' )) 812eq ( old_win , curwin ()) 813expect ( '' ) 814eq ( 2 , # api . nvim_list_wins ()) 815end ) 816it ( 'if called from floating window with an unlisted buffer' , function () 817api . nvim_set_current_win ( unlisted_buf_float ) 818api . nvim_buf_delete ( old_buf , { force =true } ) 819eq ( unlisted_buf_float , curwin ()) 820expect ( 'unlisted' ) 821eq ( '' , fn . bufname ( api . nvim_win_get_buf ( old_win ))) 822eq ( false , api . nvim_buf_is_valid ( old_buf )) 823eq ( 2 , # api . nvim_list_wins ()) 824end ) 825end ) 826it ( 'keeps focus in the floating window #39800' , function () 827api . nvim_open_win ( old_buf , false , float_opts ) 828local other_float =api . nvim_open_win ( api . nvim_create_buf ( true , false ), true , float_opts ) 829api . nvim_buf_delete ( old_buf , { force =true } ) 830eq ( other_float , curwin ()) 831end ) 832 833it ( 'does not trigger BufEnter for deleted buffer #39800' , function () 834api . nvim_open_win ( old_buf , false , float_opts ) 835api . nvim_open_win ( api . nvim_create_buf ( true , false ), true , float_opts ) 836command ( 'let g:abufs = []' ) 837command ( 'autocmd BufEnter * call add(g:abufs, +expand("<abuf>"))' ) 838api . nvim_buf_delete ( old_buf , { force =true } ) 839for _ , b in ipairs ( eval ( 'g:abufs' )) do 840neq ( old_buf , b ) 841end 842end ) 843end ) 844describe ( 'with splits, deleting the last listed buffer creates an empty buffer' , function () 845describe ( 'when a non-floating window has an unlisted buffer' , function () 846local same_buf_float 847before_each ( function () 848command ( 'botright vnew' ) 849insert ( 'unlisted' ) 850command ( 'set nobuflisted' ) 851api . nvim_set_current_win ( old_win ) 852same_buf_float =api . nvim_open_win ( old_buf , false , float_opts ) 853end ) 854after_each ( function () 855expect ( '' ) 856eq ( 2 , # api . nvim_list_wins ()) 857end ) 858it ( 'if called from non-floating window with the deleted buffer' , function () 859api . nvim_buf_delete ( old_buf , { force =true } ) 860eq ( old_win , curwin ()) 861end ) 862it ( 'if called from floating window with the deleted buffer' , function () 863api . nvim_set_current_win ( same_buf_float ) 864api . nvim_buf_delete ( old_buf , { force =true } ) 865eq ( same_buf_float , curwin ()) 866end ) 867end ) 868end ) 869end ) 870 871describe ( 'with multiple tabpages but only one listed buffer,' , function () 872local float_opts ={ relative ='editor' , row =1 , col =1 , width =1 , height =1 } 873local unlisted_buf , old_buf , old_win 874before_each ( function () 875insert ( 'unlisted' ) 876command ( 'set nobuflisted' ) 877unlisted_buf =curbuf () 878command ( 'tabnew' ) 879insert ( 'foo' ) 880old_buf =curbuf () 881old_win =curwin () 882end ) 883describe ( 'without splits, deleting the last listed buffer creates an empty buffer' , function () 884local same_buf_float 885before_each ( function () 886api . nvim_set_current_win ( old_win ) 887same_buf_float =api . nvim_open_win ( old_buf , false , float_opts ) 888end ) 889after_each ( function () 890expect ( '' ) 891eq ( 2 , # api . nvim_list_wins ()) 892eq ( 2 , # api . nvim_list_tabpages ()) 893end ) 894it ( 'if called from non-floating window' , function () 895api . nvim_buf_delete ( old_buf , { force =true } ) 896eq ( old_win , curwin ()) 897end ) 898it ( 'if called from non-floating window in another tabpage' , function () 899command ( 'tab split' ) 900eq ( 3 , # api . nvim_list_tabpages ()) 901api . nvim_buf_delete ( old_buf , { force =true } ) 902end ) 903it ( 'if called from floating window with the same buffer' , function () 904api . nvim_set_current_win ( same_buf_float ) 905command ( 'autocmd WinLeave * let g:win_leave = nvim_get_current_win()' ) 906command ( 'autocmd WinEnter * let g:win_enter = nvim_get_current_win()' ) 907api . nvim_buf_delete ( old_buf , { force =true } ) 908eq ( same_buf_float , eval ( 'g:win_leave' )) 909eq ( old_win , eval ( 'g:win_enter' )) 910eq ( old_win , curwin ()) 911end ) 912end ) 913describe ( 'with splits, deleting the last listed buffer creates an empty buffer' , function () 914local same_buf_float 915before_each ( function () 916command ( 'botright vsplit' ) 917api . nvim_set_current_buf ( unlisted_buf ) 918api . nvim_set_current_win ( old_win ) 919same_buf_float =api . nvim_open_win ( old_buf , false , float_opts ) 920end ) 921after_each ( function () 922expect ( '' ) 923eq ( 3 , # api . nvim_list_wins ()) 924eq ( 2 , # api . nvim_list_tabpages ()) 925end ) 926it ( 'if called from non-floating window with the deleted buffer' , function () 927api . nvim_buf_delete ( old_buf , { force =true } ) 928eq ( old_win , curwin ()) 929end ) 930it ( 'if called from floating window with the deleted buffer' , function () 931api . nvim_set_current_win ( same_buf_float ) 932api . nvim_buf_delete ( old_buf , { force =true } ) 933eq ( same_buf_float , curwin ()) 934end ) 935end ) 936end ) 937 938describe ( 'with multiple tabpages and multiple listed buffers,' , function () 939local float_opts ={ relative ='editor' , row =1 , col =1 , width =1 , height =1 } 940local old_tabpage , old_buf , old_win 941before_each ( function () 942old_tabpage =curtab () 943insert ( 'oldtab' ) 944command ( 'tabnew' ) 945old_buf =curbuf () 946old_win =curwin () 947end ) 948describe ( 'closing the last non-floating window' , function () 949describe ( 'closes the tabpage when all floating windows are closeable' , function () 950local same_buf_float 951before_each ( function () 952same_buf_float =api . nvim_open_win ( old_buf , false , float_opts ) 953end ) 954after_each ( function () 955eq ( old_tabpage , curtab ()) 956expect ( 'oldtab' ) 957eq ( 1 , # api . nvim_list_tabpages ()) 958end ) 959it ( 'if called from non-floating window' , function () 960api . nvim_win_close ( old_win , false ) 961end ) 962it ( 'if called from floating window' , function () 963api . nvim_set_current_win ( same_buf_float ) 964api . nvim_win_close ( old_win , false ) 965end ) 966end ) 967describe ( 'gives E5601 when there are non-closeable floating windows' , function () 968local other_buf_float 969before_each ( function () 970command ( 'set nohidden' ) 971local other_buf =api . nvim_create_buf ( true , false ) 972other_buf_float =api . nvim_open_win ( other_buf , true , float_opts ) 973insert ( 'foo' ) 974api . nvim_set_current_win ( old_win ) 975end ) 976it ( 'if called from non-floating window' , function () 977eq ( 'Vim:E5601: Cannot close window, only floating window would remain' , pcall_err ( api . nvim_win_close , old_win , false )) 978end ) 979it ( 'if called from floating window' , function () 980api . nvim_set_current_win ( other_buf_float ) 981eq ( 'Vim:E5601: Cannot close window, only floating window would remain' , pcall_err ( api . nvim_win_close , old_win , false )) 982end ) 983end ) 984end ) 985describe ( "deleting the last non-floating window's buffer" , function () 986describe ( 'closes the tabpage when all floating windows are closeable' , function () 987local same_buf_float , other_buf , other_buf_float 988before_each ( function () 989same_buf_float =api . nvim_open_win ( old_buf , false , float_opts ) 990other_buf =api . nvim_create_buf ( true , false ) 991other_buf_float =api . nvim_open_win ( other_buf , true , float_opts ) 992api . nvim_set_current_win ( old_win ) 993end ) 994after_each ( function () 995eq ( old_tabpage , curtab ()) 996expect ( 'oldtab' ) 997eq ( 1 , # api . nvim_list_tabpages ()) 998end ) 999it ( 'if called from non-floating window' , function () 1000api . nvim_buf_delete ( old_buf , { force =false } ) 1001end ) 1002it ( 'if called from floating window with the same buffer' , function () 1003api . nvim_set_current_win ( same_buf_float ) 1004api . nvim_buf_delete ( old_buf , { force =false } ) 1005end ) 1006it ( 'if called from floating window with another buffer' , function () 1007api . nvim_set_current_win ( other_buf_float ) 1008api . nvim_buf_delete ( old_buf , { force =false } ) 1009end ) 1010end ) 1011-- TODO: what to do when there are non-closeable floating windows? 1012end ) 1013end ) 1014 1015describe ( ':close on non-float with floating windows' , function () 1016-- XXX: it isn't really clear whether this should quit Nvim, as if the autocommand 1017-- here is BufUnload then it does quit Nvim. 1018-- But with BufWinLeave, this doesn't quit Nvim if there are no floating windows, 1019-- so it shouldn't quit Nvim if there are floating windows. 1020it ( 'does not quit Nvim if BufWinLeave makes it the only non-float' , function () 1021exec ( [[ 1022let g:buf = bufnr() 1023new 1024let s:midwin = win_getid() 1025new 1026setlocal bufhidden=wipe 1027call nvim_win_set_config(s:midwin, 1028\ #{relative: 'editor', row: 5, col: 5, width: 5, height: 5}) 1029autocmd BufWinLeave * ++once exe g:buf .. 'bwipe!' 1030]] ) 1031eq ( 'Vim(close):E855: Autocommands caused command to abort' , pcall_err ( command , 'close' )) 1032assert_alive () 1033end ) 1034 1035it ( 'does not crash if BufUnload makes it the only non-float in tabpage' , function () 1036exec ( [[ 1037tabnew 1038let g:buf = bufnr() 1039new 1040let s:midwin = win_getid() 1041new 1042setlocal bufhidden=wipe 1043call nvim_win_set_config(s:midwin, 1044\ #{relative: 'editor', row: 5, col: 5, width: 5, height: 5}) 1045autocmd BufUnload * ++once exe g:buf .. 'bwipe!' 1046]] ) 1047eq ( 'Vim(close):E5601: Cannot close window, only floating window would remain' , pcall_err ( command , 'close' )) 1048assert_alive () 1049end ) 1050 1051describe ( 'does not crash if WinClosed makes it the only non-float' , function () 1052before_each ( function () 1053exec ( [[ 1054let g:buf = bufnr() 1055new 1056setlocal bufhidden=wipe 1057autocmd WinClosed * ++once exe g:buf .. 'bwipe!' 1058]] ) 1059end ) 1060 1061local opts ={ relative ='editor' , row =5 , col =5 , width =5 , height =5 } 1062local floatwin 1063 1064describe ( 'and there is a float window with the same buffer' , function () 1065before_each ( function () 1066floatwin =api . nvim_open_win ( 0 , false , opts ) 1067end ) 1068 1069it ( 'with multiple tabpages' , function () 1070command ( 'tabnew | tabprev' ) 1071eq ( 'Vim(close):E5601: Cannot close window, only floating window would remain' , pcall_err ( command , 'close' )) 1072api . nvim_win_close ( floatwin , true ) 1073assert_alive () 1074end ) 1075 1076it ( 'with only one tabpage' , function () 1077command ( 'close' ) 1078api . nvim_win_close ( floatwin , true ) 1079assert_alive () 1080end ) 1081end ) 1082 1083describe ( 'and there is a float with a different buffer' , function () 1084before_each ( function () 1085floatwin =api . nvim_open_win ( api . nvim_create_buf ( true , false ), false , opts ) 1086end ) 1087 1088it ( 'with multiple tabpages' , function () 1089command ( 'tabnew | tabprev' ) 1090eq ( 'Vim(close):E855: Autocommands caused command to abort' , pcall_err ( command , 'close' )) 1091assert_alive () 1092end ) 1093 1094it ( 'with only one tabpage' , function () 1095eq ( 'Vim(close):E855: Autocommands caused command to abort' , pcall_err ( command , 'close' )) 1096assert_alive () 1097end ) 1098end ) 1099end ) 1100 1101it ( 'does not crash if WinClosed from floating window closes it' , function () 1102exec ( [[ 1103tabnew 1104new 1105let s:win = win_getid() 1106call nvim_win_set_config(s:win, 1107\ #{relative: 'editor', row: 5, col: 5, width: 5, height: 5}) 1108wincmd t 1109exe $"autocmd WinClosed {s:win} 1close" 1110]] ) 1111command ( 'close' ) 1112assert_alive () 1113end ) 1114 1115it ( 'does not unload bufhidden=hide buffer' , function () 1116local buf =api . nvim_create_buf ( false , true ) 1117command ( 'set nohidden' ) 1118api . nvim_open_tabpage ( 0 , true , {} ) 1119api . nvim_open_win ( buf , false , { relative ='editor' , width =1 , height =1 , row =0 , col =0 } ) 1120command ( 'close!' ) 1121eq ( true , api . nvim_buf_is_loaded ( buf )) 1122end ) 1123end ) 1124 1125it ( 'placed relative to tabline and laststatus' , function () 1126local screen =Screen . new ( 20 , 10 ) 1127screen : add_extra_attr_ids ( { [ 100 ] ={ bold =true , foreground =Screen . colors . Magenta } } ) 1128command ( 'set showtabline=1 laststatus=1' ) 1129api . nvim_open_win ( 0 , false , { relative ='laststatus' , border ='single' , anchor ='SE' , width =5 , height =1 , row =0 , col =1000 } ) 1130local tabwin =api . nvim_open_win ( 0 , false , { relative ='tabline' , border ='single' , width =5 , height =1 , row =0 , col =1000 } ) 1131screen : expect ( [[ 1132^ {31:┌─────┐}| 1133{1:~ }{31:│}{4: }{31:│}| 1134{1:~ }{31:└─────┘}| 1135{1:~ }|*3 1136{1:~ }{31:┌─────┐}| 1137{1:~ }{31:│}{4: }{31:│}| 1138{1:~ }{31:└─────┘}| 1139| 1140]] ) 1141command ( 'tabnew | tabnext' ) 1142screen : expect ( [[ 1143{5: }{100:3}{5: Name] }{24: No Name]X}| 1144^ {31:┌─────┐}| 1145{1:~ }{31:│}{4: }{31:│}| 1146{1:~ }{31:└─────┘}| 1147{1:~ }|*2 1148{1:~ }{31:┌─────┐}| 1149{1:~ }{31:│}{4: }{31:│}| 1150{1:~ }{31:└─────┘}| 1151| 1152]] ) 1153command ( 'vsplit' ) 1154screen : expect ( [[ 1155{5: }{100:4}{5: Name] }{24: No Name]X}| 1156^ {31:┌─────┐}| 1157{1:~ }{31:│}{4: }{31:│}| 1158{1:~ }{31:└─────┘}| 1159{1:~ }{2:│}{1:~}| 1160{1:~ }{31:┌─────┐}| 1161{1:~ }{31:│}{4: }{31:│}| 1162{1:~ }{31:└─────┘}| 1163{3:[No Name] }{2:<}| 1164| 1165]] ) 1166command ( 'quit' ) 1167api . nvim_win_set_config ( tabwin , { relative ='tabline' , border ='single' , width =5 , height =1 , row =1 , col =0 } ) 1168screen : expect ( [[ 1169{5: }{100:3}{5: Name] }{24: No Name]X}| 1170^ | 1171{31:┌─────┐}{1: }| 1172{31:│}{4: }{31:│}{1: }| 1173{31:└─────┘}{1: }| 1174{1:~ }| 1175{1:~ }{31:┌─────┐}| 1176{1:~ }{31:│}{4: }{31:│}| 1177{1:~ }{31:└─────┘}| 1178| 1179]] ) 1180command ( 'tabonly' ) 1181screen : expect ( [[ 1182^ | 1183{31:┌─────┐}{1: }| 1184{31:│}{4: }{31:│}{1: }| 1185{31:└─────┘}{1: }| 1186{1:~ }|*2 1187{1:~ }{31:┌─────┐}| 1188{1:~ }{31:│}{4: }{31:│}| 1189{1:~ }{31:└─────┘}| 1190| 1191]] ) 1192end ) 1193 1194it ( 'non-visible/focusable are not assigned a window number' , function () 1195command ( 'tabnew' ) 1196local tp =api . nvim_get_current_tabpage () 1197local split_win =api . nvim_get_current_win () 1198local float_buf =api . nvim_create_buf ( true , true ) 1199local win =api . nvim_open_win ( float_buf , false , { relative ='editor' , width =2 , height =2 , row =2 , col =2 , focusable =false } ) 1200api . nvim_open_win ( 0 , false , { relative ='editor' , width =2 , height =2 , row =2 , col =2 , hide =true } ) 1201api . nvim_open_win ( 0 , false , { relative ='editor' , width =2 , height =2 , row =2 , col =2 } ) 1202 1203eq ( 2 , fn . winnr ( '$' )) 1204eq ( 0 , fn . win_id2win ( win )) 1205eq ( 0 , fn . getwininfo ( win )[ 1 ]. winnr ) 1206eq ( { 0 , 0 } , fn . win_id2tabwin ( win )) 1207eq ( 2 , fn . tabpagewinnr ( 2 , '$' )) 1208eq ( 0 , fn . win_getid ( 3 )) 1209eq ( 0 , fn . win_getid ( 3 , 2 )) 1210eq ( - 1 , fn . bufwinnr ( float_buf )) 1211eq ( win , fn . bufwinid ( float_buf )) -- bufwinid unaffected. 1212eq ( nil , fn . winrestcmd (): match ( '3resize' )) 1213 1214-- Unless it is the current window. 1215api . nvim_set_current_win ( win ) 1216eq ( 3 , fn . winnr ( '$' )) 1217eq ( 3 , fn . winnr ()) 1218eq ( 3 , fn . win_id2win ( win )) 1219eq ( 3 , fn . getwininfo ( win )[ 1 ]. winnr ) 1220eq ( { 2 , 3 } , fn . win_id2tabwin ( win )) 1221eq ( 3 , fn . tabpagewinnr ( 2 , '$' )) 1222eq ( 3 , fn . tabpagewinnr ( 2 )) 1223eq ( win , fn . win_getid ( 3 )) 1224eq ( win , fn . win_getid ( 3 , 2 )) 1225eq ( 3 , fn . bufwinnr ( float_buf )) 1226matches ( '3resize' , fn . winrestcmd ()) 1227 1228-- When switching tabpages it should still have a winnr, as it's current in the other tabpage. 1229command ( 'tabfirst' ) 1230eq ( { 2 , 3 } , fn . win_id2tabwin ( win )) 1231eq ( 3 , fn . getwininfo ( win )[ 1 ]. winnr ) 1232eq ( win , fn . win_getid ( 3 , 2 )) 1233eq ( 3 , fn . tabpagewinnr ( 2 , '$' )) 1234eq ( 3 , fn . tabpagewinnr ( 2 )) 1235 1236-- ...but not if it's non-current in that tabpage. 1237api . nvim_tabpage_set_win ( tp , split_win ) 1238eq ( { 0 , 0 } , fn . win_id2tabwin ( win )) 1239eq ( 0 , fn . getwininfo ( win )[ 1 ]. winnr ) 1240eq ( 0 , fn . win_getid ( 3 , 2 )) 1241eq ( 2 , fn . tabpagewinnr ( 2 , '$' )) 1242eq ( 1 , fn . tabpagewinnr ( 2 )) 1243end ) 1244 1245it ( 'non-visible/focusable is not a valid previous window' , function () 1246local win =api . nvim_open_win ( 0 , true , { relative ='editor' , width =2 , height =2 , row =2 , col =2 , focusable =false } ) 1247command ( 'wincmd p' ) 1248command ( 'wincmd p' ) 1249neq ( win , api . nvim_get_current_win ()) 1250api . nvim_win_set_config ( win , { focusable =true , hide =true } ) 1251command ( 'wincmd p' ) 1252neq ( win , api . nvim_get_current_win ()) 1253api . nvim_win_set_config ( win , { hide =false } ) 1254command ( 'wincmd p' ) 1255eq ( win , api . nvim_get_current_win ()) 1256end ) 1257 1258it ( 'no crash for unallocated relative window grid' , function () 1259local win =api . nvim_open_win ( 0 , false , { relative ='editor' , row =0 , col =0 , height =1 , width =1 } ) 1260exec_lua ( function () 1261vim . api . nvim_create_autocmd ( 'CmdwinEnter' , { 1262callback =function () 1263vim . api . nvim_win_set_config ( win , { relative ='win' , win =0 , row =0 , col =0 } ) 1264vim . api . nvim__redraw ( { flush =true } ) 1265end , 1266} ) 1267end ) 1268feed ( 'q:' ) 1269assert_alive () 1270end ) 1271 1272it ( "no error for zero height with 'winminheight'" , function () 1273local win =api . nvim_open_win ( 0 , false , { relative ='editor' , row =0 , col =0 , height =1 , width =1 } ) 1274api . nvim_set_option_value ( 'winminheight' , 0 , {} ) 1275api . nvim_win_set_height ( win , 0 ) 1276api . nvim_win_set_config ( win , api . nvim_win_get_config ( win )) 1277end ) 1278 1279it ( ':fclose does not crash from nasty autocommands' , function () 1280local w1 =api . nvim_open_win ( 0 , false , { relative ='editor' , row =0 , col =0 , width =5 , height =5 , zindex =6 } ) 1281local w2 =api . nvim_open_win ( 0 , false , { relative ='editor' , row =0 , col =0 , width =5 , height =5 , zindex =5 } ) 1282local w3 =api . nvim_open_win ( 0 , false , { relative ='editor' , row =0 , col =0 , width =5 , height =5 , zindex =4 } ) 1283local w4 =api . nvim_open_win ( 0 , true , { relative ='editor' , row =0 , col =0 , width =5 , height =5 , zindex =3 } ) 1284exec_lua ( function () 1285vim . api . nvim_create_autocmd ( 'WinClosed' , { 1286once =true , 1287callback =function () 1288vim . api . nvim_win_close ( w2 , true ) 1289end , 1290} ) 1291end ) 1292-- We close just the first three floats with highest zindex, so w4 remains open. 1293-- (despite w2 being closed early by the autocommand rather than directly by :fclose) 1294command ( '3fclose' ) 1295eq ( false , api . nvim_win_is_valid ( w1 )) 1296eq ( false , api . nvim_win_is_valid ( w2 )) 1297eq ( false , api . nvim_win_is_valid ( w3 )) 1298eq ( true , api . nvim_win_is_valid ( w4 )) 1299 1300-- Try switching tab pages and moving windows between tab pages via nvim_win_set_config. 1301-- Simplest if :fclose skips windows in non-current tabpages. 1302local w5 =api . nvim_open_win ( 0 , false , { relative ='editor' , row =0 , col =0 , width =5 , height =5 , zindex =2 } ) 1303command ( 'tabnew | tabprevious' ) 1304command ( 'autocmd WinEnter * ++once tabnext' ) 1305eq ( w4 , api . nvim_get_current_win ()) 1306local tp1 =api . nvim_get_current_tabpage () 1307command ( 'fclose!' ) 1308eq ( false , api . nvim_win_is_valid ( w4 )) 1309eq ( true , api . nvim_win_is_valid ( w5 )) 1310neq ( tp1 , api . nvim_get_current_tabpage ()) 1311 1312local w_tp2 =api . nvim_get_current_win () 1313api . nvim_set_current_tabpage ( tp1 ) 1314local w6 =api . nvim_open_win ( 0 , false , { relative ='editor' , row =0 , col =0 , width =5 , height =5 , zindex =1 } ) 1315exec_lua ( function () 1316vim . api . nvim_create_autocmd ( 'WinClosed' , { 1317once =true , 1318callback =function () 1319vim . api . nvim_win_set_config ( w6 , { win =w_tp2 , split ='below' } ) 1320end , 1321} ) 1322end ) 1323command ( 'fclose!' ) 1324eq ( false , api . nvim_win_is_valid ( w5 )) 1325eq ( true , api . nvim_win_is_valid ( w6 )) 1326neq ( tp1 , api . nvim_win_get_tabpage ( w6 )) 1327end ) 1328 1329it ( 'compositor clears old position when configuring reallocates grid #38143' , function () 1330local screen =Screen . new () 1331local w1 =api . nvim_open_win ( 0 , true , { relative ='editor' , border ='single' , row =0 , col =0 , width =5 , height =5 } ) 1332screen : expect ( [[ 1333{31:┌─────┐} | 1334{31:│}{4:^ }{31:│}{1: }| 1335{31:│}{11:~ }{31:│}{1: }|*4 1336{31:└─────┘}{1: }| 1337{1:~ }|*6 1338| 1339]] ) 1340api . nvim_win_set_config ( w1 , { relative ='cursor' , row =1 , col =1 , height =4 , width =4 } ) 1341screen : expect ( [[ 1342| 1343{1:~ }| 1344{1:~ }{31:┌────┐}{1: }| 1345{1:~ }{31:│}{4:^ }{31:│}{1: }| 1346{1:~ }{31:│}{11:~ }{31:│}{1: }|*3 1347{1:~ }{31:└────┘}{1: }| 1348{1:~ }|*5 1349| 1350]] ) 1351end ) 1352 1353local function with_ext_multigrid ( multigrid , send_mouse_grid ) 1354local screen , attrs 1355before_each ( function () 1356screen =Screen . new ( 40 , 7 , { ext_multigrid =multigrid } ) 1357attrs ={ 1358[ 0 ] ={ bold =true , foreground =Screen . colors . Blue } , 1359[ 1 ] ={ background =Screen . colors . LightMagenta } , 1360[ 2 ] ={ background =Screen . colors . LightMagenta , bold =true , foreground =Screen . colors . Blue1 } , 1361[ 3 ] ={ bold =true } , 1362[ 4 ] ={ bold =true , reverse =true } , 1363[ 5 ] ={ reverse =true } , 1364[ 6 ] ={ background =Screen . colors . LightMagenta , bold =true , reverse =true } , 1365[ 7 ] ={ foreground =Screen . colors . White , background =Screen . colors . Red } , 1366[ 8 ] ={ bold =true , foreground =Screen . colors . SeaGreen4 } , 1367[ 9 ] ={ background =Screen . colors . LightGrey , underline =true } , 1368[ 10 ] ={ background =Screen . colors . LightGrey , underline =true , bold =true , foreground =Screen . colors . Magenta } , 1369[ 11 ] ={ bold =true , foreground =Screen . colors . Fuchsia , background =Screen . colors . LightMagenta } , 1370[ 12 ] ={ background =Screen . colors . Red , bold =true , foreground =Screen . colors . Blue1 } , 1371[ 13 ] ={ background =Screen . colors . WebGray } , 1372[ 14 ] ={ foreground =Screen . colors . Brown } , 1373[ 15 ] ={ background =Screen . colors . Grey20 } , 1374[ 16 ] ={ background =Screen . colors . Grey20 , bold =true , foreground =Screen . colors . Blue1 } , 1375[ 17 ] ={ background =Screen . colors . Yellow } , 1376[ 18 ] ={ foreground =Screen . colors . Brown , background =Screen . colors . Grey20 } , 1377[ 19 ] ={ foreground =Screen . colors . DarkBlue , background =Screen . colors . WebGray } , 1378[ 20 ] ={ bold =true , foreground =Screen . colors . Brown } , 1379[ 21 ] ={ background =Screen . colors . Gray90 } , 1380[ 22 ] ={ background =Screen . colors . LightRed } , 1381[ 23 ] ={ foreground =Screen . colors . Black , background =Screen . colors . White } , 1382[ 24 ] ={ foreground =Screen . colors . Black , background =Screen . colors . Grey80 } , 1383[ 25 ] ={ blend =100 , background =Screen . colors . Gray0 } , 1384[ 26 ] ={ blend =80 , background =Screen . colors . Gray0 } , 1385[ 27 ] ={ foreground =Screen . colors . Black , background =Screen . colors . LightGrey } , 1386[ 28 ] ={ foreground =Screen . colors . DarkBlue , background =Screen . colors . LightGrey } , 1387[ 29 ] ={ background =Screen . colors . Yellow1 , foreground =Screen . colors . Blue4 } , 1388[ 30 ] ={ background =Screen . colors . Grey , foreground =Screen . colors . Blue4 , bold =true } , 1389[ 31 ] ={ foreground =Screen . colors . Grey0 } , 1390[ 32 ] ={ background =Screen . colors . LightMagenta , foreground =Screen . colors . Brown } , 1391[ 33 ] ={ background =Screen . colors . LightMagenta , reverse =true } , 1392[ 34 ] ={ foreground =Screen . colors . Fuchsia , bold =true } , 1393[ 35 ] ={ foreground =Screen . colors . White , background =Screen . colors . Red1 , reverse =true } , 1394[ 36 ] ={ foreground =Screen . colors . Fuchsia , background =Screen . colors . Red1 , bold =true } , 1395[ 37 ] ={ foreground =Screen . colors . SeaGreen , reverse =true , bold =true } , 1396} 1397screen : set_default_attr_ids ( attrs ) 1398end ) 1399 1400it ( 'can be created and reconfigured' , function () 1401local buf =api . nvim_create_buf ( false , false ) 1402local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =2 , row =2 , col =5 } ) 1403local expected_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } 1404 1405if multigrid then 1406screen : expect { 1407grid =[[ 1408## grid 1 1409[2:----------------------------------------]|*6 1410[3:----------------------------------------]| 1411## grid 2 1412^ | 1413{0:~ }|*5 1414## grid 3 1415| 1416## grid 4 1417{1: }| 1418{2:~ }| 1419]] , 1420float_pos =expected_pos , 1421} 1422else 1423screen : expect ( [[ 1424^ | 1425{0:~ }| 1426{0:~ }{1: }{0: }| 1427{0:~ }{2:~ }{0: }| 1428{0:~ }|*2 1429| 1430]] ) 1431end 1432 1433api . nvim_win_set_config ( win , { relative ='editor' , row =0 , col =10 } ) 1434expected_pos [ 4 ][ 4 ] =0 1435expected_pos [ 4 ][ 5 ] =10 1436expected_pos [ 4 ][ 9 ] =0 1437expected_pos [ 4 ][ 10 ] =10 1438if multigrid then 1439screen : expect { 1440grid =[[ 1441## grid 1 1442[2:----------------------------------------]|*6 1443[3:----------------------------------------]| 1444## grid 2 1445^ | 1446{0:~ }|*5 1447## grid 3 1448| 1449## grid 4 1450{1: }| 1451{2:~ }| 1452]] , 1453float_pos =expected_pos , 1454} 1455else 1456screen : expect ( [[ 1457^ {1: } | 1458{0:~ }{2:~ }{0: }| 1459{0:~ }|*4 1460| 1461]] ) 1462end 1463 1464api . nvim_win_close ( win , false ) 1465if multigrid then 1466screen : expect ( [[ 1467## grid 1 1468[2:----------------------------------------]|*6 1469[3:----------------------------------------]| 1470## grid 2 1471^ | 1472{0:~ }|*5 1473## grid 3 1474| 1475]] ) 1476else 1477screen : expect ( [[ 1478^ | 1479{0:~ }|*5 1480| 1481]] ) 1482end 1483end ) 1484 1485it ( 'window position fixed' , function () 1486command ( 'rightbelow 20vsplit' ) 1487local buf =api . nvim_create_buf ( false , false ) 1488local win =api . nvim_open_win ( buf , false , { 1489relative ='win' , 1490width =15 , 1491height =2 , 1492row =2 , 1493col =10 , 1494anchor ='NW' , 1495fixed =true , 1496} ) 1497 1498if multigrid then 1499screen : expect { 1500grid =[[ 1501## grid 1 1502[2:-------------------]{5:│}[4:--------------------]|*5 1503{5:[No Name] }{4:[No Name] }| 1504[3:----------------------------------------]| 1505## grid 2 1506| 1507{0:~ }|*4 1508## grid 3 1509| 1510## grid 4 1511^ | 1512{0:~ }|*4 1513## grid 5 1514{1: }| 1515{2:~ }| 1516]] , 1517float_pos ={ [ 5 ] ={ 1002 , 'NW' , 4 , 2 , 10 , true , 50 , 1 , 2 , 30 } } , 1518} 1519else 1520screen : expect ( [[ 1521{5:│}^ | 1522{0:~ }{5:│}{0:~ }| 1523{0:~ }{5:│}{0:~ }{1: }| 1524{0:~ }{5:│}{0:~ }{2:~ }| 1525{0:~ }{5:│}{0:~ }| 1526{5:[No Name] }{4:[No Name] }| 1527| 1528]] ) 1529end 1530 1531api . nvim_win_set_config ( win , { fixed =false } ) 1532 1533if multigrid then 1534screen : expect { 1535grid =[[ 1536## grid 1 1537[2:-------------------]{5:│}[4:--------------------]|*5 1538{5:[No Name] }{4:[No Name] }| 1539[3:----------------------------------------]| 1540## grid 2 1541| 1542{0:~ }|*4 1543## grid 3 1544| 1545## grid 4 1546^ | 1547{0:~ }|*4 1548## grid 5 1549{1: }| 1550{2:~ }| 1551]] , 1552float_pos ={ [ 5 ] ={ 1002 , 'NW' , 4 , 2 , 10 , true , 50 , 1 , 2 , 25 } } , 1553} 1554else 1555screen : expect ( [[ 1556{5:│}^ | 1557{0:~ }{5:│}{0:~ }| 1558{0:~ }{5:│}{0:~ }{1: }| 1559{0:~ }{5:│}{0:~ }{2:~ }| 1560{0:~ }{5:│}{0:~ }| 1561{5:[No Name] }{4:[No Name] }| 1562| 1563]] ) 1564end 1565end ) 1566 1567it ( 'draws correctly with redrawdebug=compositor' , function () 1568-- NB: we do not test that it produces the "correct" debug info 1569-- (as it is intermediate only, and is allowed to change by internal 1570-- refactors). Only check that it doesn't cause permanent glitches, 1571-- or something. 1572command ( 'set redrawdebug=compositor' ) 1573command ( 'set wd=1' ) 1574local buf =api . nvim_create_buf ( false , false ) 1575local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =2 , row =2 , col =5 } ) 1576local expected_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } 1577 1578if multigrid then 1579screen : expect { 1580grid =[[ 1581## grid 1 1582[2:----------------------------------------]|*6 1583[3:----------------------------------------]| 1584## grid 2 1585^ | 1586{0:~ }|*5 1587## grid 3 1588| 1589## grid 4 1590{1: }| 1591{2:~ }| 1592]] , 1593float_pos =expected_pos , 1594} 1595else 1596screen : expect ( [[ 1597^ | 1598{0:~ }| 1599{0:~ }{1: }{0: }| 1600{0:~ }{2:~ }{0: }| 1601{0:~ }|*2 1602| 1603]] ) 1604end 1605 1606api . nvim_win_set_config ( win , { relative ='editor' , row =0 , col =10 } ) 1607expected_pos [ 4 ][ 4 ] =0 1608expected_pos [ 4 ][ 5 ] =10 1609expected_pos [ 4 ][ 9 ] =0 1610expected_pos [ 4 ][ 10 ] =10 1611if multigrid then 1612screen : expect { 1613grid =[[ 1614## grid 1 1615[2:----------------------------------------]|*6 1616[3:----------------------------------------]| 1617## grid 2 1618^ | 1619{0:~ }|*5 1620## grid 3 1621| 1622## grid 4 1623{1: }| 1624{2:~ }| 1625]] , 1626float_pos =expected_pos , 1627} 1628else 1629screen : expect ( [[ 1630^ {1: } | 1631{0:~ }{2:~ }{0: }| 1632{0:~ }|*4 1633| 1634]] ) 1635end 1636 1637api . nvim_win_close ( win , false ) 1638if multigrid then 1639screen : expect ( [[ 1640## grid 1 1641[2:----------------------------------------]|*6 1642[3:----------------------------------------]| 1643## grid 2 1644^ | 1645{0:~ }|*5 1646## grid 3 1647| 1648]] ) 1649else 1650screen : expect ( [[ 1651^ | 1652{0:~ }|*5 1653| 1654]] ) 1655end 1656end ) 1657 1658it ( 'return their configuration' , function () 1659local buf =api . nvim_create_buf ( false , false ) 1660local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =2 , row =3 , col =5 , zindex =60 } ) 1661local expected ={ 1662anchor ='NW' , 1663border ='none' , 1664style ='' , 1665col =5 , 1666external =false , 1667focusable =true , 1668mouse =true , 1669height =2 , 1670relative ='editor' , 1671row =3 , 1672width =20 , 1673zindex =60 , 1674hide =false , 1675} 1676eq ( expected , api . nvim_win_get_config ( win )) 1677eq ( 1678true , 1679exec_lua ( 1680[[ 1681local expected, win = ... 1682local actual = vim.api.nvim_win_get_config(win) 1683for k,v in pairs(expected) do 1684if v ~= actual[k] then 1685error(k) 1686end 1687end 1688return true]] , 1689expected , 1690win 1691) 1692) 1693 1694eq ( { 1695external =false , 1696focusable =true , 1697mouse =true , 1698hide =false , 1699relative ='' , 1700style ='' , 1701split ='left' , 1702width =40 , 1703height =6 , 1704} , api . nvim_win_get_config ( 0 )) 1705 1706if multigrid then 1707api . nvim_win_set_config ( win , { external =true , width =10 , height =1 } ) 1708eq ( { 1709external =true , 1710focusable =true , 1711mouse =true , 1712width =10 , 1713height =1 , 1714relative ='' , 1715style ='' , 1716hide =false , 1717border ='none' , 1718} , api . nvim_win_get_config ( win )) 1719end 1720end ) 1721 1722it ( 'defaults to NormalFloat highlight and inherited options' , function () 1723command ( 'set number' ) 1724command ( 'hi NormalFloat guibg=#333333 guifg=NONE' ) 1725feed ( 'ix<cr>y<cr><esc>gg' ) 1726local win =api . nvim_open_win ( 0 , false , { relative ='editor' , width =20 , height =4 , row =4 , col =10 } ) 1727if multigrid then 1728screen : expect { 1729grid =[[ 1730## grid 1 1731[2:----------------------------------------]|*6 1732[3:----------------------------------------]| 1733## grid 2 1734{14: 1 }^x | 1735{14: 2 }y | 1736{14: 3 } | 1737{0:~ }|*3 1738## grid 3 1739| 1740## grid 4 1741{18: 1 }{15:x }| 1742{18: 2 }{15:y }| 1743{18: 3 }{15: }| 1744{16:~ }| 1745]] , 1746float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 4 , 10 , true , 50 , 1 , 2 , 10 } } , 1747} 1748else 1749screen : expect ( [[ 1750{14: 1 }^x | 1751{14: 2 }y | 1752{14: 3 } {18: 1 }{15:x } | 1753{0:~ }{18: 2 }{15:y }{0: }| 1754{0:~ }{18: 3 }{15: }{0: }| 1755{0:~ }{16:~ }{0: }| 1756| 1757]] ) 1758end 1759 1760local buf =api . nvim_create_buf ( false , true ) 1761api . nvim_win_set_buf ( win , buf ) 1762if multigrid then 1763screen : expect { 1764grid =[[ 1765## grid 1 1766[2:----------------------------------------]|*6 1767[3:----------------------------------------]| 1768## grid 2 1769{14: 1 }^x | 1770{14: 2 }y | 1771{14: 3 } | 1772{0:~ }|*3 1773## grid 3 1774| 1775## grid 4 1776{18: 1 }{15: }| 1777{16:~ }|*3 1778]] , 1779float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 4 , 10 , true , 50 , 1 , 2 , 10 } } , 1780} 1781else 1782screen : expect ( [[ 1783{14: 1 }^x | 1784{14: 2 }y | 1785{14: 3 } {18: 1 }{15: } | 1786{0:~ }{16:~ }{0: }|*3 1787| 1788]] ) 1789end 1790 1791-- 1792-- floating windows inherit NormalFloat from global-ns. 1793-- 1794command ( 'fclose' ) 1795command ( 'hi NormalFloat guibg=LightRed' ) 1796api . nvim_open_win ( 0 , false , { relative ='win' , row =3 , col =3 , width =12 , height =3 , style ='minimal' } ) 1797api . nvim_set_hl_ns ( api . nvim_create_namespace ( 'test1' )) 1798if multigrid then 1799screen : expect ( { 1800grid =[[ 1801## grid 1 1802[2:----------------------------------------]|*6 1803[3:----------------------------------------]| 1804## grid 2 1805{14: 1 }^x | 1806{14: 2 }y | 1807{14: 3 } | 1808{0:~ }|*3 1809## grid 3 1810| 1811## grid 5 1812{22:x }| 1813{22:y }| 1814{22: }| 1815]] , 1816float_pos ={ [ 5 ] ={ 1002 , 'NW' , 2 , 3 , 3 , true , 50 , 1 , 3 , 3 } } , 1817win_viewport ={ 1818[ 2 ] ={ win =1000 , topline =0 , botline =4 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 1819[ 5 ] ={ win =1002 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 1820} , 1821win_viewport_margins ={ 1822[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 1823[ 5 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1002 } , 1824} , 1825} ) 1826else 1827screen : expect ( { 1828grid =[[ 1829{14: 1 }^x | 1830{14: 2 }y | 1831{14: 3 } | 1832{0:~ }{22:x }{0: }| 1833{0:~ }{22:y }{0: }| 1834{0:~ }{22: }{0: }| 1835| 1836]] , 1837} ) 1838end 1839end ) 1840 1841it ( "can use 'minimal' style" , function () 1842command ( 'set number' ) 1843command ( 'set signcolumn=yes' ) 1844command ( 'set colorcolumn=1' ) 1845command ( 'set cursorline' ) 1846command ( 'set foldcolumn=1' ) 1847command ( 'hi NormalFloat guibg=#333333 guifg=NONE' ) 1848feed ( 'ix<cr>y<cr><esc>gg' ) 1849local win =api . nvim_open_win ( 0 , false , { relative ='editor' , width =20 , height =4 , row =4 , col =10 , style ='minimal' } ) 1850if multigrid then 1851screen : expect { 1852grid =[[ 1853## grid 1 1854[2:----------------------------------------]|*6 1855[3:----------------------------------------]| 1856## grid 2 1857{19: }{20: 1 }{22:^x}{21: }| 1858{19: }{14: 2 }{22:y} | 1859{19: }{14: 3 }{22: } | 1860{0:~ }|*3 1861## grid 3 1862| 1863## grid 4 1864{15:x }| 1865{15:y }| 1866{15: }|*2 1867]] , 1868float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 4 , 10 , true , 50 , 1 , 2 , 10 } } , 1869} 1870else 1871screen : expect { 1872grid =[[ 1873{19: }{20: 1 }{22:^x}{21: }| 1874{19: }{14: 2 }{22:y} | 1875{19: }{14: 3 }{22: } {15:x } | 1876{0:~ }{15:y }{0: }| 1877{0:~ }{15: }{0: }|*2 1878| 1879]] , 1880} 1881end 1882 1883-- signcolumn=yes still works if there actually are signs 1884command ( 'sign define piet1 text=𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄ texthl=Search' ) 1885command ( 'sign place 1 line=1 name=piet1 buffer=1' ) 1886if multigrid then 1887screen : expect { 1888grid =[[ 1889## grid 1 1890[2:----------------------------------------]|*6 1891[3:----------------------------------------]| 1892## grid 2 1893{19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }| 1894{19: }{14: 2 }{22:y} | 1895{19: }{14: 3 }{22: } | 1896{0:~ }|*3 1897## grid 3 1898| 1899## grid 4 1900{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }| 1901{19: }{15:y }| 1902{19: }{15: }| 1903{15: }| 1904]] , 1905float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 4 , 10 , true , 50 , 1 , 2 , 10 } } , 1906} 1907else 1908screen : expect ( [[ 1909{19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }| 1910{19: }{14: 2 }{22:y} | 1911{19: }{14: 3 }{22: } {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } | 1912{0:~ }{19: }{15:y }{0: }| 1913{0:~ }{19: }{15: }{0: }| 1914{0:~ }{15: }{0: }| 1915| 1916]] ) 1917end 1918command ( 'sign unplace 1 buffer=1' ) 1919 1920local buf =api . nvim_create_buf ( false , true ) 1921api . nvim_win_set_buf ( win , buf ) 1922if multigrid then 1923screen : expect { 1924grid =[[ 1925## grid 1 1926[2:----------------------------------------]|*6 1927[3:----------------------------------------]| 1928## grid 2 1929{19: }{20: 1 }{22:^x}{21: }| 1930{19: }{14: 2 }{22:y} | 1931{19: }{14: 3 }{22: } | 1932{0:~ }|*3 1933## grid 3 1934| 1935## grid 4 1936{15: }|*4 1937]] , 1938float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 4 , 10 , true , 50 , 1 , 2 , 10 } } , 1939} 1940else 1941screen : expect ( [[ 1942{19: }{20: 1 }{22:^x}{21: }| 1943{19: }{14: 2 }{22:y} | 1944{19: }{14: 3 }{22: } {15: } | 1945{0:~ }{15: }{0: }|*3 1946| 1947]] ) 1948end 1949end ) 1950 1951it ( "would not break 'minimal' style with signcolumn=auto:[min]-[max]" , function () 1952command ( 'set number' ) 1953command ( 'set signcolumn=auto:1-3' ) 1954command ( 'set colorcolumn=1' ) 1955command ( 'set cursorline' ) 1956command ( 'set foldcolumn=1' ) 1957command ( 'hi NormalFloat guibg=#333333 guifg=NONE' ) 1958feed ( 'ix<cr>y<cr><esc>gg' ) 1959local win =api . nvim_open_win ( 0 , false , { relative ='editor' , width =20 , height =4 , row =4 , col =10 , style ='minimal' } ) 1960if multigrid then 1961screen : expect { 1962grid =[[ 1963## grid 1 1964[2:----------------------------------------]|*6 1965[3:----------------------------------------]| 1966## grid 2 1967{19: }{20: 1 }{22:^x}{21: }| 1968{19: }{14: 2 }{22:y} | 1969{19: }{14: 3 }{22: } | 1970{0:~ }|*3 1971## grid 3 1972| 1973## grid 4 1974{15:x }| 1975{15:y }| 1976{15: }|*2 1977]] , 1978float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 4 , 10 , true , 50 , 1 , 2 , 10 } } , 1979} 1980else 1981screen : expect { 1982grid =[[ 1983{19: }{20: 1 }{22:^x}{21: }| 1984{19: }{14: 2 }{22:y} | 1985{19: }{14: 3 }{22: } {15:x } | 1986{0:~ }{15:y }{0: }| 1987{0:~ }{15: }{0: }|*2 1988| 1989]] , 1990} 1991end 1992 1993command ( 'sign define piet1 text=𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄ texthl=Search' ) 1994command ( 'sign place 1 line=1 name=piet1 buffer=1' ) 1995-- signcolumn=auto:1-3 still works if there actually are signs 1996if multigrid then 1997screen : expect { 1998grid =[[ 1999## grid 1 2000[2:----------------------------------------]|*6 2001[3:----------------------------------------]| 2002## grid 2 2003{19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }| 2004{19: }{14: 2 }{22:y} | 2005{19: }{14: 3 }{22: } | 2006{0:~ }|*3 2007## grid 3 2008| 2009## grid 4 2010{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }| 2011{19: }{15:y }| 2012{19: }{15: }| 2013{15: }| 2014]] , 2015float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 4 , 10 , true , 50 , 1 , 2 , 10 } } , 2016} 2017else 2018screen : expect ( [[ 2019{19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }| 2020{19: }{14: 2 }{22:y} | 2021{19: }{14: 3 }{22: } {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } | 2022{0:~ }{19: }{15:y }{0: }| 2023{0:~ }{19: }{15: }{0: }| 2024{0:~ }{15: }{0: }| 2025| 2026]] ) 2027end 2028command ( 'sign unplace 1 buffer=1' ) 2029 2030local buf =api . nvim_create_buf ( false , true ) 2031api . nvim_win_set_buf ( win , buf ) 2032if multigrid then 2033screen : expect { 2034grid =[[ 2035## grid 1 2036[2:----------------------------------------]|*6 2037[3:----------------------------------------]| 2038## grid 2 2039{19: }{20: 1 }{22:^x}{21: }| 2040{19: }{14: 2 }{22:y} | 2041{19: }{14: 3 }{22: } | 2042{0:~ }|*3 2043## grid 3 2044| 2045## grid 4 2046{15: }|*4 2047]] , 2048float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 4 , 10 , true , 50 , 1 , 2 , 10 } } , 2049} 2050else 2051screen : expect ( [[ 2052{19: }{20: 1 }{22:^x}{21: }| 2053{19: }{14: 2 }{22:y} | 2054{19: }{14: 3 }{22: } {15: } | 2055{0:~ }{15: }{0: }|*3 2056| 2057]] ) 2058end 2059end ) 2060 2061it ( "would not break 'minimal' style with statuscolumn set" , function () 2062command ( 'set number' ) 2063command ( 'set signcolumn=yes' ) 2064command ( 'set colorcolumn=1' ) 2065command ( 'set cursorline' ) 2066command ( 'set foldcolumn=1' ) 2067command ( 'set statuscolumn=%l%s%C' ) 2068command ( 'hi NormalFloat guibg=#333333 guifg=NONE' ) 2069feed ( 'ix<cr>y<cr><esc>gg' ) 2070api . nvim_open_win ( 0 , false , { relative ='editor' , width =20 , height =4 , row =4 , col =10 , style ='minimal' } ) 2071if multigrid then 2072screen : expect ( { 2073grid =[[ 2074## grid 1 2075[2:----------------------------------------]|*6 2076[3:----------------------------------------]| 2077## grid 2 2078{20: 1}{19: }{22:^x}{21: }| 2079{14: 2}{19: }{22:y} | 2080{14: 3}{19: }{22: } | 2081{0:~ }|*3 2082## grid 3 2083| 2084## grid 4 2085{15:x }| 2086{15:y }| 2087{15: }|*2 2088]] , 2089float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 4 , 10 , true , 50 , 1 , 2 , 10 } } , 2090} ) 2091else 2092screen : expect ( [[ 2093{20: 1}{19: }{22:^x}{21: }| 2094{14: 2}{19: }{22:y} | 2095{14: 3}{19: }{22: } {15:x } | 2096{0:~ }{15:y }{0: }| 2097{0:~ }{15: }{0: }|*2 2098| 2099]] ) 2100end 2101end ) 2102 2103it ( 'can have border' , function () 2104local buf =api . nvim_create_buf ( false , false ) 2105api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { ' halloj! ' , ' BORDAA ' } ) 2106local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =9 , height =2 , row =2 , col =5 , border ='double' } ) 2107eq ( '╔' , api . nvim_win_get_config ( win ). border [ 1 ]) 2108 2109api . nvim_win_set_config ( win , { border ='single' } ) 2110eq ( '┌' , api . nvim_win_get_config ( win ). border [ 1 ]) 2111 2112api . nvim_win_set_config ( win , { border ='rounded' } ) 2113eq ( '╭' , api . nvim_win_get_config ( win ). border [ 1 ]) 2114 2115api . nvim_win_set_config ( win , { border ='solid' } ) 2116eq ( ' ' , api . nvim_win_get_config ( win ). border [ 1 ]) 2117 2118-- support: ascii char, UTF-8 char, composed char, highlight per char 2119api . nvim_win_set_config ( win , { border ={ 'x' , { 'å' , 'ErrorMsg' } , { '\\' } , { 'n̈̊' , 'Search' } } } ) 2120eq ( 2121{ 'x' , { 'å' , 'ErrorMsg' } , '\\' , { 'n̈̊' , 'Search' } , 'x' , { 'å' , 'ErrorMsg' } , '\\' , { 'n̈̊' , 'Search' } } , 2122api . nvim_win_get_config ( win ). border 2123) 2124if multigrid then 2125screen : expect { 2126grid =[[ 2127## grid 1 2128[2:----------------------------------------]|*6 2129[3:----------------------------------------]| 2130## grid 2 2131^ | 2132{0:~ }|*5 2133## grid 3 2134| 2135## grid 4 2136{33:x}{7:ååååååååå}{33:\}| 2137{17:n̈̊}{1: halloj! }{17:n̈̊}| 2138{17:n̈̊}{1: BORDAA }{17:n̈̊}| 2139{33:\}{7:ååååååååå}{33:x}| 2140]] , 2141float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2142win_viewport ={ 2143[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2144[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2145} , 2146} 2147else 2148screen : expect { 2149grid =[[ 2150^ | 2151{0:~ }| 2152{0:~ }{33:x}{7:ååååååååå}{33:\}{0: }| 2153{0:~ }{17:n̈̊}{1: halloj! }{17:n̈̊}{0: }| 2154{0:~ }{17:n̈̊}{1: BORDAA }{17:n̈̊}{0: }| 2155{0:~ }{33:\}{7:ååååååååå}{33:x}{0: }| 2156| 2157]] , 2158} 2159end 2160 2161api . nvim_win_set_config ( win , { border ='none' } ) 2162eq ( 'none' , api . nvim_win_get_config ( win ). border ) 2163 2164api . nvim_win_set_config ( win , { border ={ '' , '' , '' , '>' , '' , '' , '' , '<' } } ) 2165eq ( { '' , '' , '' , '>' , '' , '' , '' , '<' } , api . nvim_win_get_config ( win ). border ) 2166if multigrid then 2167screen : expect { 2168grid =[[ 2169## grid 1 2170[2:----------------------------------------]|*6 2171[3:----------------------------------------]| 2172## grid 2 2173^ | 2174{0:~ }|*5 2175## grid 3 2176| 2177## grid 4 2178{33:<}{1: halloj! }{33:>}| 2179{33:<}{1: BORDAA }{33:>}| 2180]] , 2181float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2182win_viewport ={ 2183[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2184[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2185} , 2186win_viewport_margins ={ 2187[ 2 ] ={ win =1000 , top =0 , bottom =0 , left =0 , right =0 } , 2188[ 4 ] ={ win =1001 , top =0 , bottom =0 , left =1 , right =1 } , 2189} , 2190} 2191else 2192screen : expect { 2193grid =[[ 2194^ | 2195{0:~ }| 2196{0:~ }{33:<}{1: halloj! }{33:>}{0: }| 2197{0:~ }{33:<}{1: BORDAA }{33:>}{0: }| 2198{0:~ }|*2 2199| 2200]] , 2201} 2202end 2203 2204api . nvim_win_set_config ( win , { border ={ '' , '_' , '' , '' , '' , '-' , '' , '' } } ) 2205eq ( { '' , '_' , '' , '' , '' , '-' , '' , '' } , api . nvim_win_get_config ( win ). border ) 2206if multigrid then 2207screen : expect { 2208grid =[[ 2209## grid 1 2210[2:----------------------------------------]|*6 2211[3:----------------------------------------]| 2212## grid 2 2213^ | 2214{0:~ }|*5 2215## grid 3 2216| 2217## grid 4 2218{33:_________}| 2219{1: halloj! }| 2220{1: BORDAA }| 2221{33:---------}| 2222]] , 2223float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2224win_viewport ={ 2225[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2226[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2227} , 2228win_viewport_margins ={ 2229[ 2 ] ={ win =1000 , top =0 , bottom =0 , left =0 , right =0 } , 2230[ 4 ] ={ win =1001 , top =1 , bottom =1 , left =0 , right =0 } , 2231} , 2232} 2233else 2234screen : expect { 2235grid =[[ 2236^ | 2237{0:~ }| 2238{0:~ }{33:_________}{0: }| 2239{0:~ }{1: halloj! }{0: }| 2240{0:~ }{1: BORDAA }{0: }| 2241{0:~ }{33:---------}{0: }| 2242| 2243]] , 2244} 2245end 2246 2247insert [[ 2248neeed some dummy 2249background text 2250to show the effect 2251of color blending 2252of border shadow 2253]] 2254 2255api . nvim_win_set_config ( win , { border ='shadow' } ) 2256if multigrid then 2257screen : expect { 2258grid =[[ 2259## grid 1 2260[2:----------------------------------------]|*6 2261[3:----------------------------------------]| 2262## grid 2 2263neeed some dummy | 2264background text | 2265to show the effect | 2266of color blending | 2267of border shadow | 2268^ | 2269## grid 3 2270| 2271## grid 4 2272{1: halloj! }{25: }| 2273{1: BORDAA }{26: }| 2274{25: }{26: }| 2275]] , 2276float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2277win_viewport ={ 2278[ 2 ] ={ win =1000 , topline =0 , botline =6 , curline =5 , curcol =0 , linecount =6 , sum_scroll_delta =0 } , 2279[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2280} , 2281win_viewport_margins ={ 2282[ 2 ] ={ win =1000 , top =0 , bottom =0 , left =0 , right =0 } , 2283[ 4 ] ={ win =1001 , top =0 , bottom =1 , left =0 , right =1 } , 2284} , 2285} 2286else 2287screen : expect { 2288grid =[[ 2289neeed some dummy | 2290background text | 2291to sh{1: halloj! }{31:f}ect | 2292of co{1: BORDAA }{24:i}ng | 2293of bo{31:r}{24:der shado}w | 2294^ | 2295| 2296]] , 2297} 2298end 2299end ) 2300 2301it ( 'nvim_win_get_config.title_pos' , function () 2302local title_pos =exec_lua ( [[ 2303local bufnr = vim.api.nvim_create_buf(false, false) 2304local opts = { 2305relative = 'editor', 2306col = 2, 2307row = 5, 2308height = 2, 2309width = 9, 2310border = 'double', 2311title = 'Test', 2312title_pos = 'center' 2313} 2314 2315local win_id = vim.api.nvim_open_win(bufnr, true, opts) 2316return vim.api.nvim_win_get_config(win_id).title_pos 2317]] ) 2318 2319eq ( 'center' , title_pos ) 2320end ) 2321 2322it ( 'nvim_win_get_config.footer_pos' , function () 2323local footer_pos =exec_lua ( [[ 2324local bufnr = vim.api.nvim_create_buf(false, false) 2325local opts = { 2326relative = 'editor', 2327col = 2, 2328row = 5, 2329height = 2, 2330width = 9, 2331border = 'double', 2332footer = 'Test', 2333footer_pos = 'center' 2334} 2335 2336local win_id = vim.api.nvim_open_win(bufnr, true, opts) 2337return vim.api.nvim_win_get_config(win_id).footer_pos 2338]] ) 2339 2340eq ( 'center' , footer_pos ) 2341end ) 2342 2343it ( 'truncates title longer than window width #25746 #23602' , function () 2344local buf =api . nvim_create_buf ( false , false ) 2345api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { ' halloj! ' , ' BORDAA ' } ) 2346local config ={ 2347relative ='editor' , 2348width =9 , 2349height =2 , 2350row =2 , 2351col =5 , 2352border ='double' , 2353title ='abcdefghijklmnopqrstuvwxyz' , 2354title_pos ='center' , 2355footer ='abcdefghi' , -- exactly fits window width #36872 2356} 2357local win =api . nvim_open_win ( buf , false , config ) 2358if multigrid then 2359screen : expect { 2360grid =[[ 2361## grid 1 2362[2:----------------------------------------]|*6 2363[3:----------------------------------------]| 2364## grid 2 2365^ | 2366{0:~ }|*5 2367## grid 3 2368| 2369## grid 4 2370{33:╔}{11:<stuvwxyz}{33:╗}| 2371{33:║}{1: halloj! }{33:║}| 2372{33:║}{1: BORDAA }{33:║}| 2373{33:╚}{11:abcdefghi}{33:╝}| 2374]] , 2375float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2376win_viewport ={ 2377[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2378[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2379} , 2380} 2381else 2382screen : expect { 2383grid =[[ 2384^ | 2385{0:~ }| 2386{0:~ }{33:╔}{11:<stuvwxyz}{33:╗}{0: }| 2387{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2388{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2389{0:~ }{33:╚}{11:abcdefghi}{33:╝}{0: }| 2390| 2391]] , 2392} 2393end 2394config . title ={ { 'abcd' } , { 'stuvw' } , { 'xyz' } } 2395api . nvim_win_set_config ( win , config ) 2396screen : expect_unchanged () 2397api . nvim_win_close ( win , false ) 2398assert_alive () 2399end ) 2400 2401it ( 'no border with title and footer' , function () 2402local buf =api . nvim_create_buf ( false , false ) 2403api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'Hello' } ) 2404api . nvim_open_win ( buf , false , { 2405relative ='editor' , 2406width =9 , 2407height =2 , 2408row =2 , 2409col =5 , 2410title ='Title' , 2411footer ='Footer' , 2412} ) 2413 2414if multigrid then 2415screen : expect ( { 2416grid =[[ 2417## grid 1 2418[2:----------------------------------------]|*6 2419[3:----------------------------------------]| 2420## grid 2 2421^ | 2422{0:~ }|*5 2423## grid 3 2424| 2425## grid 4 2426{1:Hello }| 2427{2:~ }| 2428]] , 2429float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2430win_viewport ={ 2431[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2432[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2433} , 2434} ) 2435else 2436screen : expect ( [[ 2437^ | 2438{0:~ }| 2439{0:~ }{1:Hello }{0: }| 2440{0:~ }{2:~ }{0: }| 2441{0:~ }|*2 2442| 2443]] ) 2444end 2445end ) 2446 2447it ( 'border with title' , function () 2448local buf =api . nvim_create_buf ( false , false ) 2449api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { ' halloj! ' , ' BORDAA ' } ) 2450local win =api . nvim_open_win ( buf , false , { 2451relative ='editor' , 2452width =9 , 2453height =2 , 2454row =2 , 2455col =5 , 2456border ='double' , 2457title ='Left' , 2458title_pos ='left' , 2459} ) 2460 2461if multigrid then 2462screen : expect { 2463grid =[[ 2464## grid 1 2465[2:----------------------------------------]|*6 2466[3:----------------------------------------]| 2467## grid 2 2468^ | 2469{0:~ }|*5 2470## grid 3 2471| 2472## grid 4 2473{33:╔}{11:Left}{33:═════╗}| 2474{33:║}{1: halloj! }{33:║}| 2475{33:║}{1: BORDAA }{33:║}| 2476{33:╚═════════╝}| 2477]] , 2478float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2479win_viewport ={ 2480[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2481[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2482} , 2483} 2484else 2485screen : expect { 2486grid =[[ 2487^ | 2488{0:~ }| 2489{0:~ }{33:╔}{11:Left}{33:═════╗}{0: }| 2490{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2491{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2492{0:~ }{33:╚═════════╝}{0: }| 2493| 2494]] , 2495} 2496end 2497 2498api . nvim_win_set_config ( win , { title ='Center' , title_pos ='center' } ) 2499if multigrid then 2500screen : expect { 2501grid =[[ 2502## grid 1 2503[2:----------------------------------------]|*6 2504[3:----------------------------------------]| 2505## grid 2 2506^ | 2507{0:~ }|*5 2508## grid 3 2509| 2510## grid 4 2511{33:╔═}{11:Center}{33:══╗}| 2512{33:║}{1: halloj! }{33:║}| 2513{33:║}{1: BORDAA }{33:║}| 2514{33:╚═════════╝}| 2515]] , 2516float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2517win_viewport ={ 2518[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2519[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2520} , 2521} 2522else 2523screen : expect { 2524grid =[[ 2525^ | 2526{0:~ }| 2527{0:~ }{33:╔═}{11:Center}{33:══╗}{0: }| 2528{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2529{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2530{0:~ }{33:╚═════════╝}{0: }| 2531| 2532]] , 2533} 2534end 2535 2536api . nvim_win_set_config ( win , { title ='Right' , title_pos ='right' } ) 2537if multigrid then 2538screen : expect { 2539grid =[[ 2540## grid 1 2541[2:----------------------------------------]|*6 2542[3:----------------------------------------]| 2543## grid 2 2544^ | 2545{0:~ }|*5 2546## grid 3 2547| 2548## grid 4 2549{33:╔════}{11:Right}{33:╗}| 2550{33:║}{1: halloj! }{33:║}| 2551{33:║}{1: BORDAA }{33:║}| 2552{33:╚═════════╝}| 2553]] , 2554float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2555win_viewport ={ 2556[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2557[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2558} , 2559} 2560else 2561screen : expect { 2562grid =[[ 2563^ | 2564{0:~ }| 2565{0:~ }{33:╔════}{11:Right}{33:╗}{0: }| 2566{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2567{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2568{0:~ }{33:╚═════════╝}{0: }| 2569| 2570]] , 2571} 2572end 2573 2574api . nvim_win_set_config ( win , { title ={ { '🦄' } , { 'BB' } } , title_pos ='right' } ) 2575if multigrid then 2576screen : expect { 2577grid =[[ 2578## grid 1 2579[2:----------------------------------------]|*6 2580[3:----------------------------------------]| 2581## grid 2 2582^ | 2583{0:~ }|*5 2584## grid 3 2585| 2586## grid 4 2587{33:╔═════}{11:🦄BB}{33:╗}| 2588{33:║}{1: halloj! }{33:║}| 2589{33:║}{1: BORDAA }{33:║}| 2590{33:╚═════════╝}| 2591]] , 2592float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2593win_viewport ={ 2594[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2595[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2596} , 2597} 2598else 2599screen : expect { 2600grid =[[ 2601^ | 2602{0:~ }| 2603{0:~ }{33:╔═════}{11:🦄BB}{33:╗}{0: }| 2604{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2605{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2606{0:~ }{33:╚═════════╝}{0: }| 2607| 2608]] , 2609} 2610end 2611 2612-- reuse before title pos 2613api . nvim_win_set_config ( win , { title ='new' } ) 2614if multigrid then 2615screen : expect ( { 2616grid =[[ 2617## grid 1 2618[2:----------------------------------------]|*6 2619[3:----------------------------------------]| 2620## grid 2 2621^ | 2622{0:~ }|*5 2623## grid 3 2624| 2625## grid 4 2626{33:╔══════}{11:new}{33:╗}| 2627{33:║}{1: halloj! }{33:║}| 2628{33:║}{1: BORDAA }{33:║}| 2629{33:╚═════════╝}| 2630]] , 2631float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2632win_viewport ={ 2633[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2634[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2635} , 2636win_viewport_margins ={ 2637[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 2638[ 4 ] ={ bottom =1 , left =1 , right =1 , top =1 , win =1001 } , 2639} , 2640} ) 2641else 2642screen : expect ( [[ 2643^ | 2644{0:~ }| 2645{0:~ }{33:╔══════}{11:new}{33:╗}{0: }| 2646{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2647{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2648{0:~ }{33:╚═════════╝}{0: }| 2649| 2650]] ) 2651end 2652end ) 2653 2654it ( 'border with footer' , function () 2655local buf =api . nvim_create_buf ( false , false ) 2656api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { ' halloj! ' , ' BORDAA ' } ) 2657local win =api . nvim_open_win ( buf , false , { 2658relative ='editor' , 2659width =9 , 2660height =2 , 2661row =2 , 2662col =5 , 2663border ='double' , 2664footer ='Left' , 2665footer_pos ='left' , 2666} ) 2667 2668if multigrid then 2669screen : expect { 2670grid =[[ 2671## grid 1 2672[2:----------------------------------------]|*6 2673[3:----------------------------------------]| 2674## grid 2 2675^ | 2676{0:~ }|*5 2677## grid 3 2678| 2679## grid 4 2680{33:╔═════════╗}| 2681{33:║}{1: halloj! }{33:║}| 2682{33:║}{1: BORDAA }{33:║}| 2683{33:╚}{11:Left}{33:═════╝}| 2684]] , 2685float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2686win_viewport ={ 2687[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2688[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2689} , 2690} 2691else 2692screen : expect { 2693grid =[[ 2694^ | 2695{0:~ }| 2696{0:~ }{33:╔═════════╗}{0: }| 2697{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2698{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2699{0:~ }{33:╚}{11:Left}{33:═════╝}{0: }| 2700| 2701]] , 2702} 2703end 2704 2705api . nvim_win_set_config ( win , { footer ='Center' , footer_pos ='center' } ) 2706if multigrid then 2707screen : expect { 2708grid =[[ 2709## grid 1 2710[2:----------------------------------------]|*6 2711[3:----------------------------------------]| 2712## grid 2 2713^ | 2714{0:~ }|*5 2715## grid 3 2716| 2717## grid 4 2718{33:╔═════════╗}| 2719{33:║}{1: halloj! }{33:║}| 2720{33:║}{1: BORDAA }{33:║}| 2721{33:╚═}{11:Center}{33:══╝}| 2722]] , 2723float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2724win_viewport ={ 2725[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2726[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2727} , 2728} 2729else 2730screen : expect { 2731grid =[[ 2732^ | 2733{0:~ }| 2734{0:~ }{33:╔═════════╗}{0: }| 2735{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2736{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2737{0:~ }{33:╚═}{11:Center}{33:══╝}{0: }| 2738| 2739]] , 2740} 2741end 2742 2743api . nvim_win_set_config ( win , { footer ='Right' , footer_pos ='right' } ) 2744if multigrid then 2745screen : expect { 2746grid =[[ 2747## grid 1 2748[2:----------------------------------------]|*6 2749[3:----------------------------------------]| 2750## grid 2 2751^ | 2752{0:~ }|*5 2753## grid 3 2754| 2755## grid 4 2756{33:╔═════════╗}| 2757{33:║}{1: halloj! }{33:║}| 2758{33:║}{1: BORDAA }{33:║}| 2759{33:╚════}{11:Right}{33:╝}| 2760]] , 2761float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2762win_viewport ={ 2763[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2764[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2765} , 2766} 2767else 2768screen : expect { 2769grid =[[ 2770^ | 2771{0:~ }| 2772{0:~ }{33:╔═════════╗}{0: }| 2773{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2774{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2775{0:~ }{33:╚════}{11:Right}{33:╝}{0: }| 2776| 2777]] , 2778} 2779end 2780 2781api . nvim_win_set_config ( win , { footer ={ { '🦄' } , { 'BB' } } , footer_pos ='right' } ) 2782if multigrid then 2783screen : expect { 2784grid =[[ 2785## grid 1 2786[2:----------------------------------------]|*6 2787[3:----------------------------------------]| 2788## grid 2 2789^ | 2790{0:~ }|*5 2791## grid 3 2792| 2793## grid 4 2794{33:╔═════════╗}| 2795{33:║}{1: halloj! }{33:║}| 2796{33:║}{1: BORDAA }{33:║}| 2797{33:╚═════}{11:🦄BB}{33:╝}| 2798]] , 2799float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2800win_viewport ={ 2801[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2802[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2803} , 2804} 2805else 2806screen : expect { 2807grid =[[ 2808^ | 2809{0:~ }| 2810{0:~ }{33:╔═════════╗}{0: }| 2811{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2812{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2813{0:~ }{33:╚═════}{11:🦄BB}{33:╝}{0: }| 2814| 2815]] , 2816} 2817end 2818 2819-- reuse before footer pos 2820api . nvim_win_set_config ( win , { footer ='new' } ) 2821if multigrid then 2822screen : expect ( { 2823grid =[[ 2824## grid 1 2825[2:----------------------------------------]|*6 2826[3:----------------------------------------]| 2827## grid 2 2828^ | 2829{0:~ }|*5 2830## grid 3 2831| 2832## grid 4 2833{33:╔═════════╗}| 2834{33:║}{1: halloj! }{33:║}| 2835{33:║}{1: BORDAA }{33:║}| 2836{33:╚══════}{11:new}{33:╝}| 2837]] , 2838float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2839win_viewport ={ 2840[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2841[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2842} , 2843win_viewport_margins ={ 2844[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 2845[ 4 ] ={ bottom =1 , left =1 , right =1 , top =1 , win =1001 } , 2846} , 2847} ) 2848else 2849screen : expect ( [[ 2850^ | 2851{0:~ }| 2852{0:~ }{33:╔═════════╗}{0: }| 2853{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2854{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2855{0:~ }{33:╚══════}{11:new}{33:╝}{0: }| 2856| 2857]] ) 2858end 2859end ) 2860 2861it ( 'border with title and footer' , function () 2862local buf =api . nvim_create_buf ( false , false ) 2863api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { ' halloj! ' , ' BORDAA ' } ) 2864local win =api . nvim_open_win ( buf , false , { 2865relative ='editor' , 2866width =9 , 2867height =2 , 2868row =2 , 2869col =5 , 2870border ='double' , 2871title ='Left' , 2872title_pos ='left' , 2873footer ='Right' , 2874footer_pos ='right' , 2875} ) 2876 2877if multigrid then 2878screen : expect { 2879grid =[[ 2880## grid 1 2881[2:----------------------------------------]|*6 2882[3:----------------------------------------]| 2883## grid 2 2884^ | 2885{0:~ }|*5 2886## grid 3 2887| 2888## grid 4 2889{33:╔}{11:Left}{33:═════╗}| 2890{33:║}{1: halloj! }{33:║}| 2891{33:║}{1: BORDAA }{33:║}| 2892{33:╚════}{11:Right}{33:╝}| 2893]] , 2894float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2895win_viewport ={ 2896[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2897[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2898} , 2899} 2900else 2901screen : expect { 2902grid =[[ 2903^ | 2904{0:~ }| 2905{0:~ }{33:╔}{11:Left}{33:═════╗}{0: }| 2906{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2907{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2908{0:~ }{33:╚════}{11:Right}{33:╝}{0: }| 2909| 2910]] , 2911} 2912end 2913 2914api . nvim_win_set_config ( win , { title ='Center' , title_pos ='center' , footer ='Center' , footer_pos ='center' } ) 2915if multigrid then 2916screen : expect { 2917grid =[[ 2918## grid 1 2919[2:----------------------------------------]|*6 2920[3:----------------------------------------]| 2921## grid 2 2922^ | 2923{0:~ }|*5 2924## grid 3 2925| 2926## grid 4 2927{33:╔═}{11:Center}{33:══╗}| 2928{33:║}{1: halloj! }{33:║}| 2929{33:║}{1: BORDAA }{33:║}| 2930{33:╚═}{11:Center}{33:══╝}| 2931]] , 2932float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2933win_viewport ={ 2934[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2935[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2936} , 2937} 2938else 2939screen : expect { 2940grid =[[ 2941^ | 2942{0:~ }| 2943{0:~ }{33:╔═}{11:Center}{33:══╗}{0: }| 2944{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2945{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2946{0:~ }{33:╚═}{11:Center}{33:══╝}{0: }| 2947| 2948]] , 2949} 2950end 2951 2952api . nvim_win_set_config ( win , { title ='Right' , title_pos ='right' , footer ='Left' , footer_pos ='left' } ) 2953if multigrid then 2954screen : expect { 2955grid =[[ 2956## grid 1 2957[2:----------------------------------------]|*6 2958[3:----------------------------------------]| 2959## grid 2 2960^ | 2961{0:~ }|*5 2962## grid 3 2963| 2964## grid 4 2965{33:╔════}{11:Right}{33:╗}| 2966{33:║}{1: halloj! }{33:║}| 2967{33:║}{1: BORDAA }{33:║}| 2968{33:╚}{11:Left}{33:═════╝}| 2969]] , 2970float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 2971win_viewport ={ 2972[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 2973[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 2974} , 2975} 2976else 2977screen : expect { 2978grid =[[ 2979^ | 2980{0:~ }| 2981{0:~ }{33:╔════}{11:Right}{33:╗}{0: }| 2982{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 2983{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 2984{0:~ }{33:╚}{11:Left}{33:═════╝}{0: }| 2985| 2986]] , 2987} 2988end 2989 2990command ( 'hi B0 guibg=Red guifg=Black' ) 2991command ( 'hi B1 guifg=White' ) 2992 2993api . nvim_win_set_config ( win , { 2994title ={ { '🦄' } , { 'BB' , { 'B0' , 'B1' } } } , 2995title_pos ='right' , 2996footer ={ { '🦄' } , { 'BB' , { 'B0' , 'B1' } } } , 2997footer_pos ='right' , 2998} ) 2999if multigrid then 3000screen : expect { 3001grid =[[ 3002## grid 1 3003[2:----------------------------------------]|*6 3004[3:----------------------------------------]| 3005## grid 2 3006^ | 3007{0:~ }|*5 3008## grid 3 3009| 3010## grid 4 3011{33:╔═════}{11:🦄}{7:BB}{33:╗}| 3012{33:║}{1: halloj! }{33:║}| 3013{33:║}{1: BORDAA }{33:║}| 3014{33:╚═════}{11:🦄}{7:BB}{33:╝}| 3015]] , 3016float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 3017win_viewport ={ 3018[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3019[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 3020} , 3021} 3022else 3023screen : expect { 3024grid =[[ 3025^ | 3026{0:~ }| 3027{0:~ }{33:╔═════}{11:🦄}{7:BB}{33:╗}{0: }| 3028{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 3029{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 3030{0:~ }{33:╚═════}{11:🦄}{7:BB}{33:╝}{0: }| 3031| 3032]] , 3033} 3034end 3035eq ( { { '🦄' } , { 'BB' , { 'B0' , 'B1' } } } , api . nvim_win_get_config ( win ). title ) 3036eq ( { { '🦄' } , { 'BB' , { 'B0' , 'B1' } } } , api . nvim_win_get_config ( win ). footer ) 3037 3038api . nvim_win_set_config ( win , { 3039title ={ { '🦄' , '' } , { 'BB' , { 'B0' , 'B1' , '' } } } , 3040title_pos ='left' , 3041footer ={ { '🦄' , '' } , { 'BB' , { 'B0' , 'B1' , '' } } } , 3042footer_pos ='left' , 3043} ) 3044if multigrid then 3045screen : expect { 3046grid =[[ 3047## grid 1 3048[2:----------------------------------------]|*6 3049[3:----------------------------------------]| 3050## grid 2 3051^ | 3052{0:~ }|*5 3053## grid 3 3054| 3055## grid 4 3056{33:╔}{1:🦄}{7:BB}{33:═════╗}| 3057{33:║}{1: halloj! }{33:║}| 3058{33:║}{1: BORDAA }{33:║}| 3059{33:╚}{1:🦄}{7:BB}{33:═════╝}| 3060]] , 3061float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 3062win_viewport ={ 3063[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3064[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 3065} , 3066} 3067else 3068screen : expect { 3069grid =[[ 3070^ | 3071{0:~ }| 3072{0:~ }{33:╔}{1:🦄}{7:BB}{33:═════╗}{0: }| 3073{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 3074{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 3075{0:~ }{33:╚}{1:🦄}{7:BB}{33:═════╝}{0: }| 3076| 3077]] , 3078} 3079end 3080eq ( { { '🦄' , '' } , { 'BB' , { 'B0' , 'B1' , '' } } } , api . nvim_win_get_config ( win ). title ) 3081eq ( { { '🦄' , '' } , { 'BB' , { 'B0' , 'B1' , '' } } } , api . nvim_win_get_config ( win ). footer ) 3082 3083api . nvim_win_set_config ( win , { border ='single' , title ='a\tb' , footer ='A\tB' } ) 3084if multigrid then 3085screen : expect ( { 3086grid =[[ 3087## grid 1 3088[2:----------------------------------------]|*6 3089[3:----------------------------------------]| 3090## grid 2 3091^ | 3092{0:~ }|*5 3093## grid 3 3094| 3095## grid 4 3096{33:┌}{11:a^Ib}{33:─────┐}| 3097{33:│}{1: halloj! }{33:│}| 3098{33:│}{1: BORDAA }{33:│}| 3099{33:└}{11:A^IB}{33:─────┘}| 3100]] , 3101float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 3102win_viewport ={ 3103[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3104[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 3105} , 3106} ) 3107else 3108screen : expect ( [[ 3109^ | 3110{0:~ }| 3111{0:~ }{33:┌}{11:a^Ib}{33:─────┐}{0: }| 3112{0:~ }{33:│}{1: halloj! }{33:│}{0: }| 3113{0:~ }{33:│}{1: BORDAA }{33:│}{0: }| 3114{0:~ }{33:└}{11:A^IB}{33:─────┘}{0: }| 3115| 3116]] ) 3117end 3118 3119api . nvim_win_set_config ( win , { title ={ { 'a\tb' } } , footer ={ { 'A\tB' } } } ) 3120screen : expect_unchanged () 3121 3122-- making it a split should not leak memory 3123api . nvim_win_set_config ( win , { vertical =true } ) 3124if multigrid then 3125screen : expect { 3126grid =[[ 3127## grid 1 3128[4:--------------------]{5:│}[2:-------------------]|*5 3129{5:[No Name] [+] }{4:[No Name] }| 3130[3:----------------------------------------]| 3131## grid 2 3132^ | 3133{0:~ }|*4 3134## grid 3 3135| 3136## grid 4 3137halloj! | 3138BORDAA | 3139{0:~ }|*3 3140]] , 3141win_viewport ={ 3142[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3143[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 3144} , 3145} 3146else 3147screen : expect { 3148grid =[[ 3149halloj! {5:│}^ | 3150BORDAA {5:│}{0:~ }| 3151{0:~ }{5:│}{0:~ }|*3 3152{5:[No Name] [+] }{4:[No Name] }| 3153| 3154]] , 3155} 3156end 3157end ) 3158 3159it ( 'terminates border on edge of viewport when window extends past viewport' , function () 3160local buf =api . nvim_create_buf ( false , false ) 3161api . nvim_open_win ( buf , false , { relative ='editor' , width =40 , height =7 , row =0 , col =0 , border ='single' , zindex =201 } ) 3162if multigrid then 3163screen : expect { 3164grid =[[ 3165## grid 1 3166[2:----------------------------------------]|*6 3167[3:----------------------------------------]| 3168## grid 2 3169^ | 3170{0:~ }|*5 3171## grid 3 3172| 3173## grid 4 3174{33:┌────────────────────────────────────────┐}| 3175{33:│}{1: }{33:│}| 3176{33:│}{2:~ }{33:│}|*6 3177{33:└────────────────────────────────────────┘}| 3178]] , 3179float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 0 , true , 201 , 2 , 0 , 0 } } , 3180win_viewport ={ 3181[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3182[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3183} , 3184} 3185else 3186screen : expect { 3187grid =[[ 3188{33:^┌──────────────────────────────────────┐}| 3189{33:│}{1: }{33:│}| 3190{33:│}{2:~ }{33:│}|*4 3191{33:└──────────────────────────────────────┘}| 3192]] , 3193} 3194end 3195end ) 3196 3197it ( 'with border show popupmenu' , function () 3198screen : try_resize ( 40 , 10 ) 3199local buf =api . nvim_create_buf ( false , false ) 3200api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 3201'aaa aab ' , 3202'abb acc ' , 3203'' , 3204} ) 3205api . nvim_open_win ( buf , true , { relative ='editor' , width =9 , height =3 , row =0 , col =5 , border ='double' } ) 3206feed 'G' 3207 3208if multigrid then 3209screen : expect { 3210grid =[[ 3211## grid 1 3212[2:----------------------------------------]|*9 3213[3:----------------------------------------]| 3214## grid 2 3215| 3216{0:~ }|*8 3217## grid 3 3218| 3219## grid 4 3220{33:╔═════════╗}| 3221{33:║}{1:aaa aab }{33:║}| 3222{33:║}{1:abb acc }{33:║}| 3223{33:║}{1:^ }{33:║}| 3224{33:╚═════════╝}| 3225]] , 3226float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 3227win_viewport ={ 3228[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3229[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =2 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 3230} , 3231} 3232else 3233screen : expect { 3234grid =[[ 3235{33:╔═════════╗} | 3236{0:~ }{33:║}{1:aaa aab }{33:║}{0: }| 3237{0:~ }{33:║}{1:abb acc }{33:║}{0: }| 3238{0:~ }{33:║}{1:^ }{33:║}{0: }| 3239{0:~ }{33:╚═════════╝}{0: }| 3240{0:~ }|*4 3241| 3242]] , 3243} 3244end 3245 3246feed 'i<c-x><c-p>' 3247if multigrid then 3248screen : expect { 3249grid =[[ 3250## grid 1 3251[2:----------------------------------------]|*9 3252[3:----------------------------------------]| 3253## grid 2 3254| 3255{0:~ }|*8 3256## grid 3 3257{3:-- }{8:match 1 of 4} | 3258## grid 4 3259{33:╔═════════╗}| 3260{33:║}{1:aaa aab }{33:║}| 3261{33:║}{1:abb acc }{33:║}| 3262{33:║}{1:acc^ }{33:║}| 3263{33:╚═════════╝}| 3264## grid 5 3265{1: aaa }| 3266{1: aab }| 3267{1: abb }| 3268{13: acc }| 3269]] , 3270float_pos ={ 3271[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } , 3272[ 5 ] ={ - 1 , 'NW' , 4 , 4 , 0 , false , 100 , 2 , 4 , 5 } , 3273} , 3274win_viewport ={ 3275[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3276[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =2 , curcol =3 , linecount =3 , sum_scroll_delta =0 } , 3277} , 3278} 3279else 3280screen : expect { 3281grid =[[ 3282{33:╔═════════╗} | 3283{0:~ }{33:║}{1:aaa aab }{33:║}{0: }| 3284{0:~ }{33:║}{1:abb acc }{33:║}{0: }| 3285{0:~ }{33:║}{1:acc^ }{33:║}{0: }| 3286{0:~ }{1: aaa }{0: }| 3287{0:~ }{1: aab }{0: }| 3288{0:~ }{1: abb }{0: }| 3289{0:~ }{13: acc }{0: }| 3290{0:~ }| 3291{3:-- }{8:match 1 of 4} | 3292]] , 3293} 3294end 3295 3296feed '<esc>' 3297if multigrid then 3298screen : expect { 3299grid =[[ 3300## grid 1 3301[2:----------------------------------------]|*9 3302[3:----------------------------------------]| 3303## grid 2 3304| 3305{0:~ }|*8 3306## grid 3 3307| 3308## grid 4 3309{33:╔═════════╗}| 3310{33:║}{1:aaa aab }{33:║}| 3311{33:║}{1:abb acc }{33:║}| 3312{33:║}{1:ac^c }{33:║}| 3313{33:╚═════════╝}| 3314]] , 3315float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 3316win_viewport ={ 3317[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3318[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =2 , curcol =2 , linecount =3 , sum_scroll_delta =0 } , 3319} , 3320} 3321else 3322screen : expect { 3323grid =[[ 3324{33:╔═════════╗} | 3325{0:~ }{33:║}{1:aaa aab }{33:║}{0: }| 3326{0:~ }{33:║}{1:abb acc }{33:║}{0: }| 3327{0:~ }{33:║}{1:ac^c }{33:║}{0: }| 3328{0:~ }{33:╚═════════╝}{0: }| 3329{0:~ }|*4 3330| 3331]] , 3332} 3333end 3334 3335exec ( [[ 3336nnoremenu Test.foo : 3337nnoremenu Test.bar : 3338nnoremenu Test.baz : 3339]] ) 3340feed ':popup Test<CR>' 3341if multigrid then 3342screen : expect { 3343grid =[[ 3344## grid 1 3345[2:----------------------------------------]|*9 3346[3:----------------------------------------]| 3347## grid 2 3348| 3349{0:~ }|*8 3350## grid 3 3351:popup Test | 3352## grid 4 3353{33:╔═════════╗}| 3354{33:║}{1:aaa aab }{33:║}| 3355{33:║}{1:abb acc }{33:║}| 3356{33:║}{1:ac^c }{33:║}| 3357{33:╚═════════╝}| 3358## grid 5 3359{1: foo }| 3360{1: bar }| 3361{1: baz }| 3362]] , 3363float_pos ={ 3364[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } , 3365[ 5 ] ={ - 1 , 'NW' , 4 , 4 , 2 , false , 250 , 3 , 4 , 7 } , 3366} , 3367win_viewport ={ 3368[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3369[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =2 , curcol =2 , linecount =3 , sum_scroll_delta =0 } , 3370} , 3371} 3372else 3373screen : expect { 3374grid =[[ 3375{33:╔═════════╗} | 3376{0:~ }{33:║}{1:aaa aab }{33:║}{0: }| 3377{0:~ }{33:║}{1:abb acc }{33:║}{0: }| 3378{0:~ }{33:║}{1:ac^c }{33:║}{0: }| 3379{0:~ }{33:╚═}{1: foo }{33:═══╝}{0: }| 3380{0:~ }{1: bar }{0: }| 3381{0:~ }{1: baz }{0: }| 3382{0:~ }|*2 3383:popup Test | 3384]] , 3385} 3386end 3387end ) 3388 3389it ( "doesn't wrap with vertical border" , function () 3390screen : try_resize ( 40 , 10 ) 3391local buf =api . nvim_create_buf ( false , false ) 3392api . nvim_open_win ( buf , false , { relative ='editor' , width =9 , height =3 , row =0 , col =5 , border ='double' } ) 3393-- make sure text is drawn after border 3394if multigrid then 3395screen : expect { 3396grid =[[ 3397## grid 1 3398[2:----------------------------------------]|*9 3399[3:----------------------------------------]| 3400## grid 2 3401^ | 3402{0:~ }|*8 3403## grid 3 3404| 3405## grid 4 3406{33:╔═════════╗}| 3407{33:║}{1: }{33:║}| 3408{33:║}{2:~ }{33:║}|*2 3409{33:╚═════════╝}| 3410]] , 3411win_pos ={ [ 2 ] ={ height =9 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 3412float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 3413win_viewport ={ 3414[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3415[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3416} , 3417win_viewport_margins ={ 3418[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 3419[ 4 ] ={ bottom =1 , left =1 , right =1 , top =1 , win =1001 } , 3420} , 3421} 3422else 3423screen : expect ( [[ 3424^ {33:╔═════════╗} | 3425{0:~ }{33:║}{1: }{33:║}{0: }| 3426{0:~ }{33:║}{2:~ }{33:║}{0: }|*2 3427{0:~ }{33:╚═════════╝}{0: }| 3428{0:~ }|*4 3429| 3430]] ) 3431end 3432api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'aaa long line' , 'abb acc ' } ) 3433if multigrid then 3434screen : expect { 3435grid =[[ 3436## grid 1 3437[2:----------------------------------------]|*9 3438[3:----------------------------------------]| 3439## grid 2 3440^ | 3441{0:~ }|*8 3442## grid 3 3443| 3444## grid 4 3445{33:╔═════════╗}| 3446{33:║}{1:aaa long }{33:║}| 3447{33:║}{1:line }{33:║}| 3448{33:║}{1:abb acc }{33:║}| 3449{33:╚═════════╝}| 3450]] , 3451win_pos ={ [ 2 ] ={ height =9 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 3452float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 3453win_viewport ={ 3454[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3455[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 3456} , 3457win_viewport_margins ={ 3458[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 3459[ 4 ] ={ bottom =1 , left =1 , right =1 , top =1 , win =1001 } , 3460} , 3461condition =function () 3462for i =1 , 5 do 3463eq ( false , screen . _grids [ 4 ]. rows [ i ]. wrap , i ) 3464end 3465end , 3466} 3467else 3468screen : expect ( [[ 3469^ {33:╔═════════╗} | 3470{0:~ }{33:║}{1:aaa long }{33:║}{0: }| 3471{0:~ }{33:║}{1:line }{33:║}{0: }| 3472{0:~ }{33:║}{1:abb acc }{33:║}{0: }| 3473{0:~ }{33:╚═════════╝}{0: }| 3474{0:~ }|*4 3475| 3476]] ) 3477end 3478end ) 3479 3480it ( 'does wrap without vertical border' , function () 3481screen : try_resize ( 40 , 10 ) 3482local buf =api . nvim_create_buf ( false , false ) 3483api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'aaa long line' , 'abb acc ' } ) 3484api . nvim_open_win ( buf , false , { relative ='editor' , width =9 , height =3 , row =0 , col =5 } ) 3485if multigrid then 3486screen : expect { 3487grid =[[ 3488## grid 1 3489[2:----------------------------------------]|*9 3490[3:----------------------------------------]| 3491## grid 2 3492^ | 3493{0:~ }|*8 3494## grid 3 3495| 3496## grid 4 3497{1:aaa long }| 3498{1:line }| 3499{1:abb acc }| 3500]] , 3501win_pos ={ [ 2 ] ={ height =9 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 3502float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 3503win_viewport ={ 3504[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3505[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 3506} , 3507win_viewport_margins ={ 3508[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 3509[ 4 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1001 } , 3510} , 3511condition =function () 3512for i =1 , 3 do 3513eq ( i == 1 , screen . _grids [ 4 ]. rows [ i ]. wrap , i ) 3514end 3515end , 3516} 3517else 3518screen : expect ( [[ 3519^ {1:aaa long } | 3520{0:~ }{1:line }{0: }| 3521{0:~ }{1:abb acc }{0: }| 3522{0:~ }|*6 3523| 3524]] ) 3525end 3526end ) 3527 3528it ( 'border is drawn properly when number column is too wide #35431' , function () 3529local buf =api . nvim_create_buf ( false , false ) 3530local opts ={ relative ='editor' , row =1 , col =1 , width =3 , height =3 , border ='rounded' } 3531local win =api . nvim_open_win ( buf , false , opts ) 3532api . nvim_set_option_value ( 'number' , true , { win =win } ) 3533if multigrid then 3534screen : expect ( { 3535grid =[[ 3536## grid 1 3537[2:----------------------------------------]|*6 3538[3:----------------------------------------]| 3539## grid 2 3540^ | 3541{0:~ }|*5 3542## grid 3 3543| 3544## grid 4 3545{33:╭───╮}| 3546{33:│}{32: 1}{33:│}| 3547{33:│}{32: }{33:│}|*2 3548{33:╰───╯}| 3549]] , 3550float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 1 , 1 , 1 } } , 3551} ) 3552else 3553screen : expect ( [[ 3554^ | 3555{0:~}{33:╭───╮}{0: }| 3556{0:~}{33:│}{32: 1}{33:│}{0: }| 3557{0:~}{33:│}{32: }{33:│}{0: }|*2 3558{0:~}{33:╰───╯}{0: }| 3559| 3560]] ) 3561end 3562end ) 3563 3564it ( 'show ruler of current floating window' , function () 3565command 'set ruler' 3566local buf =api . nvim_create_buf ( false , false ) 3567api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'aaa aab ' , 'abb acc ' } ) 3568api . nvim_open_win ( buf , true , { relative ='editor' , width =9 , height =3 , row =0 , col =5 } ) 3569feed 'gg' 3570 3571if multigrid then 3572screen : expect { 3573grid =[[ 3574## grid 1 3575[2:----------------------------------------]|*6 3576[3:----------------------------------------]| 3577## grid 2 3578| 3579{0:~ }|*5 3580## grid 3 35811,1 All| 3582## grid 4 3583{1:^aaa aab }| 3584{1:abb acc }| 3585{2:~ }| 3586]] , 3587float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 3588win_viewport ={ 3589[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3590[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 3591} , 3592} 3593else 3594screen : expect { 3595grid =[[ 3596{1:^aaa aab } | 3597{0:~ }{1:abb acc }{0: }| 3598{0:~ }{2:~ }{0: }| 3599{0:~ }|*3 36001,1 All| 3601]] , 3602} 3603end 3604 3605feed 'w' 3606if multigrid then 3607screen : expect { 3608grid =[[ 3609## grid 1 3610[2:----------------------------------------]|*6 3611[3:----------------------------------------]| 3612## grid 2 3613| 3614{0:~ }|*5 3615## grid 3 36161,5 All| 3617## grid 4 3618{1:aaa ^aab }| 3619{1:abb acc }| 3620{2:~ }| 3621]] , 3622float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 3623win_viewport ={ 3624[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3625[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =4 , linecount =2 , sum_scroll_delta =0 } , 3626} , 3627} 3628else 3629screen : expect { 3630grid =[[ 3631{1:aaa ^aab } | 3632{0:~ }{1:abb acc }{0: }| 3633{0:~ }{2:~ }{0: }| 3634{0:~ }|*3 36351,5 All| 3636]] , 3637} 3638end 3639end ) 3640 3641it ( "correct ruler position in current float with 'rulerformat' set" , function () 3642command 'set ruler rulerformat=fish:<><' 3643api . nvim_open_win ( 0 , true , { relative ='editor' , width =9 , height =3 , row =0 , col =5 } ) 3644if multigrid then 3645screen : expect { 3646grid =[[ 3647## grid 1 3648[2:----------------------------------------]|*6 3649[3:----------------------------------------]| 3650## grid 2 3651| 3652{0:~ }|*5 3653## grid 3 3654fish:<>< | 3655## grid 4 3656{1:^ }| 3657{2:~ }|*2 3658]] , 3659float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 3660win_viewport ={ 3661[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3662[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3663} , 3664} 3665else 3666screen : expect { 3667grid =[[ 3668{1:^ } | 3669{0:~ }{2:~ }{0: }|*2 3670{0:~ }|*3 3671fish:<>< | 3672]] , 3673} 3674end 3675end ) 3676 3677it ( 'does not show ruler of not-last current float during ins-completion' , function () 3678screen : try_resize ( 50 , 9 ) 3679command 'set ruler showmode' 3680api . nvim_open_win ( 0 , false , { relative ='editor' , width =3 , height =3 , row =0 , col =0 } ) 3681api . nvim_open_win ( 0 , false , { relative ='editor' , width =3 , height =3 , row =0 , col =5 } ) 3682feed '<c-w>w' 3683neq ( '' , api . nvim_win_get_config ( 0 ). relative ) 3684neq ( fn . winnr '$' , fn . winnr ()) 3685if multigrid then 3686screen : expect { 3687grid =[[ 3688## grid 1 3689[2:--------------------------------------------------]|*8 3690[3:--------------------------------------------------]| 3691## grid 2 3692| 3693{0:~ }|*7 3694## grid 3 36950,0-1 All| 3696## grid 4 3697{1: }| 3698{2:~ }|*2 3699## grid 5 3700{1:^ }| 3701{2:~ }|*2 3702]] , 3703float_pos ={ 3704[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 0 , true , 50 , 1 , 0 , 0 } , 3705[ 5 ] ={ 1002 , 'NW' , 1 , 0 , 5 , true , 50 , 2 , 0 , 5 } , 3706} , 3707win_viewport ={ 3708[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3709[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3710[ 5 ] ={ win =1002 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3711} , 3712} 3713else 3714screen : expect { 3715grid =[[ 3716{1: } {1:^ } | 3717{2:~ }{0: }{2:~ }{0: }|*2 3718{0:~ }|*5 37190,0-1 All| 3720]] , 3721} 3722end 3723feed 'i<c-x>' 3724if multigrid then 3725screen : expect { 3726grid =[[ 3727## grid 1 3728[2:--------------------------------------------------]|*8 3729[3:--------------------------------------------------]| 3730## grid 2 3731| 3732{0:~ }|*7 3733## grid 3 3734{3:-- ^X mode (^]^D^E^F^I^K^L^N^O^P^Rs^U^V^Y)} | 3735## grid 4 3736{1: }| 3737{2:~ }|*2 3738## grid 5 3739{1:^ }| 3740{2:~ }|*2 3741]] , 3742float_pos ={ 3743[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 0 , true , 50 , 1 , 0 , 0 } , 3744[ 5 ] ={ 1002 , 'NW' , 1 , 0 , 5 , true , 50 , 2 , 0 , 5 } , 3745} , 3746win_viewport ={ 3747[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3748[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3749[ 5 ] ={ win =1002 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3750} , 3751} 3752else 3753screen : expect { 3754grid =[[ 3755{1: } {1:^ } | 3756{2:~ }{0: }{2:~ }{0: }|*2 3757{0:~ }|*5 3758{3:-- ^X mode (^]^D^E^F^I^K^L^N^O^P^Rs^U^V^Y)} | 3759]] , 3760} 3761end 3762end ) 3763 3764it ( 'can have minimum size' , function () 3765insert ( 'the background text' ) 3766local buf =api . nvim_create_buf ( false , true ) 3767api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'x' } ) 3768local win =api . nvim_open_win ( buf , false , { relative ='win' , width =1 , height =1 , row =0 , col =4 , focusable =false } ) 3769if multigrid then 3770screen : expect { 3771grid =[[ 3772## grid 1 3773[2:----------------------------------------]|*6 3774[3:----------------------------------------]| 3775## grid 2 3776the background tex^t | 3777{0:~ }|*5 3778## grid 3 3779| 3780## grid 4 3781{1:x}| 3782]] , 3783float_pos ={ [ 4 ] ={ 1001 , 'NW' , 2 , 0 , 4 , false , 50 , 1 , 0 , 4 } } , 3784} 3785else 3786screen : expect ( [[ 3787the {1:x}ackground tex^t | 3788{0:~ }|*5 3789| 3790]] ) 3791end 3792 3793api . nvim_win_set_config ( win , { relative ='win' , row =0 , col =15 } ) 3794if multigrid then 3795screen : expect { 3796grid =[[ 3797## grid 1 3798[2:----------------------------------------]|*6 3799[3:----------------------------------------]| 3800## grid 2 3801the background tex^t | 3802{0:~ }|*5 3803## grid 3 3804| 3805## grid 4 3806{1:x}| 3807]] , 3808float_pos ={ [ 4 ] ={ 1001 , 'NW' , 2 , 0 , 15 , false , 50 , 1 , 0 , 15 } } , 3809} 3810else 3811screen : expect ( [[ 3812the background {1:x}ex^t | 3813{0:~ }|*5 3814| 3815]] ) 3816end 3817 3818api . nvim_win_close ( win , false ) 3819if multigrid then 3820screen : expect ( [[ 3821## grid 1 3822[2:----------------------------------------]|*6 3823[3:----------------------------------------]| 3824## grid 2 3825the background tex^t | 3826{0:~ }|*5 3827## grid 3 3828| 3829]] ) 3830else 3831screen : expect ( [[ 3832the background tex^t | 3833{0:~ }|*5 3834| 3835]] ) 3836end 3837end ) 3838 3839describe ( 'no crash when rearranging windows' , function () 3840local function test_rearrange_windows ( cmd ) 3841command ( 'set laststatus=2' ) 3842screen : try_resize ( 40 , 13 ) 3843 3844command ( 'args X1 X2 X3 X4 X5 X6' ) 3845command ( 'sargument 2' ) 3846command ( 'sargument 3' ) 3847local w3 =curwin () 3848command ( 'sargument 4' ) 3849local w4 =curwin () 3850command ( 'sargument 5' ) 3851command ( 'sargument 6' ) 3852 3853local float_opts ={ relative ='editor' , row =6 , col =0 , width =40 , height =1 } 3854api . nvim_win_set_config ( w3 , float_opts ) 3855api . nvim_win_set_config ( w4 , float_opts ) 3856command ( 'wincmd =' ) 3857if multigrid then 3858screen : expect { 3859grid =[[ 3860## grid 1 3861[8:----------------------------------------]|*2 3862{4:X6 }| 3863[7:----------------------------------------]|*2 3864{5:X5 }| 3865[4:----------------------------------------]|*2 3866{5:X2 }| 3867[2:----------------------------------------]|*2 3868{5:X1 }| 3869[3:----------------------------------------]| 3870## grid 2 3871| 3872{0:~ }| 3873## grid 3 3874| 3875## grid 4 3876| 3877{0:~ }| 3878## grid 5 3879{1: }| 3880## grid 6 3881{1: }| 3882## grid 7 3883| 3884{0:~ }| 3885## grid 8 3886^ | 3887{0:~ }| 3888]] , 3889float_pos ={ 3890[ 5 ] ={ 1002 , 'NW' , 1 , 6 , 0 , true , 50 , 1 , 6 , 0 } , 3891[ 6 ] ={ 1003 , 'NW' , 1 , 6 , 0 , true , 50 , 2 , 6 , 0 } , 3892} , 3893win_viewport ={ 3894[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3895[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3896[ 5 ] ={ win =1002 , topline =0 , botline =1 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3897[ 6 ] ={ win =1003 , topline =0 , botline =1 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3898[ 7 ] ={ win =1004 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3899[ 8 ] ={ win =1005 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3900} , 3901} 3902else 3903screen : expect { 3904grid =[[ 3905^ | 3906{0:~ }| 3907{4:X6 }| 3908| 3909{0:~ }| 3910{5:X5 }| 3911{1: }| 3912{0:~ }| 3913{5:X2 }| 3914| 3915{0:~ }| 3916{5:X1 }| 3917| 3918]] , 3919} 3920end 3921 3922command ( cmd ) 3923if multigrid then 3924screen : expect { 3925grid =[[ 3926## grid 1 3927[2:----------------------------------------]| 3928{4:X1 }| 3929[4:----------------------------------------]| 3930{5:X2 }| 3931[9:----------------------------------------]| 3932{5:X3 }| 3933[10:----------------------------------------]| 3934{5:X4 }| 3935[7:----------------------------------------]| 3936{5:X5 }| 3937[8:----------------------------------------]| 3938{5:X6 }| 3939[3:----------------------------------------]| 3940## grid 2 3941^ | 3942## grid 3 3943| 3944## grid 4 3945| 3946## grid 7 3947| 3948## grid 8 3949| 3950## grid 9 3951| 3952## grid 10 3953| 3954]] , 3955win_viewport ={ 3956[ 2 ] ={ win =1000 , topline =0 , botline =1 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3957[ 4 ] ={ win =1001 , topline =0 , botline =1 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3958[ 7 ] ={ win =1004 , topline =0 , botline =1 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3959[ 8 ] ={ win =1005 , topline =0 , botline =1 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3960[ 9 ] ={ win =1006 , topline =0 , botline =1 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3961[ 10 ] ={ win =1007 , topline =0 , botline =1 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 3962} , 3963} 3964else 3965screen : expect { 3966grid =[[ 3967^ | 3968{4:X1 }| 3969| 3970{5:X2 }| 3971| 3972{5:X3 }| 3973| 3974{5:X4 }| 3975| 3976{5:X5 }| 3977| 3978{5:X6 }| 3979| 3980]] , 3981} 3982end 3983end 3984 3985it ( 'using :unhide' , function () 3986test_rearrange_windows ( 'unhide' ) 3987end ) 3988 3989it ( 'using :all' , function () 3990test_rearrange_windows ( 'all' ) 3991end ) 3992end ) 3993 3994it ( 'validation: multigrid' , function () 3995if multigrid then 3996local buf =api . nvim_create_buf ( false , false ) 3997eq ( 3998"Conflict: 'win' not allowed with external window" , 3999pcall_err ( api . nvim_open_win , buf , false , { external =true , win =0 , width =10 , height =10 } ) 4000) 4001api . nvim_open_win ( buf , true , { external =true , width =10 , height =10 } ) 4002eq ( "Conflict: 'win' not allowed with external window" , pcall_err ( api . nvim_win_set_config , 0 , { win =0 } )) 4003-- OK to include "win" if external window is also reconfigured to a normal float. 4004api . nvim_win_set_config ( 0 , { relative ='editor' , win =0 , row =0 , col =0 , width =5 , height =5 } ) 4005eq ( 'editor' , api . nvim_win_get_config ( 0 ). relative ) 4006end 4007end ) 4008 4009it ( 'can be placed relative window or cursor' , function () 4010screen : try_resize ( 40 , 9 ) 4011api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'just some' , 'example text' } ) 4012feed ( 'gge' ) 4013local oldwin =api . nvim_get_current_win () 4014command ( 'below split' ) 4015if multigrid then 4016screen : expect ( [[ 4017## grid 1 4018[2:----------------------------------------]|*3 4019{5:[No Name] [+] }| 4020[4:----------------------------------------]|*3 4021{4:[No Name] [+] }| 4022[3:----------------------------------------]| 4023## grid 2 4024just some | 4025example text | 4026{0:~ }| 4027## grid 3 4028| 4029## grid 4 4030jus^t some | 4031example text | 4032{0:~ }| 4033]] ) 4034else 4035screen : expect ( [[ 4036just some | 4037example text | 4038{0:~ }| 4039{5:[No Name] [+] }| 4040jus^t some | 4041example text | 4042{0:~ }| 4043{4:[No Name] [+] }| 4044| 4045]] ) 4046end 4047 4048local buf =api . nvim_create_buf ( false , false ) 4049-- no 'win' arg, relative default window 4050local win =api . nvim_open_win ( buf , false , { relative ='win' , width =20 , height =2 , row =0 , col =10 } ) 4051if multigrid then 4052screen : expect { 4053grid =[[ 4054## grid 1 4055[2:----------------------------------------]|*3 4056{5:[No Name] [+] }| 4057[4:----------------------------------------]|*3 4058{4:[No Name] [+] }| 4059[3:----------------------------------------]| 4060## grid 2 4061just some | 4062example text | 4063{0:~ }| 4064## grid 3 4065| 4066## grid 4 4067jus^t some | 4068example text | 4069{0:~ }| 4070## grid 5 4071{1: }| 4072{2:~ }| 4073]] , 4074float_pos ={ [ 5 ] ={ 1002 , 'NW' , 4 , 0 , 10 , true , 50 , 1 , 4 , 10 } } , 4075} 4076else 4077screen : expect ( [[ 4078just some | 4079example text | 4080{0:~ }| 4081{5:[No Name] [+] }| 4082jus^t some {1: } | 4083example te{2:~ } | 4084{0:~ }| 4085{4:[No Name] [+] }| 4086| 4087]] ) 4088end 4089 4090api . nvim_win_set_config ( win , { relative ='cursor' , row =1 , col =- 2 } ) 4091if multigrid then 4092screen : expect { 4093grid =[[ 4094## grid 1 4095[2:----------------------------------------]|*3 4096{5:[No Name] [+] }| 4097[4:----------------------------------------]|*3 4098{4:[No Name] [+] }| 4099[3:----------------------------------------]| 4100## grid 2 4101just some | 4102example text | 4103{0:~ }| 4104## grid 3 4105| 4106## grid 4 4107jus^t some | 4108example text | 4109{0:~ }| 4110## grid 5 4111{1: }| 4112{2:~ }| 4113]] , 4114float_pos ={ [ 5 ] ={ 1002 , 'NW' , 4 , 1 , 1 , true , 50 , 1 , 5 , 1 } } , 4115} 4116else 4117screen : expect ( [[ 4118just some | 4119example text | 4120{0:~ }| 4121{5:[No Name] [+] }| 4122jus^t some | 4123e{1: } | 4124{0:~}{2:~ }{0: }| 4125{4:[No Name] [+] }| 4126| 4127]] ) 4128end 4129 4130api . nvim_win_set_config ( win , { relative ='cursor' , row =0 , col =0 , anchor ='SW' } ) 4131if multigrid then 4132screen : expect { 4133grid =[[ 4134## grid 1 4135[2:----------------------------------------]|*3 4136{5:[No Name] [+] }| 4137[4:----------------------------------------]|*3 4138{4:[No Name] [+] }| 4139[3:----------------------------------------]| 4140## grid 2 4141just some | 4142example text | 4143{0:~ }| 4144## grid 3 4145| 4146## grid 4 4147jus^t some | 4148example text | 4149{0:~ }| 4150## grid 5 4151{1: }| 4152{2:~ }| 4153]] , 4154float_pos ={ [ 5 ] ={ 1002 , 'SW' , 4 , 0 , 3 , true , 50 , 1 , 2 , 3 } } , 4155} 4156else 4157screen : expect ( [[ 4158just some | 4159example text | 4160{0:~ }{1: }{0: }| 4161{5:[No}{2:~ }{5: }| 4162jus^t some | 4163example text | 4164{0:~ }| 4165{4:[No Name] [+] }| 4166| 4167]] ) 4168end 4169 4170api . nvim_win_set_config ( win , { relative ='win' , win =oldwin , row =1 , col =10 , anchor ='NW' } ) 4171if multigrid then 4172screen : expect { 4173grid =[[ 4174## grid 1 4175[2:----------------------------------------]|*3 4176{5:[No Name] [+] }| 4177[4:----------------------------------------]|*3 4178{4:[No Name] [+] }| 4179[3:----------------------------------------]| 4180## grid 2 4181just some | 4182example text | 4183{0:~ }| 4184## grid 3 4185| 4186## grid 4 4187jus^t some | 4188example text | 4189{0:~ }| 4190## grid 5 4191{1: }| 4192{2:~ }| 4193]] , 4194float_pos ={ [ 5 ] ={ 1002 , 'NW' , 2 , 1 , 10 , true , 50 , 1 , 1 , 10 } } , 4195} 4196else 4197screen : expect ( [[ 4198just some | 4199example te{1: } | 4200{0:~ }{2:~ }{0: }| 4201{5:[No Name] [+] }| 4202jus^t some | 4203example text | 4204{0:~ }| 4205{4:[No Name] [+] }| 4206| 4207]] ) 4208end 4209 4210api . nvim_win_set_config ( win , { relative ='win' , win =oldwin , row =3 , col =39 , anchor ='SE' } ) 4211if multigrid then 4212screen : expect { 4213grid =[[ 4214## grid 1 4215[2:----------------------------------------]|*3 4216{5:[No Name] [+] }| 4217[4:----------------------------------------]|*3 4218{4:[No Name] [+] }| 4219[3:----------------------------------------]| 4220## grid 2 4221just some | 4222example text | 4223{0:~ }| 4224## grid 3 4225| 4226## grid 4 4227jus^t some | 4228example text | 4229{0:~ }| 4230## grid 5 4231{1: }| 4232{2:~ }| 4233]] , 4234float_pos ={ [ 5 ] ={ 1002 , 'SE' , 2 , 3 , 39 , true , 50 , 1 , 1 , 19 } } , 4235} 4236else 4237screen : expect ( [[ 4238just some | 4239example text {1: } | 4240{0:~ }{2:~ }{0: }| 4241{5:[No Name] [+] }| 4242jus^t some | 4243example text | 4244{0:~ }| 4245{4:[No Name] [+] }| 4246| 4247]] ) 4248end 4249 4250api . nvim_win_set_config ( win , { relative ='win' , win =0 , row =0 , col =50 , anchor ='NE' } ) 4251if multigrid then 4252screen : expect { 4253grid =[[ 4254## grid 1 4255[2:----------------------------------------]|*3 4256{5:[No Name] [+] }| 4257[4:----------------------------------------]|*3 4258{4:[No Name] [+] }| 4259[3:----------------------------------------]| 4260## grid 2 4261just some | 4262example text | 4263{0:~ }| 4264## grid 3 4265| 4266## grid 4 4267jus^t some | 4268example text | 4269{0:~ }| 4270## grid 5 4271{1: }| 4272{2:~ }| 4273]] , 4274float_pos ={ [ 5 ] ={ 1002 , 'NE' , 4 , 0 , 50 , true , 50 , 1 , 4 , 20 } } , 4275win_viewport ={ 4276[ 2 ] ={ topline =0 , botline =3 , curline =0 , curcol =3 , linecount =2 , sum_scroll_delta =0 , win =1000 } , 4277[ 4 ] ={ topline =0 , botline =3 , curline =0 , curcol =3 , linecount =2 , sum_scroll_delta =0 , win =1001 } , 4278[ 5 ] ={ topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 , win =1002 } , 4279} , 4280} 4281else 4282screen : expect ( [[ 4283just some | 4284example text | 4285{0:~ }| 4286{5:[No Name] [+] }| 4287jus^t some {1: }| 4288example text {2:~ }| 4289{0:~ }| 4290{4:[No Name] [+] }| 4291| 4292]] ) 4293end 4294end ) 4295 4296it ( 'always anchor to corner including border' , function () 4297screen : try_resize ( 40 , 13 ) 4298api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'just some example text' , 'some more example text' } ) 4299feed ( 'ggeee' ) 4300command ( 'below split' ) 4301if multigrid then 4302screen : expect ( [[ 4303## grid 1 4304[2:----------------------------------------]|*5 4305{5:[No Name] [+] }| 4306[4:----------------------------------------]|*5 4307{4:[No Name] [+] }| 4308[3:----------------------------------------]| 4309## grid 2 4310just some example text | 4311some more example text | 4312{0:~ }|*3 4313## grid 3 4314| 4315## grid 4 4316just some exampl^e text | 4317some more example text | 4318{0:~ }|*3 4319]] ) 4320else 4321screen : expect ( [[ 4322just some example text | 4323some more example text | 4324{0:~ }|*3 4325{5:[No Name] [+] }| 4326just some exampl^e text | 4327some more example text | 4328{0:~ }|*3 4329{4:[No Name] [+] }| 4330| 4331]] ) 4332end 4333 4334local buf =api . nvim_create_buf ( false , false ) 4335api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { ' halloj! ' , ' BORDAA ' } ) 4336local win =api . nvim_open_win ( buf , false , { relative ='cursor' , width =9 , height =2 , row =1 , col =- 2 , border ='double' } ) 4337 4338if multigrid then 4339screen : expect { 4340grid =[[ 4341## grid 1 4342[2:----------------------------------------]|*5 4343{5:[No Name] [+] }| 4344[4:----------------------------------------]|*5 4345{4:[No Name] [+] }| 4346[3:----------------------------------------]| 4347## grid 2 4348just some example text | 4349some more example text | 4350{0:~ }|*3 4351## grid 3 4352| 4353## grid 4 4354just some exampl^e text | 4355some more example text | 4356{0:~ }|*3 4357## grid 5 4358{33:╔═════════╗}| 4359{33:║}{1: halloj! }{33:║}| 4360{33:║}{1: BORDAA }{33:║}| 4361{33:╚═════════╝}| 4362]] , 4363float_pos ={ [ 5 ] ={ 1002 , 'NW' , 4 , 1 , 14 , true , 50 , 1 , 7 , 14 } } , 4364} 4365else 4366screen : expect ( [[ 4367just some example text | 4368some more example text | 4369{0:~ }|*3 4370{5:[No Name] [+] }| 4371just some exampl^e text | 4372some more exam{33:╔═════════╗} | 4373{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 4374{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 4375{0:~ }{33:╚═════════╝}{0: }| 4376{4:[No Name] [+] }| 4377| 4378]] ) 4379end 4380 4381api . nvim_win_set_config ( win , { relative ='cursor' , row =0 , col =- 2 , anchor ='NE' } ) 4382if multigrid then 4383screen : expect { 4384grid =[[ 4385## grid 1 4386[2:----------------------------------------]|*5 4387{5:[No Name] [+] }| 4388[4:----------------------------------------]|*5 4389{4:[No Name] [+] }| 4390[3:----------------------------------------]| 4391## grid 2 4392just some example text | 4393some more example text | 4394{0:~ }|*3 4395## grid 3 4396| 4397## grid 4 4398just some exampl^e text | 4399some more example text | 4400{0:~ }|*3 4401## grid 5 4402{33:╔═════════╗}| 4403{33:║}{1: halloj! }{33:║}| 4404{33:║}{1: BORDAA }{33:║}| 4405{33:╚═════════╝}| 4406]] , 4407float_pos ={ [ 5 ] ={ 1002 , 'NE' , 4 , 0 , 14 , true , 50 , 1 , 6 , 3 } } , 4408} 4409else 4410screen : expect ( [[ 4411just some example text | 4412some more example text | 4413{0:~ }|*3 4414{5:[No Name] [+] }| 4415jus{33:╔═════════╗}pl^e text | 4416som{33:║}{1: halloj! }{33:║}ple text | 4417{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 4418{0:~ }{33:╚═════════╝}{0: }| 4419{0:~ }| 4420{4:[No Name] [+] }| 4421| 4422]] ) 4423end 4424 4425api . nvim_win_set_config ( win , { relative ='cursor' , row =1 , col =- 2 , anchor ='SE' } ) 4426if multigrid then 4427screen : expect { 4428grid =[[ 4429## grid 1 4430[2:----------------------------------------]|*5 4431{5:[No Name] [+] }| 4432[4:----------------------------------------]|*5 4433{4:[No Name] [+] }| 4434[3:----------------------------------------]| 4435## grid 2 4436just some example text | 4437some more example text | 4438{0:~ }|*3 4439## grid 3 4440| 4441## grid 4 4442just some exampl^e text | 4443some more example text | 4444{0:~ }|*3 4445## grid 5 4446{33:╔═════════╗}| 4447{33:║}{1: halloj! }{33:║}| 4448{33:║}{1: BORDAA }{33:║}| 4449{33:╚═════════╝}| 4450]] , 4451float_pos ={ [ 5 ] ={ 1002 , 'SE' , 4 , 1 , 14 , true , 50 , 1 , 3 , 3 } } , 4452} 4453else 4454screen : expect ( [[ 4455just some example text | 4456some more example text | 4457{0:~ }| 4458{0:~ }{33:╔═════════╗}{0: }| 4459{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 4460{5:[No}{33:║}{1: BORDAA }{33:║}{5: }| 4461jus{33:╚═════════╝}pl^e text | 4462some more example text | 4463{0:~ }|*3 4464{4:[No Name] [+] }| 4465| 4466]] ) 4467end 4468 4469api . nvim_win_set_config ( win , { relative ='cursor' , row =0 , col =- 2 , anchor ='SW' } ) 4470if multigrid then 4471screen : expect { 4472grid =[[ 4473## grid 1 4474[2:----------------------------------------]|*5 4475{5:[No Name] [+] }| 4476[4:----------------------------------------]|*5 4477{4:[No Name] [+] }| 4478[3:----------------------------------------]| 4479## grid 2 4480just some example text | 4481some more example text | 4482{0:~ }|*3 4483## grid 3 4484| 4485## grid 4 4486just some exampl^e text | 4487some more example text | 4488{0:~ }|*3 4489## grid 5 4490{33:╔═════════╗}| 4491{33:║}{1: halloj! }{33:║}| 4492{33:║}{1: BORDAA }{33:║}| 4493{33:╚═════════╝}| 4494]] , 4495float_pos ={ [ 5 ] ={ 1002 , 'SW' , 4 , 0 , 14 , true , 50 , 1 , 2 , 14 } } , 4496} 4497else 4498screen : expect ( [[ 4499just some example text | 4500some more example text | 4501{0:~ }{33:╔═════════╗}{0: }| 4502{0:~ }{33:║}{1: halloj! }{33:║}{0: }| 4503{0:~ }{33:║}{1: BORDAA }{33:║}{0: }| 4504{5:[No Name] [+] }{33:╚═════════╝}{5: }| 4505just some exampl^e text | 4506some more example text | 4507{0:~ }|*3 4508{4:[No Name] [+] }| 4509| 4510]] ) 4511end 4512end ) 4513 4514it ( 'anchored to another floating window updated in the same call #14735' , function () 4515feed ( 'i<CR><CR><CR><Esc>' ) 4516 4517exec ( [[ 4518let b1 = nvim_create_buf(v:true, v:false) 4519let b2 = nvim_create_buf(v:true, v:false) 4520let b3 = nvim_create_buf(v:true, v:false) 4521let b4 = nvim_create_buf(v:true, v:false) 4522let b5 = nvim_create_buf(v:true, v:false) 4523let b6 = nvim_create_buf(v:true, v:false) 4524let b7 = nvim_create_buf(v:true, v:false) 4525let b8 = nvim_create_buf(v:true, v:false) 4526call setbufline(b1, 1, '1') 4527call setbufline(b2, 1, '2') 4528call setbufline(b3, 1, '3') 4529call setbufline(b4, 1, '4') 4530call setbufline(b5, 1, '5') 4531call setbufline(b6, 1, '6') 4532call setbufline(b7, 1, '7') 4533call setbufline(b8, 1, '8') 4534let o1 = #{relative: 'editor', row: 1, col: 10, width: 5, height: 1} 4535let w1 = nvim_open_win(b1, v:false, o1) 4536let o2 = extendnew(o1, #{col: 30}) 4537let w2 = nvim_open_win(b2, v:false, o2) 4538let o3 = extendnew(o1, #{relative: 'win', win: w1, anchor: 'NE', col: 0}) 4539let w3 = nvim_open_win(b3, v:false, o3) 4540let o4 = extendnew(o3, #{win: w2}) 4541let w4 = nvim_open_win(b4, v:false, o4) 4542let o5 = extendnew(o3, #{win: w3, anchor: 'SE', row: 0}) 4543let w5 = nvim_open_win(b5, v:false, o5) 4544let o6 = extendnew(o5, #{win: w4}) 4545let w6 = nvim_open_win(b6, v:false, o6) 4546let o7 = extendnew(o5, #{win: w5, anchor: 'SW', col: 5}) 4547let w7 = nvim_open_win(b7, v:false, o7) 4548let o8 = extendnew(o7, #{win: w6}) 4549let w8 = nvim_open_win(b8, v:false, o8) 4550]] ) 4551if multigrid then 4552screen : expect { 4553grid =[[ 4554## grid 1 4555[2:----------------------------------------]|*6 4556[3:----------------------------------------]| 4557## grid 2 4558|*3 4559^ | 4560{0:~ }|*2 4561## grid 3 4562| 4563## grid 5 4564{1:1 }| 4565## grid 6 4566{1:2 }| 4567## grid 7 4568{1:3 }| 4569## grid 8 4570{1:4 }| 4571## grid 9 4572{1:5 }| 4573## grid 10 4574{1:6 }| 4575## grid 11 4576{1:7 }| 4577## grid 12 4578{1:8 }| 4579]] , 4580float_pos ={ 4581[ 5 ] ={ 1002 , 'NW' , 1 , 1 , 10 , true , 50 , 5 , 1 , 10 } , 4582[ 6 ] ={ 1003 , 'NW' , 1 , 1 , 30 , true , 50 , 1 , 1 , 30 } , 4583[ 7 ] ={ 1004 , 'NE' , 5 , 1 , 0 , true , 50 , 6 , 2 , 5 } , 4584[ 8 ] ={ 1005 , 'NE' , 6 , 1 , 0 , true , 50 , 2 , 2 , 25 } , 4585[ 9 ] ={ 1006 , 'SE' , 7 , 0 , 0 , true , 50 , 7 , 1 , 0 } , 4586[ 10 ] ={ 1007 , 'SE' , 8 , 0 , 0 , true , 50 , 3 , 1 , 20 } , 4587[ 11 ] ={ 1008 , 'SW' , 9 , 0 , 5 , true , 50 , 8 , 0 , 5 } , 4588[ 12 ] ={ 1009 , 'SW' , 10 , 0 , 5 , true , 50 , 4 , 0 , 25 } , 4589} , 4590} 4591else 4592screen : expect ( [[ 4593{1:7 } {1:8 } | 4594{1:5 } {1:1 } {1:6 } {1:2 } | 4595{1:3 } {1:4 } | 4596^ | 4597{0:~ }|*2 4598| 4599]] ) 4600end 4601 4602-- Reconfigure in different directions 4603exec ( [[ 4604let o1 = extendnew(o1, #{anchor: 'NW'}) 4605call nvim_win_set_config(w8, o1) 4606let o2 = extendnew(o2, #{anchor: 'NW'}) 4607call nvim_win_set_config(w4, o2) 4608let o3 = extendnew(o3, #{win: w8}) 4609call nvim_win_set_config(w2, o3) 4610let o4 = extendnew(o4, #{win: w4}) 4611call nvim_win_set_config(w1, o4) 4612let o5 = extendnew(o5, #{win: w2}) 4613call nvim_win_set_config(w6, o5) 4614let o6 = extendnew(o6, #{win: w1}) 4615call nvim_win_set_config(w3, o6) 4616let o7 = extendnew(o7, #{win: w6}) 4617call nvim_win_set_config(w5, o7) 4618let o8 = extendnew(o8, #{win: w3}) 4619call nvim_win_set_config(w7, o8) 4620]] ) 4621if multigrid then 4622screen : expect { 4623grid =[[ 4624## grid 1 4625[2:----------------------------------------]|*6 4626[3:----------------------------------------]| 4627## grid 2 4628|*3 4629^ | 4630{0:~ }|*2 4631## grid 3 4632| 4633## grid 5 4634{1:1 }| 4635## grid 6 4636{1:2 }| 4637## grid 7 4638{1:3 }| 4639## grid 8 4640{1:4 }| 4641## grid 9 4642{1:5 }| 4643## grid 10 4644{1:6 }| 4645## grid 11 4646{1:7 }| 4647## grid 12 4648{1:8 }| 4649]] , 4650float_pos ={ 4651[ 5 ] ={ 1002 , 'NE' , 8 , 1 , 0 , true , 50 , 5 , 2 , 25 } , 4652[ 6 ] ={ 1003 , 'NE' , 12 , 1 , 0 , true , 50 , 1 , 2 , 5 } , 4653[ 7 ] ={ 1004 , 'SE' , 5 , 0 , 0 , true , 50 , 6 , 1 , 20 } , 4654[ 8 ] ={ 1005 , 'NW' , 1 , 1 , 30 , true , 50 , 2 , 1 , 30 } , 4655[ 9 ] ={ 1006 , 'SW' , 10 , 0 , 5 , true , 50 , 7 , 0 , 5 } , 4656[ 10 ] ={ 1007 , 'SE' , 6 , 0 , 0 , true , 50 , 3 , 1 , 0 } , 4657[ 11 ] ={ 1008 , 'SW' , 7 , 0 , 5 , true , 50 , 8 , 0 , 25 } , 4658[ 12 ] ={ 1009 , 'NW' , 1 , 1 , 10 , true , 50 , 4 , 1 , 10 } , 4659} , 4660} 4661else 4662screen : expect ( [[ 4663{1:5 } {1:7 } | 4664{1:6 } {1:8 } {1:3 } {1:4 } | 4665{1:2 } {1:1 } | 4666^ | 4667{0:~ }|*2 4668| 4669]] ) 4670end 4671 4672-- Not clear how cycles should behave, but they should not hang or crash 4673exec ( [[ 4674let o1 = extendnew(o1, #{relative: 'win', win: w7}) 4675call nvim_win_set_config(w1, o1) 4676let o2 = extendnew(o2, #{relative: 'win', win: w8}) 4677call nvim_win_set_config(w2, o2) 4678let o3 = extendnew(o3, #{win: w1}) 4679call nvim_win_set_config(w3, o3) 4680let o4 = extendnew(o4, #{win: w2}) 4681call nvim_win_set_config(w4, o4) 4682let o5 = extendnew(o5, #{win: w3}) 4683call nvim_win_set_config(w5, o5) 4684let o6 = extendnew(o6, #{win: w4}) 4685call nvim_win_set_config(w6, o6) 4686let o7 = extendnew(o7, #{win: w5}) 4687call nvim_win_set_config(w7, o7) 4688let o8 = extendnew(o8, #{win: w6}) 4689call nvim_win_set_config(w8, o8) 4690redraw 4691]] ) 4692end ) 4693 4694it ( 'can be placed relative text in a window' , function () 4695screen : try_resize ( 30 , 5 ) 4696local firstwin =api . nvim_get_current_win () 4697api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'just some' , 'example text that is wider than the window' , '' , '' , 'more text' } ) 4698if multigrid then 4699screen : expect { 4700grid =[[ 4701## grid 1 4702[2:------------------------------]|*4 4703[3:------------------------------]| 4704## grid 2 4705^just some | 4706example text that is wider tha| 4707n the window | 4708| 4709## grid 3 4710| 4711]] , 4712} 4713else 4714screen : expect { 4715grid =[[ 4716^just some | 4717example text that is wider tha| 4718n the window | 4719|*2 4720]] , 4721} 4722end 4723 4724local buf =api . nvim_create_buf ( false , false ) 4725api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'some info!' } ) 4726 4727local win =api . nvim_open_win ( buf , false , { relative ='win' , width =12 , height =1 , bufpos ={ 1 , 32 } } ) 4728if multigrid then 4729screen : expect { 4730grid =[[ 4731## grid 1 4732[2:------------------------------]|*4 4733[3:------------------------------]| 4734## grid 2 4735^just some | 4736example text that is wider tha| 4737n the window | 4738| 4739## grid 3 4740| 4741## grid 4 4742{1:some info! }| 4743]] , 4744float_pos ={ [ 4 ] ={ 1001 , 'NW' , 2 , 3 , 2 , true , 50 , 1 , 3 , 2 } } , 4745} 4746else 4747screen : expect { 4748grid =[[ 4749^just some | 4750example text that is wider tha| 4751n the window | 4752{1:some info! } | 4753| 4754]] , 4755} 4756end 4757eq ( { 4758relative ='win' , 4759width =12 , 4760height =1 , 4761bufpos ={ 1 , 32 } , 4762anchor ='NW' , 4763border ='none' , 4764style ='' , 4765hide =false , 4766external =false , 4767col =0 , 4768row =1 , 4769win =firstwin , 4770focusable =true , 4771mouse =true , 4772zindex =50 , 4773} , api . nvim_win_get_config ( win )) 4774 4775feed ( '<c-e>' ) 4776if multigrid then 4777screen : expect { 4778grid =[[ 4779## grid 1 4780[2:------------------------------]|*4 4781[3:------------------------------]| 4782## grid 2 4783^example text that is wider tha| 4784n the window | 4785|*2 4786## grid 3 4787| 4788## grid 4 4789{1:some info! }| 4790]] , 4791float_pos ={ [ 4 ] ={ 1001 , 'NW' , 2 , 2 , 2 , true , 50 , 1 , 2 , 2 } } , 4792} 4793else 4794screen : expect { 4795grid =[[ 4796^example text that is wider tha| 4797n the window | 4798{1:some info! } | 4799|*2 4800]] , 4801} 4802end 4803 4804screen : try_resize ( 45 , 5 ) 4805if multigrid then 4806screen : expect { 4807grid =[[ 4808## grid 1 4809[2:---------------------------------------------]|*4 4810[3:---------------------------------------------]| 4811## grid 2 4812^example text that is wider than the window | 4813|*2 4814more text | 4815## grid 3 4816| 4817## grid 4 4818{1:some info! }| 4819]] , 4820float_pos ={ [ 4 ] ={ 1001 , 'NW' , 2 , 1 , 32 , true , 50 , 1 , 1 , 32 } } , 4821} 4822else 4823-- note: appears misaligned due to cursor 4824screen : expect { 4825grid =[[ 4826^example text that is wider than the window | 4827{1:some info! } | 4828| 4829more text | 4830| 4831]] , 4832} 4833end 4834 4835screen : try_resize ( 25 , 10 ) 4836if multigrid then 4837screen : expect { 4838grid =[[ 4839## grid 1 4840[2:-------------------------]|*9 4841[3:-------------------------]| 4842## grid 2 4843^example text that is wide| 4844r than the window | 4845|*2 4846more text | 4847{0:~ }|*4 4848## grid 3 4849| 4850## grid 4 4851{1:some info! }| 4852]] , 4853float_pos ={ [ 4 ] ={ 1001 , 'NW' , 2 , 2 , 7 , true , 50 , 1 , 2 , 7 } } , 4854} 4855else 4856screen : expect { 4857grid =[[ 4858^example text that is wide| 4859r than the window | 4860{1:some info! } | 4861| 4862more text | 4863{0:~ }|*4 4864| 4865]] , 4866} 4867end 4868 4869api . nvim_win_set_config ( win , { relative ='win' , bufpos ={ 1 , 32 } , anchor ='SW' } ) 4870if multigrid then 4871screen : expect { 4872grid =[[ 4873## grid 1 4874[2:-------------------------]|*9 4875[3:-------------------------]| 4876## grid 2 4877^example text that is wide| 4878r than the window | 4879|*2 4880more text | 4881{0:~ }|*4 4882## grid 3 4883| 4884## grid 4 4885{1:some info! }| 4886]] , 4887float_pos ={ [ 4 ] ={ 1001 , 'SW' , 2 , 1 , 7 , true , 50 , 1 , 0 , 7 } } , 4888} 4889else 4890screen : expect { 4891grid =[[ 4892^example{1:some info! }s wide| 4893r than the window | 4894|*2 4895more text | 4896{0:~ }|*4 4897| 4898]] , 4899} 4900end 4901 4902command ( 'set laststatus=0' ) 4903command ( 'botright vnew' ) 4904if multigrid then 4905screen : expect { 4906grid =[[ 4907## grid 1 4908[2:----]{5:│}[5:--------------------]|*9 4909[3:-------------------------]| 4910## grid 2 4911exam| 4912ple | 4913text| 4914tha| 4915t is| 4916wid| 4917er t| 4918han | 4919the | 4920## grid 3 4921| 4922## grid 4 4923{1:some info! }| 4924## grid 5 4925^ | 4926{0:~ }|*8 4927]] , 4928float_pos ={ 4929[ 4 ] ={ 1001 , 'SW' , 2 , 8 , 0 , true , 50 , 1 , 7 , 0 } , 4930} , 4931} 4932else 4933screen : expect { 4934grid =[[ 4935exam{5:│}^ | 4936ple {5:│}{0:~ }| 4937text{5:│}{0:~ }| 4938tha{5:│}{0:~ }| 4939t is{5:│}{0:~ }| 4940wid{5:│}{0:~ }| 4941er t{5:│}{0:~ }| 4942{1:some info! }{0: }| 4943the {5:│}{0:~ }| 4944| 4945]] , 4946} 4947end 4948command ( 'close' ) 4949 4950api . nvim_win_set_config ( win , { relative ='win' , bufpos ={ 1 , 32 } , anchor ='NW' , col =- 2 } ) 4951if multigrid then 4952screen : expect { 4953grid =[[ 4954## grid 1 4955[2:-------------------------]|*9 4956[3:-------------------------]| 4957## grid 2 4958^example text that is wide| 4959r than the window | 4960|*2 4961more text | 4962{0:~ }|*4 4963## grid 3 4964| 4965## grid 4 4966{1:some info! }| 4967]] , 4968float_pos ={ [ 4 ] ={ 1001 , 'NW' , 2 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 4969} 4970else 4971screen : expect { 4972grid =[[ 4973^example text that is wide| 4974r than the window | 4975{1:some info! } | 4976| 4977more text | 4978{0:~ }|*4 4979| 4980]] , 4981} 4982end 4983 4984api . nvim_win_set_config ( win , { relative ='win' , bufpos ={ 1 , 32 } , row =2 } ) 4985if multigrid then 4986screen : expect { 4987grid =[[ 4988## grid 1 4989[2:-------------------------]|*9 4990[3:-------------------------]| 4991## grid 2 4992^example text that is wide| 4993r than the window | 4994|*2 4995more text | 4996{0:~ }|*4 4997## grid 3 4998| 4999## grid 4 5000{1:some info! }| 5001]] , 5002float_pos ={ [ 4 ] ={ 1001 , 'NW' , 2 , 3 , 7 , true , 50 , 1 , 3 , 7 } } , 5003} 5004else 5005screen : expect { 5006grid =[[ 5007^example text that is wide| 5008r than the window | 5009| 5010{1:some info! } | 5011more text | 5012{0:~ }|*4 5013| 5014]] , 5015} 5016end 5017 5018command ( '%fold' ) 5019if multigrid then 5020screen : expect { 5021grid =[[ 5022## grid 1 5023[2:-------------------------]|*9 5024[3:-------------------------]| 5025## grid 2 5026{28:^+-- 5 lines: just some··}| 5027{0:~ }|*8 5028## grid 3 5029| 5030## grid 4 5031{1:some info! }| 5032]] , 5033float_pos ={ [ 4 ] ={ 1001 , 'NW' , 2 , 2 , 0 , true , 50 , 1 , 2 , 0 } } , 5034} 5035else 5036screen : expect { 5037grid =[[ 5038{28:^+-- 5 lines: just some··}| 5039{0:~ }| 5040{1:some info! }{0: }| 5041{0:~ }|*6 5042| 5043]] , 5044} 5045end 5046end ) 5047 5048it ( 'validates cursor even when window is not entered' , function () 5049screen : try_resize ( 30 , 5 ) 5050command ( 'set nowrap' ) 5051insert ( [[some text that is wider than the window]] ) 5052if multigrid then 5053screen : expect ( [[ 5054## grid 1 5055[2:------------------------------]|*4 5056[3:------------------------------]| 5057## grid 2 5058that is wider than the windo^w | 5059{0:~ }|*3 5060## grid 3 5061| 5062]] ) 5063else 5064screen : expect ( [[ 5065that is wider than the windo^w | 5066{0:~ }|*3 5067| 5068]] ) 5069end 5070 5071local buf =api . nvim_create_buf ( false , true ) 5072api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'some floaty text' } ) 5073api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =1 , row =3 , col =1 } ) 5074if multigrid then 5075screen : expect { 5076grid =[[ 5077## grid 1 5078[2:------------------------------]|*4 5079[3:------------------------------]| 5080## grid 2 5081that is wider than the windo^w | 5082{0:~ }|*3 5083## grid 3 5084| 5085## grid 4 5086{1:some floaty text }| 5087]] , 5088float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 3 , 1 , true , 50 , 1 , 3 , 1 } } , 5089} 5090else 5091screen : expect ( [[ 5092that is wider than the windo^w | 5093{0:~ }|*2 5094{0:~}{1:some floaty text }{0: }| 5095| 5096]] ) 5097end 5098end ) 5099 5100if multigrid then 5101pending ( 'supports second UI without multigrid' , function () 5102local session2 =n . connect ( eval ( 'v:servername' )) 5103( session2 : request ( 'nvim_eval' , '2+2' )) 5104local screen2 =Screen . new ( 40 , 7 ) 5105screen2 : attach ( nil , session2 ) 5106screen2 : set_default_attr_ids ( attrs ) 5107local buf =api . nvim_create_buf ( false , false ) 5108api . nvim_open_win ( buf , true , { relative ='editor' , width =20 , height =2 , row =2 , col =5 } ) 5109local expected_pos ={ [ 2 ] ={ 1001 , 'NW' , 1 , 2 , 5 } } 5110screen : expect { 5111grid =[[ 5112## grid 1 5113| 5114{0:~ }|*5 5115| 5116## grid 2 5117{1:^ }| 5118{2:~ }| 5119]] , 5120float_pos =expected_pos , 5121} 5122screen2 : expect ( [[ 5123| 5124{0:~ }| 5125{0:~ }{1:^ }{0: }| 5126{0:~ }{2:~ }{0: }| 5127{0:~ }|*2 5128| 5129]] ) 5130end ) 5131end 5132 5133it ( 'handles resized screen' , function () 5134local buf =api . nvim_create_buf ( false , false ) 5135api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'such' , 'very' , 'float' } ) 5136local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =15 , height =4 , row =2 , col =10 } ) 5137if multigrid then 5138screen : expect { 5139grid =[[ 5140## grid 1 5141[2:----------------------------------------]|*6 5142[3:----------------------------------------]| 5143## grid 2 5144^ | 5145{0:~ }|*5 5146## grid 3 5147| 5148## grid 4 5149{1:such }| 5150{1:very }| 5151{1:float }| 5152{2:~ }| 5153]] , 5154float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 10 } } , 5155} 5156else 5157screen : expect ( [[ 5158^ | 5159{0:~ }| 5160{0:~ }{1:such }{0: }| 5161{0:~ }{1:very }{0: }| 5162{0:~ }{1:float }{0: }| 5163{0:~ }{2:~ }{0: }| 5164| 5165]] ) 5166end 5167 5168screen : try_resize ( 40 , 5 ) 5169if multigrid then 5170screen : expect { 5171grid =[[ 5172## grid 1 5173[2:----------------------------------------]|*4 5174[3:----------------------------------------]| 5175## grid 2 5176^ | 5177{0:~ }|*3 5178## grid 3 5179| 5180## grid 4 5181{1:such }| 5182{1:very }| 5183{1:float }| 5184{2:~ }| 5185]] , 5186float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 0 , 10 } } , 5187} 5188else 5189screen : expect ( [[ 5190^ {1:such } | 5191{0:~ }{1:very }{0: }| 5192{0:~ }{1:float }{0: }| 5193{0:~ }{2:~ }{0: }| 5194| 5195]] ) 5196end 5197 5198screen : try_resize ( 40 , 4 ) 5199if multigrid then 5200screen : expect { 5201grid =[[ 5202## grid 1 5203[2:----------------------------------------]|*3 5204[3:----------------------------------------]| 5205## grid 2 5206^ | 5207{0:~ }|*2 5208## grid 3 5209| 5210## grid 4 5211{1:such }| 5212{1:very }| 5213{1:float }| 5214{2:~ }| 5215]] , 5216float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 0 , 10 } } , 5217} 5218else 5219screen : expect ( [[ 5220^ {1:such } | 5221{0:~ }{1:very }{0: }| 5222{0:~ }{1:float }{0: }| 5223| 5224]] ) 5225end 5226 5227screen : try_resize ( 40 , 3 ) 5228if multigrid then 5229screen : expect { 5230grid =[[ 5231## grid 1 5232[2:----------------------------------------]|*2 5233[3:----------------------------------------]| 5234## grid 2 5235^ | 5236{0:~ }| 5237## grid 3 5238| 5239## grid 4 5240{1:such }| 5241{1:very }| 5242{1:float }| 5243{2:~ }| 5244]] , 5245float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 0 , 10 } } , 5246} 5247else 5248screen : expect ( [[ 5249^ {1:such } | 5250{0:~ }{1:very }{0: }| 5251| 5252]] ) 5253end 5254feed ( '<c-w>wjj' ) 5255if multigrid then 5256screen : expect { 5257grid =[[ 5258## grid 1 5259[2:----------------------------------------]|*2 5260[3:----------------------------------------]| 5261## grid 2 5262| 5263{0:~ }| 5264## grid 3 5265| 5266## grid 4 5267{1:such }| 5268{1:very }| 5269{1:^float }| 5270{2:~ }| 5271]] , 5272float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 0 , 10 } } , 5273} 5274else 5275screen : expect ( [[ 5276{1:very } | 5277{0:~ }{1:^float }{0: }| 5278| 5279]] ) 5280end 5281 5282screen : try_resize ( 40 , 7 ) 5283if multigrid then 5284screen : expect { 5285grid =[[ 5286## grid 1 5287[2:----------------------------------------]|*6 5288[3:----------------------------------------]| 5289## grid 2 5290| 5291{0:~ }|*5 5292## grid 3 5293| 5294## grid 4 5295{1:such }| 5296{1:very }| 5297{1:^float }| 5298{2:~ }| 5299]] , 5300float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 10 } } , 5301} 5302else 5303screen : expect ( [[ 5304| 5305{0:~ }| 5306{0:~ }{1:such }{0: }| 5307{0:~ }{1:very }{0: }| 5308{0:~ }{1:^float }{0: }| 5309{0:~ }{2:~ }{0: }| 5310| 5311]] ) 5312end 5313 5314api . nvim_win_set_config ( win , { height =3 } ) 5315feed ( 'gg' ) 5316if multigrid then 5317screen : expect { 5318grid =[[ 5319## grid 1 5320[2:----------------------------------------]|*6 5321[3:----------------------------------------]| 5322## grid 2 5323| 5324{0:~ }|*5 5325## grid 3 5326| 5327## grid 4 5328{1:^such }| 5329{1:very }| 5330{1:float }| 5331]] , 5332float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 10 } } , 5333} 5334else 5335screen : expect ( [[ 5336| 5337{0:~ }| 5338{0:~ }{1:^such }{0: }| 5339{0:~ }{1:very }{0: }| 5340{0:~ }{1:float }{0: }| 5341{0:~ }| 5342| 5343]] ) 5344end 5345 5346screen : try_resize ( 26 , 7 ) 5347if multigrid then 5348screen : expect { 5349grid =[[ 5350## grid 1 5351[2:--------------------------]|*6 5352[3:--------------------------]| 5353## grid 2 5354| 5355{0:~ }|*5 5356## grid 3 5357| 5358## grid 4 5359{1:^such }| 5360{1:very }| 5361{1:float }| 5362]] , 5363float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 10 } } , 5364} 5365else 5366screen : expect ( [[ 5367| 5368{0:~ }| 5369{0:~ }{1:^such }{0: }| 5370{0:~ }{1:very }{0: }| 5371{0:~ }{1:float }{0: }| 5372{0:~ }| 5373| 5374]] ) 5375end 5376 5377screen : try_resize ( 25 , 7 ) 5378if multigrid then 5379screen : expect { 5380grid =[[ 5381## grid 1 5382[2:-------------------------]|*6 5383[3:-------------------------]| 5384## grid 2 5385| 5386{0:~ }|*5 5387## grid 3 5388| 5389## grid 4 5390{1:^such }| 5391{1:very }| 5392{1:float }| 5393]] , 5394float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 10 } } , 5395} 5396else 5397screen : expect ( [[ 5398| 5399{0:~ }| 5400{0:~ }{1:^such }| 5401{0:~ }{1:very }| 5402{0:~ }{1:float }| 5403{0:~ }| 5404| 5405]] ) 5406end 5407 5408screen : try_resize ( 24 , 7 ) 5409if multigrid then 5410screen : expect { 5411grid =[[ 5412## grid 1 5413[2:------------------------]|*6 5414[3:------------------------]| 5415## grid 2 5416| 5417{0:~ }|*5 5418## grid 3 5419| 5420## grid 4 5421{1:^such }| 5422{1:very }| 5423{1:float }| 5424]] , 5425float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 9 } } , 5426} 5427else 5428screen : expect ( [[ 5429| 5430{0:~ }| 5431{0:~ }{1:^such }| 5432{0:~ }{1:very }| 5433{0:~ }{1:float }| 5434{0:~ }| 5435| 5436]] ) 5437end 5438 5439screen : try_resize ( 16 , 7 ) 5440if multigrid then 5441screen : expect { 5442grid =[[ 5443## grid 1 5444[2:----------------]|*6 5445[3:----------------]| 5446## grid 2 5447| 5448{0:~ }|*5 5449## grid 3 5450| 5451## grid 4 5452{1:^such }| 5453{1:very }| 5454{1:float }| 5455]] , 5456float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 1 } } , 5457} 5458else 5459screen : expect ( [[ 5460| 5461{0:~ }| 5462{0:~}{1:^such }| 5463{0:~}{1:very }| 5464{0:~}{1:float }| 5465{0:~ }| 5466| 5467]] ) 5468end 5469 5470screen : try_resize ( 15 , 7 ) 5471if multigrid then 5472screen : expect { 5473grid =[[ 5474## grid 1 5475[2:---------------]|*6 5476[3:---------------]| 5477## grid 2 5478| 5479{0:~ }|*5 5480## grid 3 5481| 5482## grid 4 5483{1:^such }| 5484{1:very }| 5485{1:float }| 5486]] , 5487float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 0 } } , 5488} 5489else 5490screen : expect ( [[ 5491| 5492{0:~ }| 5493{1:^such }| 5494{1:very }| 5495{1:float }| 5496{0:~ }| 5497| 5498]] ) 5499end 5500 5501screen : try_resize ( 14 , 7 ) 5502if multigrid then 5503screen : expect { 5504grid =[[ 5505## grid 1 5506[2:--------------]|*6 5507[3:--------------]| 5508## grid 2 5509| 5510{0:~ }|*5 5511## grid 3 5512| 5513## grid 4 5514{1:^such }| 5515{1:very }| 5516{1:float }| 5517]] , 5518float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 0 } } , 5519} 5520else 5521screen : expect ( [[ 5522| 5523{0:~ }| 5524{1:^such }| 5525{1:very }| 5526{1:float }| 5527{0:~ }| 5528| 5529]] ) 5530end 5531 5532screen : try_resize ( 12 , 7 ) 5533if multigrid then 5534screen : expect { 5535grid =[[ 5536## grid 1 5537[2:------------]|*6 5538[3:------------]| 5539## grid 2 5540| 5541{0:~ }|*5 5542## grid 3 5543| 5544## grid 4 5545{1:^such }| 5546{1:very }| 5547{1:float }| 5548]] , 5549float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 0 } } , 5550} 5551else 5552screen : expect ( [[ 5553| 5554{0:~ }| 5555{1:^such }| 5556{1:very }| 5557{1:float }| 5558{0:~ }| 5559| 5560]] ) 5561end 5562 5563-- Doesn't make much sense, but check nvim doesn't crash 5564screen : try_resize ( 1 , 1 ) 5565if multigrid then 5566screen : expect { 5567grid =[[ 5568## grid 1 5569[2:------------]| 5570[3:------------]| 5571## grid 2 5572| 5573## grid 3 5574| 5575## grid 4 5576{1:^such }| 5577{1:very }| 5578{1:float }| 5579]] , 5580float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 0 , 0 } } , 5581} 5582else 5583screen : expect ( [[ 5584{1:^such }| 5585| 5586]] ) 5587end 5588 5589screen : try_resize ( 40 , 7 ) 5590if multigrid then 5591screen : expect { 5592grid =[[ 5593## grid 1 5594[2:----------------------------------------]|*6 5595[3:----------------------------------------]| 5596## grid 2 5597| 5598{0:~ }|*5 5599## grid 3 5600| 5601## grid 4 5602{1:^such }| 5603{1:very }| 5604{1:float }| 5605]] , 5606float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 10 , true , 50 , 1 , 2 , 10 } } , 5607} 5608else 5609screen : expect ( [[ 5610| 5611{0:~ }| 5612{0:~ }{1:^such }{0: }| 5613{0:~ }{1:very }{0: }| 5614{0:~ }{1:float }{0: }| 5615{0:~ }| 5616| 5617]] ) 5618end 5619end ) 5620 5621it ( 'does not crash with inccommand #9379' , function () 5622local expected_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 0 , true , 50 , 1 , 2 , 0 } } 5623command ( 'set inccommand=split' ) 5624command ( 'set laststatus=2' ) 5625local buf =api . nvim_create_buf ( false , false ) 5626api . nvim_open_win ( buf , true , { relative ='editor' , width =30 , height =3 , row =2 , col =0 } ) 5627insert ( [[ 5628foo 5629bar 5630]] ) 5631 5632if multigrid then 5633screen : expect { 5634grid =[[ 5635## grid 1 5636[2:----------------------------------------]|*5 5637{5:[No Name] }| 5638[3:----------------------------------------]| 5639## grid 2 5640| 5641{0:~ }|*4 5642## grid 3 5643| 5644## grid 4 5645{1:foo }| 5646{1:bar }| 5647{1:^ }| 5648]] , 5649float_pos =expected_pos , 5650} 5651else 5652screen : expect ( [[ 5653| 5654{0:~ }| 5655{1:foo }{0: }| 5656{1:bar }{0: }| 5657{1:^ }{0: }| 5658{5:[No Name] }| 5659| 5660]] ) 5661end 5662 5663feed ( ':%s/.' ) 5664if multigrid then 5665screen : expect { 5666grid =[[ 5667## grid 1 5668[2:----------------------------------------]|*5 5669{5:[Preview] }| 5670[3:----------------------------------------]| 5671## grid 2 5672| 5673## grid 3 5674:%s/.^ | 5675## grid 4 5676{17:f}{1:oo }| 5677{17:b}{1:ar }| 5678{1: }| 5679]] , 5680float_pos =expected_pos , 5681} 5682else 5683screen : expect ( [[ 5684| 5685{5:[No Name] }| 5686{17:f}{1:oo } | 5687{17:b}{1:ar } | 5688{1: }{0: }| 5689{5:[Preview] }| 5690:%s/.^ | 5691]] ) 5692end 5693 5694feed ( '<Esc>' ) 5695 5696if multigrid then 5697screen : expect { 5698grid =[[ 5699## grid 1 5700[2:----------------------------------------]|*5 5701{5:[No Name] }| 5702[3:----------------------------------------]| 5703## grid 2 5704| 5705{0:~ }|*4 5706## grid 3 5707| 5708## grid 4 5709{1:foo }| 5710{1:bar }| 5711{1:^ }| 5712]] , 5713float_pos =expected_pos , 5714} 5715else 5716screen : expect ( [[ 5717| 5718{0:~ }| 5719{1:foo }{0: }| 5720{1:bar }{0: }| 5721{1:^ }{0: }| 5722{5:[No Name] }| 5723| 5724]] ) 5725end 5726end ) 5727 5728it ( 'does not crash when set cmdheight #9680' , function () 5729local buf =api . nvim_create_buf ( false , false ) 5730api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =2 , row =2 , col =5 } ) 5731command ( 'set cmdheight=2' ) 5732eq ( 1 , api . nvim_eval ( '1' )) 5733end ) 5734 5735describe ( 'and completion' , function () 5736before_each ( function () 5737local buf =api . nvim_create_buf ( false , false ) 5738local win =api . nvim_open_win ( buf , true , { relative ='editor' , width =12 , height =4 , row =2 , col =5 } ) 5739api . nvim_set_option_value ( 'winhl' , 'Normal:ErrorMsg' , { win =win } ) 5740if multigrid then 5741screen : expect { 5742grid =[[ 5743## grid 1 5744[2:----------------------------------------]|*6 5745[3:----------------------------------------]| 5746## grid 2 5747| 5748{0:~ }|*5 5749## grid 3 5750| 5751## grid 4 5752{7:^ }| 5753{12:~ }|*3 5754]] , 5755float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 5756} 5757else 5758screen : expect ( [[ 5759| 5760{0:~ }| 5761{0:~ }{7:^ }{0: }| 5762{0:~ }{12:~ }{0: }|*3 5763| 5764]] ) 5765end 5766end ) 5767 5768it ( 'with builtin popupmenu' , function () 5769feed ( 'ix ' ) 5770fn . complete ( 3 , { 'aa' , 'word' , 'longtext' } ) 5771if multigrid then 5772screen : expect { 5773grid =[[ 5774## grid 1 5775[2:----------------------------------------]|*6 5776[3:----------------------------------------]| 5777## grid 2 5778| 5779{0:~ }|*5 5780## grid 3 5781{3:-- INSERT --} | 5782## grid 4 5783{7:x aa^ }| 5784{12:~ }|*3 5785## grid 5 5786{13: aa }| 5787{1: word }| 5788{1: longtext }| 5789]] , 5790float_pos ={ 5791[ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } , 5792[ 5 ] ={ - 1 , 'NW' , 4 , 1 , 1 , false , 100 , 2 , 3 , 6 } , 5793} , 5794} 5795else 5796screen : expect ( [[ 5797| 5798{0:~ }| 5799{0:~ }{7:x aa^ }{0: }| 5800{0:~ }{12:~}{13: aa }{0: }| 5801{0:~ }{12:~}{1: word }{0: }| 5802{0:~ }{12:~}{1: longtext }{0: }| 5803{3:-- INSERT --} | 5804]] ) 5805end 5806 5807feed ( '<esc>' ) 5808if multigrid then 5809screen : expect { 5810grid =[[ 5811## grid 1 5812[2:----------------------------------------]|*6 5813[3:----------------------------------------]| 5814## grid 2 5815| 5816{0:~ }|*5 5817## grid 3 5818| 5819## grid 4 5820{7:x a^a }| 5821{12:~ }|*3 5822]] , 5823float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 5824} 5825else 5826screen : expect ( [[ 5827| 5828{0:~ }| 5829{0:~ }{7:x a^a }{0: }| 5830{0:~ }{12:~ }{0: }|*3 5831| 5832]] ) 5833end 5834 5835feed ( '<c-w>wi' ) 5836fn . complete ( 1 , { 'xx' , 'yy' , 'zz' } ) 5837if multigrid then 5838screen : expect { 5839grid =[[ 5840## grid 1 5841[2:----------------------------------------]|*6 5842[3:----------------------------------------]| 5843## grid 2 5844xx^ | 5845{0:~ }|*5 5846## grid 3 5847{3:-- INSERT --} | 5848## grid 4 5849{7:x aa }| 5850{12:~ }|*3 5851## grid 5 5852{13:xx }| 5853{1:yy }| 5854{1:zz }| 5855]] , 5856float_pos ={ 5857[ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } , 5858[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 2 , 1 , 0 } , 5859} , 5860} 5861else 5862screen : expect ( [[ 5863xx^ | 5864{13:xx }{0: }| 5865{1:yy }{7: }{0: }| 5866{1:zz }{12: }{0: }| 5867{0:~ }{12:~ }{0: }|*2 5868{3:-- INSERT --} | 5869]] ) 5870end 5871 5872feed ( '<c-y>' ) 5873if multigrid then 5874screen : expect { 5875grid =[[ 5876## grid 1 5877[2:----------------------------------------]|*6 5878[3:----------------------------------------]| 5879## grid 2 5880xx^ | 5881{0:~ }|*5 5882## grid 3 5883{3:-- INSERT --} | 5884## grid 4 5885{7:x aa }| 5886{12:~ }|*3 5887]] , 5888float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 5889} 5890else 5891screen : expect ( [[ 5892xx^ | 5893{0:~ }| 5894{0:~ }{7:x aa }{0: }| 5895{0:~ }{12:~ }{0: }|*3 5896{3:-- INSERT --} | 5897]] ) 5898end 5899end ) 5900 5901it ( 'command menu rendered above cursor (pum_above)' , function () 5902command ( 'set wildmenu wildmode=longest:full wildoptions=pum' ) 5903feed ( ':sign u<tab>' ) 5904if multigrid then 5905screen : expect { 5906grid =[[ 5907## grid 1 5908[2:----------------------------------------]|*6 5909[3:----------------------------------------]| 5910## grid 2 5911| 5912{0:~ }|*5 5913## grid 3 5914:sign un^ | 5915## grid 4 5916{7: }| 5917{12:~ }|*3 5918## grid 5 5919{1: undefine }| 5920{1: unplace }| 5921]] , 5922float_pos ={ 5923[ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } , 5924[ 5 ] ={ - 1 , 'SW' , 1 , 6 , 5 , false , 250 , 3 , 4 , 5 } , 5925} , 5926} 5927else 5928screen : expect { 5929grid =[[ 5930| 5931{0:~ }| 5932{0:~ }{7: }{0: }| 5933{0:~ }{12:~ }{0: }| 5934{0:~ }{1: undefine }{0: }| 5935{0:~ }{1: unplace }{0: }| 5936:sign un^ | 5937]] , 5938} 5939end 5940end ) 5941 5942it ( 'with ext_popupmenu' , function () 5943screen : set_option ( 'ext_popupmenu' , true ) 5944feed ( 'ix ' ) 5945fn . complete ( 3 , { 'aa' , 'word' , 'longtext' } ) 5946local items ={ { 'aa' , '' , '' , '' } , { 'word' , '' , '' , '' } , { 'longtext' , '' , '' , '' } } 5947if multigrid then 5948screen : expect { 5949grid =[[ 5950## grid 1 5951[2:----------------------------------------]|*6 5952[3:----------------------------------------]| 5953## grid 2 5954| 5955{0:~ }|*5 5956## grid 3 5957{3:-- INSERT --} | 5958## grid 4 5959{7:x aa^ }| 5960{12:~ }|*3 5961]] , 5962float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 5963popupmenu ={ anchor ={ 4 , 0 , 2 } , items =items , pos =0 } , 5964} 5965else 5966screen : expect { 5967grid =[[ 5968| 5969{0:~ }| 5970{0:~ }{7:x aa^ }{0: }| 5971{0:~ }{12:~ }{0: }|*3 5972{3:-- INSERT --} | 5973]] , 5974popupmenu ={ anchor ={ 1 , 2 , 7 } , items =items , pos =0 } , 5975} 5976end 5977 5978feed ( '<esc>' ) 5979if multigrid then 5980screen : expect { 5981grid =[[ 5982## grid 1 5983[2:----------------------------------------]|*6 5984[3:----------------------------------------]| 5985## grid 2 5986| 5987{0:~ }|*5 5988## grid 3 5989| 5990## grid 4 5991{7:x a^a }| 5992{12:~ }|*3 5993]] , 5994float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 5995} 5996else 5997screen : expect ( [[ 5998| 5999{0:~ }| 6000{0:~ }{7:x a^a }{0: }| 6001{0:~ }{12:~ }{0: }|*3 6002| 6003]] ) 6004end 6005 6006feed ( '<c-w>wi' ) 6007fn . complete ( 1 , { 'xx' , 'yy' , 'zz' } ) 6008items ={ { 'xx' , '' , '' , '' } , { 'yy' , '' , '' , '' } , { 'zz' , '' , '' , '' } } 6009if multigrid then 6010screen : expect { 6011grid =[[ 6012## grid 1 6013[2:----------------------------------------]|*6 6014[3:----------------------------------------]| 6015## grid 2 6016xx^ | 6017{0:~ }|*5 6018## grid 3 6019{3:-- INSERT --} | 6020## grid 4 6021{7:x aa }| 6022{12:~ }|*3 6023]] , 6024float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 6025popupmenu ={ anchor ={ 2 , 0 , 0 } , items =items , pos =0 } , 6026} 6027else 6028screen : expect { 6029grid =[[ 6030xx^ | 6031{0:~ }| 6032{0:~ }{7:x aa }{0: }| 6033{0:~ }{12:~ }{0: }|*3 6034{3:-- INSERT --} | 6035]] , 6036popupmenu ={ anchor ={ 1 , 0 , 0 } , items =items , pos =0 } , 6037} 6038end 6039 6040feed ( '<c-y>' ) 6041if multigrid then 6042screen : expect { 6043grid =[[ 6044## grid 1 6045[2:----------------------------------------]|*6 6046[3:----------------------------------------]| 6047## grid 2 6048xx^ | 6049{0:~ }|*5 6050## grid 3 6051{3:-- INSERT --} | 6052## grid 4 6053{7:x aa }| 6054{12:~ }|*3 6055]] , 6056float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 6057} 6058else 6059screen : expect ( [[ 6060xx^ | 6061{0:~ }| 6062{0:~ }{7:x aa }{0: }| 6063{0:~ }{12:~ }{0: }|*3 6064{3:-- INSERT --} | 6065]] ) 6066end 6067end ) 6068end ) 6069 6070describe ( 'float shown after pum' , function () 6071local win 6072before_each ( function () 6073command ( 'hi NormalFloat guibg=#333333 guifg=NONE' ) 6074feed ( 'i' ) 6075fn . complete ( 1 , { 'aa' , 'word' , 'longtext' } ) 6076if multigrid then 6077screen : expect { 6078grid =[[ 6079## grid 1 6080[2:----------------------------------------]|*6 6081[3:----------------------------------------]| 6082## grid 2 6083aa^ | 6084{0:~ }|*5 6085## grid 3 6086{3:-- INSERT --} | 6087## grid 4 6088{13:aa }| 6089{1:word }| 6090{1:longtext }| 6091]] , 6092float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6093} 6094else 6095screen : expect ( [[ 6096aa^ | 6097{13:aa }{0: }| 6098{1:word }{0: }| 6099{1:longtext }{0: }| 6100{0:~ }|*2 6101{3:-- INSERT --} | 6102]] ) 6103end 6104 6105local buf =api . nvim_create_buf ( false , true ) 6106api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'some info' , 'about item' } ) 6107win =api . nvim_open_win ( buf , false , { relative ='cursor' , width =12 , height =2 , row =1 , col =10 } ) 6108if multigrid then 6109screen : expect { 6110grid =[[ 6111## grid 1 6112[2:----------------------------------------]|*6 6113[3:----------------------------------------]| 6114## grid 2 6115aa^ | 6116{0:~ }|*5 6117## grid 3 6118{3:-- INSERT --} | 6119## grid 4 6120{13:aa }| 6121{1:word }| 6122{1:longtext }| 6123## grid 5 6124{15:some info }| 6125{15:about item }| 6126]] , 6127float_pos ={ 6128[ 5 ] ={ 1001 , 'NW' , 2 , 1 , 12 , true , 50 , 1 , 1 , 12 } , 6129[ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 2 , 1 , 0 } , 6130} , 6131} 6132else 6133screen : expect ( [[ 6134aa^ | 6135{13:aa }{15:e info }{0: }| 6136{1:word }{15:ut item }{0: }| 6137{1:longtext }{0: }| 6138{0:~ }|*2 6139{3:-- INSERT --} | 6140]] ) 6141end 6142end ) 6143 6144it ( 'and close pum first' , function () 6145feed ( '<c-y>' ) 6146if multigrid then 6147screen : expect { 6148grid =[[ 6149## grid 1 6150[2:----------------------------------------]|*6 6151[3:----------------------------------------]| 6152## grid 2 6153aa^ | 6154{0:~ }|*5 6155## grid 3 6156{3:-- INSERT --} | 6157## grid 5 6158{15:some info }| 6159{15:about item }| 6160]] , 6161float_pos ={ [ 5 ] ={ 1001 , 'NW' , 2 , 1 , 12 , true , 50 , 1 , 1 , 12 } } , 6162} 6163else 6164screen : expect ( [[ 6165aa^ | 6166{0:~ }{15:some info }{0: }| 6167{0:~ }{15:about item }{0: }| 6168{0:~ }|*3 6169{3:-- INSERT --} | 6170]] ) 6171end 6172 6173api . nvim_win_close ( win , false ) 6174if multigrid then 6175screen : expect ( [[ 6176## grid 1 6177[2:----------------------------------------]|*6 6178[3:----------------------------------------]| 6179## grid 2 6180aa^ | 6181{0:~ }|*5 6182## grid 3 6183{3:-- INSERT --} | 6184]] ) 6185else 6186screen : expect ( [[ 6187aa^ | 6188{0:~ }|*5 6189{3:-- INSERT --} | 6190]] ) 6191end 6192end ) 6193 6194it ( 'and close float first' , function () 6195api . nvim_win_close ( win , false ) 6196if multigrid then 6197screen : expect { 6198grid =[[ 6199## grid 1 6200[2:----------------------------------------]|*6 6201[3:----------------------------------------]| 6202## grid 2 6203aa^ | 6204{0:~ }|*5 6205## grid 3 6206{3:-- INSERT --} | 6207## grid 4 6208{13:aa }| 6209{1:word }| 6210{1:longtext }| 6211]] , 6212float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6213} 6214else 6215screen : expect ( [[ 6216aa^ | 6217{13:aa }{0: }| 6218{1:word }{0: }| 6219{1:longtext }{0: }| 6220{0:~ }|*2 6221{3:-- INSERT --} | 6222]] ) 6223end 6224 6225feed ( '<c-y>' ) 6226if multigrid then 6227screen : expect ( [[ 6228## grid 1 6229[2:----------------------------------------]|*6 6230[3:----------------------------------------]| 6231## grid 2 6232aa^ | 6233{0:~ }|*5 6234## grid 3 6235{3:-- INSERT --} | 6236]] ) 6237else 6238screen : expect ( [[ 6239aa^ | 6240{0:~ }|*5 6241{3:-- INSERT --} | 6242]] ) 6243end 6244end ) 6245end ) 6246 6247it ( 'can use Normal as background' , function () 6248local buf =api . nvim_create_buf ( false , false ) 6249api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'here' , 'float' } ) 6250local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =2 , row =2 , col =5 } ) 6251api . nvim_set_option_value ( 'winhl' , 'Normal:Normal' , { win =win } ) 6252 6253if multigrid then 6254screen : expect { 6255grid =[[ 6256## grid 1 6257[2:----------------------------------------]|*6 6258[3:----------------------------------------]| 6259## grid 2 6260^ | 6261{0:~ }|*5 6262## grid 3 6263| 6264## grid 4 6265here | 6266float | 6267]] , 6268float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 6269win_viewport ={ 6270[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 6271[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 6272} , 6273} 6274else 6275screen : expect { 6276grid =[[ 6277^ | 6278{0:~ }| 6279{0:~ }here {0: }| 6280{0:~ }float {0: }| 6281{0:~ }|*2 6282| 6283]] , 6284} 6285end 6286end ) 6287 6288describe ( 'handles :wincmd' , function () 6289local win 6290local expected_pos 6291before_each ( function () 6292-- the default, but be explicit: 6293command ( 'set laststatus=1' ) 6294command ( 'set hidden' ) 6295api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'x' } ) 6296local buf =api . nvim_create_buf ( false , false ) 6297win =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =2 , row =2 , col =5 } ) 6298api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'y' } ) 6299expected_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } 6300if multigrid then 6301screen : expect { 6302grid =[[ 6303## grid 1 6304[2:----------------------------------------]|*6 6305[3:----------------------------------------]| 6306## grid 2 6307^x | 6308{0:~ }|*5 6309## grid 3 6310| 6311## grid 4 6312{1:y }| 6313{2:~ }| 6314]] , 6315float_pos =expected_pos , 6316} 6317else 6318screen : expect ( [[ 6319^x | 6320{0:~ }| 6321{0:~ }{1:y }{0: }| 6322{0:~ }{2:~ }{0: }| 6323{0:~ }|*2 6324| 6325]] ) 6326end 6327end ) 6328 6329it ( 'w' , function () 6330feed ( '<c-w>w' ) 6331if multigrid then 6332screen : expect { 6333grid =[[ 6334## grid 1 6335[2:----------------------------------------]|*6 6336[3:----------------------------------------]| 6337## grid 2 6338x | 6339{0:~ }|*5 6340## grid 3 6341| 6342## grid 4 6343{1:^y }| 6344{2:~ }| 6345]] , 6346float_pos =expected_pos , 6347} 6348else 6349screen : expect ( [[ 6350x | 6351{0:~ }| 6352{0:~ }{1:^y }{0: }| 6353{0:~ }{2:~ }{0: }| 6354{0:~ }|*2 6355| 6356]] ) 6357end 6358 6359feed ( '<c-w>w' ) 6360if multigrid then 6361screen : expect { 6362grid =[[ 6363## grid 1 6364[2:----------------------------------------]|*6 6365[3:----------------------------------------]| 6366## grid 2 6367^x | 6368{0:~ }|*5 6369## grid 3 6370| 6371## grid 4 6372{1:y }| 6373{2:~ }| 6374]] , 6375float_pos =expected_pos , 6376} 6377else 6378screen : expect ( [[ 6379^x | 6380{0:~ }| 6381{0:~ }{1:y }{0: }| 6382{0:~ }{2:~ }{0: }| 6383{0:~ }|*2 6384| 6385]] ) 6386end 6387end ) 6388 6389it ( 'w with focusable=false' , function () 6390api . nvim_win_set_config ( win , { focusable =false } ) 6391expected_pos [ 4 ][ 6 ] =false 6392feed ( '<c-w>wi' ) -- i to provoke redraw 6393if multigrid then 6394screen : expect { 6395grid =[[ 6396## grid 1 6397[2:----------------------------------------]|*6 6398[3:----------------------------------------]| 6399## grid 2 6400^x | 6401{0:~ }|*5 6402## grid 3 6403{3:-- INSERT --} | 6404## grid 4 6405{1:y }| 6406{2:~ }| 6407]] , 6408float_pos =expected_pos , 6409} 6410else 6411screen : expect ( [[ 6412^x | 6413{0:~ }| 6414{0:~ }{1:y }{0: }| 6415{0:~ }{2:~ }{0: }| 6416{0:~ }|*2 6417{3:-- INSERT --} | 6418]] ) 6419end 6420 6421feed ( '<esc><c-w>w' ) 6422if multigrid then 6423screen : expect { 6424grid =[[ 6425## grid 1 6426[2:----------------------------------------]|*6 6427[3:----------------------------------------]| 6428## grid 2 6429^x | 6430{0:~ }|*5 6431## grid 3 6432| 6433## grid 4 6434{1:y }| 6435{2:~ }| 6436]] , 6437float_pos =expected_pos , 6438} 6439else 6440screen : expect ( [[ 6441^x | 6442{0:~ }| 6443{0:~ }{1:y }{0: }| 6444{0:~ }{2:~ }{0: }| 6445{0:~ }|*2 6446| 6447]] ) 6448end 6449 6450api . nvim_open_win ( 0 , false , { relative ='editor' , width =1 , height =1 , row =0 , col =0 } ) 6451api . nvim_open_win ( 0 , false , { relative ='editor' , width =1 , height =1 , row =0 , col =0 , focusable =false } ) 6452api . nvim_open_win ( 0 , false , { relative ='editor' , width =1 , height =1 , row =0 , col =0 , focusable =false } ) 6453api . nvim_open_win ( 0 , false , { relative ='editor' , width =1 , height =1 , row =0 , col =0 , focusable =true } ) 6454api . nvim_open_win ( 0 , false , { relative ='editor' , width =1 , height =1 , row =0 , col =0 , focusable =false } ) 6455local nr_focusable ={} 6456for _ , winid in ipairs ( api . nvim_tabpage_list_wins ( 0 )) do 6457table . insert ( nr_focusable , api . nvim_win_get_config ( winid ). focusable ) 6458end 6459eq ( { true , false , true , false , false , true , false } , nr_focusable ) 6460 6461command ( '1wincmd w' ) 6462eq ( { 1 , 1000 } , { fn . winnr (), fn . win_getid () } ) 6463command ( '2wincmd w' ) 6464eq ( { 2 , 1005 } , { fn . winnr (), fn . win_getid () } ) 6465command ( '3wincmd w' ) 6466eq ( { 2 , 1005 } , { fn . winnr (), fn . win_getid () } ) 6467command ( '4wincmd w' ) 6468eq ( { 3 , 1002 } , { fn . winnr (), fn . win_getid () } ) 6469command ( '5wincmd w' ) 6470eq ( { 3 , 1002 } , { fn . winnr (), fn . win_getid () } ) 6471command ( '6wincmd w' ) 6472eq ( { 3 , 1002 } , { fn . winnr (), fn . win_getid () } ) 6473command ( '7wincmd w' ) 6474eq ( { 3 , 1002 } , { fn . winnr (), fn . win_getid () } ) 6475 6476feed ( '1<c-w>w' ) 6477eq ( { 1 , 1000 } , { fn . winnr (), fn . win_getid () } ) 6478feed ( '2<c-w>w' ) 6479eq ( { 2 , 1005 } , { fn . winnr (), fn . win_getid () } ) 6480feed ( '999<c-w>w' ) 6481eq ( { 3 , 1002 } , { fn . winnr (), fn . win_getid () } ) 6482end ) 6483 6484it ( 'W' , function () 6485feed ( '<c-w>W' ) 6486if multigrid then 6487screen : expect { 6488grid =[[ 6489## grid 1 6490[2:----------------------------------------]|*6 6491[3:----------------------------------------]| 6492## grid 2 6493x | 6494{0:~ }|*5 6495## grid 3 6496| 6497## grid 4 6498{1:^y }| 6499{2:~ }| 6500]] , 6501float_pos =expected_pos , 6502} 6503else 6504screen : expect ( [[ 6505x | 6506{0:~ }| 6507{0:~ }{1:^y }{0: }| 6508{0:~ }{2:~ }{0: }| 6509{0:~ }|*2 6510| 6511]] ) 6512end 6513 6514feed ( '<c-w>W' ) 6515if multigrid then 6516screen : expect { 6517grid =[[ 6518## grid 1 6519[2:----------------------------------------]|*6 6520[3:----------------------------------------]| 6521## grid 2 6522^x | 6523{0:~ }|*5 6524## grid 3 6525| 6526## grid 4 6527{1:y }| 6528{2:~ }| 6529]] , 6530float_pos =expected_pos , 6531} 6532else 6533screen : expect ( [[ 6534^x | 6535{0:~ }| 6536{0:~ }{1:y }{0: }| 6537{0:~ }{2:~ }{0: }| 6538{0:~ }|*2 6539| 6540]] ) 6541end 6542end ) 6543 6544local function test_float_mouse_focus () 6545if send_mouse_grid then 6546api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 0 , 0 ) 6547else 6548api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 5 ) 6549end 6550if multigrid then 6551screen : expect { 6552grid =[[ 6553## grid 1 6554[2:----------------------------------------]|*6 6555[3:----------------------------------------]| 6556## grid 2 6557x | 6558{0:~ }|*5 6559## grid 3 6560| 6561## grid 4 6562{1:^y }| 6563{2:~ }| 6564]] , 6565float_pos =expected_pos , 6566} 6567else 6568screen : expect ( [[ 6569x | 6570{0:~ }| 6571{0:~ }{1:^y }{0: }| 6572{0:~ }{2:~ }{0: }| 6573{0:~ }|*2 6574| 6575]] ) 6576end 6577 6578if send_mouse_grid then 6579api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 0 , 0 ) 6580else 6581api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 0 , 0 ) 6582end 6583if multigrid then 6584screen : expect { 6585grid =[[ 6586## grid 1 6587[2:----------------------------------------]|*6 6588[3:----------------------------------------]| 6589## grid 2 6590^x | 6591{0:~ }|*5 6592## grid 3 6593| 6594## grid 4 6595{1:y }| 6596{2:~ }| 6597]] , 6598float_pos =expected_pos , 6599} 6600else 6601screen : expect ( [[ 6602^x | 6603{0:~ }| 6604{0:~ }{1:y }{0: }| 6605{0:~ }{2:~ }{0: }| 6606{0:~ }|*2 6607| 6608]] ) 6609end 6610end 6611 6612it ( 'focus by mouse (focusable=true)' , function () 6613test_float_mouse_focus () 6614end ) 6615 6616it ( 'focus by mouse (focusable=false, mouse=true)' , function () 6617api . nvim_win_set_config ( win , { focusable =false , mouse =true } ) 6618test_float_mouse_focus () 6619end ) 6620 6621local function test_float_mouse_no_focus () 6622api . nvim_buf_set_lines ( 0 , - 1 , - 1 , true , { 'a' } ) 6623expected_pos [ 4 ][ 6 ] =false 6624if send_mouse_grid then 6625api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 0 , 0 ) 6626else 6627api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 5 ) 6628end 6629if multigrid then 6630if send_mouse_grid then 6631-- Sending input to grid 4 is a user error, you are not supposed to pass a grid 6632-- that isn't focusable. In this case, nothing happens and the input is not passed 6633-- through to grid 4, like normally happens when you pass grid 0. 6634screen : expect { 6635grid =[[ 6636## grid 1 6637[2:----------------------------------------]|*6 6638[3:----------------------------------------]| 6639## grid 2 6640^x | 6641a | 6642{0:~ }|*4 6643## grid 3 6644| 6645## grid 4 6646{1:y }| 6647{2:~ }| 6648]] , 6649float_pos =expected_pos , 6650} 6651else 6652screen : expect { 6653grid =[[ 6654## grid 1 6655[2:----------------------------------------]|*6 6656[3:----------------------------------------]| 6657## grid 2 6658x | 6659^a | 6660{0:~ }|*4 6661## grid 3 6662| 6663## grid 4 6664{1:y }| 6665{2:~ }| 6666]] , 6667float_pos =expected_pos , 6668} 6669end 6670else 6671screen : expect ( [[ 6672x | 6673^a | 6674{0:~ }{1:y }{0: }| 6675{0:~ }{2:~ }{0: }| 6676{0:~ }|*2 6677| 6678]] ) 6679end 6680 6681if send_mouse_grid then 6682api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 0 , 0 ) 6683else 6684api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 0 , 0 ) 6685end 6686if multigrid then 6687screen : expect { 6688grid =[[ 6689## grid 1 6690[2:----------------------------------------]|*6 6691[3:----------------------------------------]| 6692## grid 2 6693^x | 6694a | 6695{0:~ }|*4 6696## grid 3 6697| 6698## grid 4 6699{1:y }| 6700{2:~ }| 6701]] , 6702float_pos =expected_pos , 6703unchanged =true , 6704} 6705else 6706screen : expect ( [[ 6707^x | 6708a | 6709{0:~ }{1:y }{0: }| 6710{0:~ }{2:~ }{0: }| 6711{0:~ }|*2 6712| 6713]] ) 6714end 6715end 6716 6717it ( 'focus by mouse (focusable=false)' , function () 6718api . nvim_win_set_config ( win , { focusable =false } ) 6719test_float_mouse_no_focus () 6720end ) 6721 6722it ( 'focus by mouse (focusable=true, mouse=false)' , function () 6723api . nvim_win_set_config ( win , { mouse =false } ) 6724test_float_mouse_no_focus () 6725end ) 6726 6727it ( ':help (focusable=false, hide=true)' , function () 6728n . add_builddir_to_rtp () 6729local w =curwin () 6730for _ , helpcmd in ipairs ( { 6731'help' , 6732'helpgrep api-types' , 6733'lhelpgrep api-types' , 6734} ) do 6735command ( helpcmd ) 6736local badwins ={ 6737api . nvim_open_win ( 0 , false , { focusable =false , relative ='editor' , width =1 , height =1 , row =0 , col =0 } ), 6738api . nvim_open_win ( 0 , false , { hide =true , relative ='editor' , width =1 , height =1 , row =0 , col =0 } ), 6739} 6740command ( 'helpclose' ) 6741command ( helpcmd ) 6742eq ( false , tbl_contains ( badwins , curwin ())) 6743command ( 'helpclose' ) 6744eq ( w , curwin ()) 6745end 6746end ) 6747 6748it ( 'j' , function () 6749feed ( '<c-w>ji' ) -- INSERT to trigger screen change 6750if multigrid then 6751screen : expect { 6752grid =[[ 6753## grid 1 6754[2:----------------------------------------]|*6 6755[3:----------------------------------------]| 6756## grid 2 6757^x | 6758{0:~ }|*5 6759## grid 3 6760{3:-- INSERT --} | 6761## grid 4 6762{1:y }| 6763{2:~ }| 6764]] , 6765float_pos =expected_pos , 6766} 6767else 6768screen : expect ( [[ 6769^x | 6770{0:~ }| 6771{0:~ }{1:y }{0: }| 6772{0:~ }{2:~ }{0: }| 6773{0:~ }|*2 6774{3:-- INSERT --} | 6775]] ) 6776end 6777 6778feed ( '<esc><c-w>w' ) 6779if multigrid then 6780screen : expect { 6781grid =[[ 6782## grid 1 6783[2:----------------------------------------]|*6 6784[3:----------------------------------------]| 6785## grid 2 6786x | 6787{0:~ }|*5 6788## grid 3 6789| 6790## grid 4 6791{1:^y }| 6792{2:~ }| 6793]] , 6794float_pos =expected_pos , 6795} 6796else 6797screen : expect ( [[ 6798x | 6799{0:~ }| 6800{0:~ }{1:^y }{0: }| 6801{0:~ }{2:~ }{0: }| 6802{0:~ }|*2 6803| 6804]] ) 6805end 6806 6807feed ( '<c-w>j' ) 6808if multigrid then 6809screen : expect { 6810grid =[[ 6811## grid 1 6812[2:----------------------------------------]|*6 6813[3:----------------------------------------]| 6814## grid 2 6815^x | 6816{0:~ }|*5 6817## grid 3 6818| 6819## grid 4 6820{1:y }| 6821{2:~ }| 6822]] , 6823float_pos =expected_pos , 6824} 6825else 6826screen : expect ( [[ 6827^x | 6828{0:~ }| 6829{0:~ }{1:y }{0: }| 6830{0:~ }{2:~ }{0: }| 6831{0:~ }|*2 6832| 6833]] ) 6834end 6835end ) 6836 6837it ( 'vertical resize + - _' , function () 6838feed ( '<c-w>w' ) 6839if multigrid then 6840screen : expect { 6841grid =[[ 6842## grid 1 6843[2:----------------------------------------]|*6 6844[3:----------------------------------------]| 6845## grid 2 6846x | 6847{0:~ }|*5 6848## grid 3 6849| 6850## grid 4 6851{1:^y }| 6852{2:~ }| 6853]] , 6854float_pos =expected_pos , 6855} 6856else 6857screen : expect ( [[ 6858x | 6859{0:~ }| 6860{0:~ }{1:^y }{0: }| 6861{0:~ }{2:~ }{0: }| 6862{0:~ }|*2 6863| 6864]] ) 6865end 6866 6867feed ( '<c-w>+' ) 6868if multigrid then 6869screen : expect { 6870grid =[[ 6871## grid 1 6872[2:----------------------------------------]|*6 6873[3:----------------------------------------]| 6874## grid 2 6875x | 6876{0:~ }|*5 6877## grid 3 6878| 6879## grid 4 6880{1:^y }| 6881{2:~ }|*2 6882]] , 6883float_pos =expected_pos , 6884} 6885else 6886screen : expect ( [[ 6887x | 6888{0:~ }| 6889{0:~ }{1:^y }{0: }| 6890{0:~ }{2:~ }{0: }|*2 6891{0:~ }| 6892| 6893]] ) 6894end 6895 6896feed ( '<c-w>2-' ) 6897if multigrid then 6898screen : expect { 6899grid =[[ 6900## grid 1 6901[2:----------------------------------------]|*6 6902[3:----------------------------------------]| 6903## grid 2 6904x | 6905{0:~ }|*5 6906## grid 3 6907| 6908## grid 4 6909{1:^y }| 6910]] , 6911float_pos =expected_pos , 6912} 6913else 6914screen : expect ( [[ 6915x | 6916{0:~ }| 6917{0:~ }{1:^y }{0: }| 6918{0:~ }|*3 6919| 6920]] ) 6921end 6922 6923feed ( '<c-w>4_' ) 6924if multigrid then 6925screen : expect { 6926grid =[[ 6927## grid 1 6928[2:----------------------------------------]|*6 6929[3:----------------------------------------]| 6930## grid 2 6931x | 6932{0:~ }|*5 6933## grid 3 6934| 6935## grid 4 6936{1:^y }| 6937{2:~ }|*3 6938]] , 6939float_pos =expected_pos , 6940} 6941else 6942screen : expect ( [[ 6943x | 6944{0:~ }| 6945{0:~ }{1:^y }{0: }| 6946{0:~ }{2:~ }{0: }|*3 6947| 6948]] ) 6949end 6950 6951feed ( '<c-w>_' ) 6952if multigrid then 6953screen : expect { 6954grid =[[ 6955## grid 1 6956[2:----------------------------------------]|*6 6957[3:----------------------------------------]| 6958## grid 2 6959x | 6960{0:~ }|*5 6961## grid 3 6962| 6963## grid 4 6964{1:^y }| 6965{2:~ }|*5 6966]] , 6967float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 0 , 5 } } , 6968} 6969else 6970screen : expect ( [[ 6971x {1:^y } | 6972{0:~ }{2:~ }{0: }|*5 6973| 6974]] ) 6975end 6976end ) 6977 6978it ( 'horizontal resize > < |' , function () 6979feed ( '<c-w>w' ) 6980if multigrid then 6981screen : expect { 6982grid =[[ 6983## grid 1 6984[2:----------------------------------------]|*6 6985[3:----------------------------------------]| 6986## grid 2 6987x | 6988{0:~ }|*5 6989## grid 3 6990| 6991## grid 4 6992{1:^y }| 6993{2:~ }| 6994]] , 6995float_pos =expected_pos , 6996} 6997else 6998screen : expect ( [[ 6999x | 7000{0:~ }| 7001{0:~ }{1:^y }{0: }| 7002{0:~ }{2:~ }{0: }| 7003{0:~ }|*2 7004| 7005]] ) 7006end 7007 7008feed ( '<c-w>>' ) 7009if multigrid then 7010screen : expect { 7011grid =[[ 7012## grid 1 7013[2:----------------------------------------]|*6 7014[3:----------------------------------------]| 7015## grid 2 7016x | 7017{0:~ }|*5 7018## grid 3 7019| 7020## grid 4 7021{1:^y }| 7022{2:~ }| 7023]] , 7024float_pos =expected_pos , 7025} 7026else 7027screen : expect ( [[ 7028x | 7029{0:~ }| 7030{0:~ }{1:^y }{0: }| 7031{0:~ }{2:~ }{0: }| 7032{0:~ }|*2 7033| 7034]] ) 7035end 7036 7037feed ( '<c-w>10<lt>' ) 7038if multigrid then 7039screen : expect { 7040grid =[[ 7041## grid 1 7042[2:----------------------------------------]|*6 7043[3:----------------------------------------]| 7044## grid 2 7045x | 7046{0:~ }|*5 7047## grid 3 7048| 7049## grid 4 7050{1:^y }| 7051{2:~ }| 7052]] , 7053float_pos =expected_pos , 7054} 7055else 7056screen : expect ( [[ 7057x | 7058{0:~ }| 7059{0:~ }{1:^y }{0: }| 7060{0:~ }{2:~ }{0: }| 7061{0:~ }|*2 7062| 7063]] ) 7064end 7065 7066feed ( '<c-w>15|' ) 7067if multigrid then 7068screen : expect { 7069grid =[[ 7070## grid 1 7071[2:----------------------------------------]|*6 7072[3:----------------------------------------]| 7073## grid 2 7074x | 7075{0:~ }|*5 7076## grid 3 7077| 7078## grid 4 7079{1:^y }| 7080{2:~ }| 7081]] , 7082float_pos =expected_pos , 7083} 7084else 7085screen : expect ( [[ 7086x | 7087{0:~ }| 7088{0:~ }{1:^y }{0: }| 7089{0:~ }{2:~ }{0: }| 7090{0:~ }|*2 7091| 7092]] ) 7093end 7094 7095feed ( '<c-w>|' ) 7096if multigrid then 7097screen : expect { 7098grid =[[ 7099## grid 1 7100[2:----------------------------------------]|*6 7101[3:----------------------------------------]| 7102## grid 2 7103x | 7104{0:~ }|*5 7105## grid 3 7106| 7107## grid 4 7108{1:^y }| 7109{2:~ }| 7110]] , 7111float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 0 } } , 7112} 7113else 7114screen : expect ( [[ 7115x | 7116{0:~ }| 7117{1:^y }| 7118{2:~ }| 7119{0:~ }|*2 7120| 7121]] ) 7122end 7123end ) 7124 7125it ( 's :split (non-float)' , function () 7126feed ( '<c-w>s' ) 7127if multigrid then 7128screen : expect { 7129grid =[[ 7130## grid 1 7131[5:----------------------------------------]|*2 7132{4:[No Name] [+] }| 7133[2:----------------------------------------]|*2 7134{5:[No Name] [+] }| 7135[3:----------------------------------------]| 7136## grid 2 7137x | 7138{0:~ }| 7139## grid 3 7140| 7141## grid 4 7142{1:y }| 7143{2:~ }| 7144## grid 5 7145^x | 7146{0:~ }| 7147]] , 7148float_pos =expected_pos , 7149} 7150else 7151screen : expect ( [[ 7152^x | 7153{0:~ }| 7154{4:[No N}{1:y }{4: }| 7155x {2:~ } | 7156{0:~ }| 7157{5:[No Name] [+] }| 7158| 7159]] ) 7160end 7161 7162feed ( '<c-w>w' ) 7163if multigrid then 7164screen : expect { 7165grid =[[ 7166## grid 1 7167[5:----------------------------------------]|*2 7168{5:[No Name] [+] }| 7169[2:----------------------------------------]|*2 7170{4:[No Name] [+] }| 7171[3:----------------------------------------]| 7172## grid 2 7173^x | 7174{0:~ }| 7175## grid 3 7176| 7177## grid 4 7178{1:y }| 7179{2:~ }| 7180## grid 5 7181x | 7182{0:~ }| 7183]] , 7184float_pos =expected_pos , 7185} 7186else 7187screen : expect ( [[ 7188x | 7189{0:~ }| 7190{5:[No N}{1:y }{5: }| 7191^x {2:~ } | 7192{0:~ }| 7193{4:[No Name] [+] }| 7194| 7195]] ) 7196end 7197 7198feed ( '<c-w>w' ) 7199if multigrid then 7200screen : expect { 7201grid =[[ 7202## grid 1 7203[5:----------------------------------------]|*2 7204{5:[No Name] [+] }| 7205[2:----------------------------------------]|*2 7206{5:[No Name] [+] }| 7207[3:----------------------------------------]| 7208## grid 2 7209x | 7210{0:~ }| 7211## grid 3 7212| 7213## grid 4 7214{1:^y }| 7215{2:~ }| 7216## grid 5 7217x | 7218{0:~ }| 7219]] , 7220float_pos =expected_pos , 7221} 7222else 7223screen : expect ( [[ 7224x | 7225{0:~ }| 7226{5:[No N}{1:^y }{5: }| 7227x {2:~ } | 7228{0:~ }| 7229{5:[No Name] [+] }| 7230| 7231]] ) 7232end 7233 7234feed ( '<c-w>w' ) 7235if multigrid then 7236screen : expect { 7237grid =[[ 7238## grid 1 7239[5:----------------------------------------]|*2 7240{4:[No Name] [+] }| 7241[2:----------------------------------------]|*2 7242{5:[No Name] [+] }| 7243[3:----------------------------------------]| 7244## grid 2 7245x | 7246{0:~ }| 7247## grid 3 7248| 7249## grid 4 7250{1:y }| 7251{2:~ }| 7252## grid 5 7253^x | 7254{0:~ }| 7255]] , 7256float_pos =expected_pos , 7257} 7258else 7259screen : expect ( [[ 7260^x | 7261{0:~ }| 7262{4:[No N}{1:y }{4: }| 7263x {2:~ } | 7264{0:~ }| 7265{5:[No Name] [+] }| 7266| 7267]] ) 7268end 7269end ) 7270 7271it ( 's :split (float)' , function () 7272feed ( '<c-w>w<c-w>s' ) 7273if multigrid then 7274screen : expect { 7275grid =[[ 7276## grid 1 7277[5:----------------------------------------]|*2 7278{4:[No Name] [+] }| 7279[2:----------------------------------------]|*2 7280{5:[No Name] [+] }| 7281[3:----------------------------------------]| 7282## grid 2 7283x | 7284{0:~ }| 7285## grid 3 7286| 7287## grid 4 7288{1:y }| 7289{2:~ }| 7290## grid 5 7291^y | 7292{0:~ }| 7293]] , 7294float_pos =expected_pos , 7295} 7296else 7297screen : expect ( [[ 7298^y | 7299{0:~ }| 7300{4:[No N}{1:y }{4: }| 7301x {2:~ } | 7302{0:~ }| 7303{5:[No Name] [+] }| 7304| 7305]] ) 7306end 7307 7308feed ( '<c-w>j' ) 7309if multigrid then 7310screen : expect { 7311grid =[[ 7312## grid 1 7313[5:----------------------------------------]|*2 7314{5:[No Name] [+] }| 7315[2:----------------------------------------]|*2 7316{4:[No Name] [+] }| 7317[3:----------------------------------------]| 7318## grid 2 7319^x | 7320{0:~ }| 7321## grid 3 7322| 7323## grid 4 7324{1:y }| 7325{2:~ }| 7326## grid 5 7327y | 7328{0:~ }| 7329]] , 7330float_pos =expected_pos , 7331} 7332else 7333screen : expect ( [[ 7334y | 7335{0:~ }| 7336{5:[No N}{1:y }{5: }| 7337^x {2:~ } | 7338{0:~ }| 7339{4:[No Name] [+] }| 7340| 7341]] ) 7342end 7343 7344feed ( '<c-w>ji' ) 7345if multigrid then 7346screen : expect { 7347grid =[[ 7348## grid 1 7349[5:----------------------------------------]|*2 7350{5:[No Name] [+] }| 7351[2:----------------------------------------]|*2 7352{4:[No Name] [+] }| 7353[3:----------------------------------------]| 7354## grid 2 7355^x | 7356{0:~ }| 7357## grid 3 7358{3:-- INSERT --} | 7359## grid 4 7360{1:y }| 7361{2:~ }| 7362## grid 5 7363y | 7364{0:~ }| 7365]] , 7366float_pos =expected_pos , 7367} 7368else 7369screen : expect ( [[ 7370y | 7371{0:~ }| 7372{5:[No N}{1:y }{5: }| 7373^x {2:~ } | 7374{0:~ }| 7375{4:[No Name] [+] }| 7376{3:-- INSERT --} | 7377]] ) 7378end 7379end ) 7380 7381it ( ':new (non-float)' , function () 7382feed ( ':new<cr>' ) 7383if multigrid then 7384screen : expect { 7385grid =[[ 7386## grid 1 7387[5:----------------------------------------]|*2 7388{4:[No Name] }| 7389[2:----------------------------------------]|*2 7390{5:[No Name] [+] }| 7391[3:----------------------------------------]| 7392## grid 2 7393x | 7394{0:~ }| 7395## grid 3 7396:new | 7397## grid 4 7398{1:y }| 7399{2:~ }| 7400## grid 5 7401^ | 7402{0:~ }| 7403]] , 7404float_pos =expected_pos , 7405} 7406else 7407screen : expect ( [[ 7408^ | 7409{0:~ }| 7410{4:[No N}{1:y }{4: }| 7411x {2:~ } | 7412{0:~ }| 7413{5:[No Name] [+] }| 7414:new | 7415]] ) 7416end 7417end ) 7418 7419it ( ':new (float)' , function () 7420feed ( '<c-w>w:new<cr>' ) 7421if multigrid then 7422screen : expect { 7423grid =[[ 7424## grid 1 7425[5:----------------------------------------]|*2 7426{4:[No Name] }| 7427[2:----------------------------------------]|*2 7428{5:[No Name] [+] }| 7429[3:----------------------------------------]| 7430## grid 2 7431x | 7432{0:~ }| 7433## grid 3 7434:new | 7435## grid 4 7436{1:y }| 7437{2:~ }| 7438## grid 5 7439^ | 7440{0:~ }| 7441]] , 7442float_pos =expected_pos , 7443} 7444else 7445screen : expect ( [[ 7446^ | 7447{0:~ }| 7448{4:[No N}{1:y }{4: }| 7449x {2:~ } | 7450{0:~ }| 7451{5:[No Name] [+] }| 7452:new | 7453]] ) 7454end 7455end ) 7456 7457it ( 'v :vsplit (non-float)' , function () 7458feed ( '<c-w>v' ) 7459if multigrid then 7460screen : expect { 7461grid =[[ 7462## grid 1 7463[5:--------------------]{5:│}[2:-------------------]|*5 7464{4:[No Name] [+] }{5:[No Name] [+] }| 7465[3:----------------------------------------]| 7466## grid 2 7467x | 7468{0:~ }|*4 7469## grid 3 7470| 7471## grid 4 7472{1:y }| 7473{2:~ }| 7474## grid 5 7475^x | 7476{0:~ }|*4 7477]] , 7478float_pos =expected_pos , 7479} 7480else 7481screen : expect ( [[ 7482^x {5:│}x | 7483{0:~ }{5:│}{0:~ }| 7484{0:~ }{1:y }{0: }| 7485{0:~ }{2:~ }{0: }| 7486{0:~ }{5:│}{0:~ }| 7487{4:[No Name] [+] }{5:[No Name] [+] }| 7488| 7489]] ) 7490end 7491end ) 7492 7493it ( ':vnew (non-float)' , function () 7494feed ( ':vnew<cr>' ) 7495if multigrid then 7496screen : expect { 7497grid =[[ 7498## grid 1 7499[5:--------------------]{5:│}[2:-------------------]|*5 7500{4:[No Name] }{5:[No Name] [+] }| 7501[3:----------------------------------------]| 7502## grid 2 7503x | 7504{0:~ }|*4 7505## grid 3 7506:vnew | 7507## grid 4 7508{1:y }| 7509{2:~ }| 7510## grid 5 7511^ | 7512{0:~ }|*4 7513]] , 7514float_pos =expected_pos , 7515} 7516else 7517screen : expect ( [[ 7518^ {5:│}x | 7519{0:~ }{5:│}{0:~ }| 7520{0:~ }{1:y }{0: }| 7521{0:~ }{2:~ }{0: }| 7522{0:~ }{5:│}{0:~ }| 7523{4:[No Name] }{5:[No Name] [+] }| 7524:vnew | 7525]] ) 7526end 7527end ) 7528 7529it ( ':vnew (float)' , function () 7530feed ( '<c-w>w:vnew<cr>' ) 7531if multigrid then 7532screen : expect { 7533grid =[[ 7534## grid 1 7535[5:--------------------]{5:│}[2:-------------------]|*5 7536{4:[No Name] }{5:[No Name] [+] }| 7537[3:----------------------------------------]| 7538## grid 2 7539x | 7540{0:~ }|*4 7541## grid 3 7542:vnew | 7543## grid 4 7544{1:y }| 7545{2:~ }| 7546## grid 5 7547^ | 7548{0:~ }|*4 7549]] , 7550float_pos =expected_pos , 7551} 7552else 7553screen : expect ( [[ 7554^ {5:│}x | 7555{0:~ }{5:│}{0:~ }| 7556{0:~ }{1:y }{0: }| 7557{0:~ }{2:~ }{0: }| 7558{0:~ }{5:│}{0:~ }| 7559{4:[No Name] }{5:[No Name] [+] }| 7560:vnew | 7561]] ) 7562end 7563end ) 7564 7565it ( 'q (:quit) last non-float exits nvim' , function () 7566command ( 'autocmd VimLeave * call rpcrequest(1, "exit")' ) 7567-- avoid unsaved change in other buffer 7568feed ( '<c-w><c-w>:w Xtest_written2<cr><c-w><c-w>' ) 7569-- quit in last non-float 7570feed ( ':wq Xtest_written<cr>' ) 7571local exited =false 7572local function on_request ( name , args ) 7573eq ( 'exit' , name ) 7574eq ( {} , args ) 7575exited =true 7576return 0 7577end 7578local function on_setup () 7579feed ( ':wq Xtest_written<cr>' ) 7580end 7581run ( on_request , nil , on_setup ) 7582os . remove ( 'Xtest_written' ) 7583os . remove ( 'Xtest_written2' ) 7584eq ( true , exited ) 7585end ) 7586 7587it ( ':quit two floats in a row' , function () 7588-- enter first float 7589feed ( '<c-w><c-w>' ) 7590-- enter second float 7591api . nvim_open_win ( 0 , true , { relative ='editor' , width =20 , height =2 , row =4 , col =8 } ) 7592if multigrid then 7593screen : expect { 7594grid =[[ 7595## grid 1 7596[2:----------------------------------------]|*6 7597[3:----------------------------------------]| 7598## grid 2 7599x | 7600{0:~ }|*5 7601## grid 3 7602| 7603## grid 4 7604{1:y }| 7605{2:~ }| 7606## grid 5 7607{1:^y }| 7608{2:~ }| 7609]] , 7610float_pos ={ 7611[ 5 ] ={ 1002 , 'NW' , 1 , 4 , 8 , true , 50 , 2 , 4 , 8 } , 7612[ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } , 7613} , 7614} 7615else 7616screen : expect ( [[ 7617x | 7618{0:~ }| 7619{0:~ }{1:y }{0: }| 7620{0:~ }{2:~ }{0: }| 7621{0:~ }{1:^y }{0: }| 7622{0:~ }{2:~ }{0: }| 7623| 7624]] ) 7625end 7626 7627feed ( ':quit<cr>' ) 7628if multigrid then 7629screen : expect { 7630grid =[[ 7631## grid 1 7632[2:----------------------------------------]|*6 7633[3:----------------------------------------]| 7634## grid 2 7635x | 7636{0:~ }|*5 7637## grid 3 7638:quit | 7639## grid 4 7640{1:^y }| 7641{2:~ }| 7642]] , 7643float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 7644} 7645else 7646screen : expect ( [[ 7647x | 7648{0:~ }| 7649{0:~ }{1:^y }{0: }| 7650{0:~ }{2:~ }{0: }| 7651{0:~ }|*2 7652:quit | 7653]] ) 7654end 7655 7656feed ( ':quit<cr>' ) 7657if multigrid then 7658screen : expect ( [[ 7659## grid 1 7660[2:----------------------------------------]|*6 7661[3:----------------------------------------]| 7662## grid 2 7663^x | 7664{0:~ }|*5 7665## grid 3 7666:quit | 7667]] ) 7668else 7669screen : expect ( [[ 7670^x | 7671{0:~ }|*5 7672:quit | 7673]] ) 7674end 7675 7676assert_alive () 7677end ) 7678 7679it ( 'o (:only) non-float' , function () 7680feed ( '<c-w>o' ) 7681if multigrid then 7682screen : expect { 7683grid =[[ 7684## grid 1 7685[2:----------------------------------------]|*6 7686[3:----------------------------------------]| 7687## grid 2 7688^x | 7689{0:~ }|*5 7690## grid 3 7691| 7692]] , 7693} 7694else 7695screen : expect ( [[ 7696^x | 7697{0:~ }|*5 7698| 7699]] ) 7700end 7701end ) 7702 7703it ( 'o (:only) float fails' , function () 7704feed ( '<c-w>w<c-w>o' ) 7705if multigrid then 7706screen : expect { 7707grid =[[ 7708## grid 1 7709[2:----------------------------------------]|*4 7710[3:----------------------------------------]|*3 7711## grid 2 7712x | 7713{0:~ }|*5 7714## grid 3 7715{7:E5601: Cannot close window, only floatin}| 7716{7:g window would remain} | 7717{8:Press ENTER or type command to continue}^ | 7718## grid 4 7719{1:y }| 7720{2:~ }| 7721]] , 7722float_pos =expected_pos , 7723} 7724else 7725screen : expect ( [[ 7726x | 7727{0:~ }| 7728{0:~ }{1:y }{0: }| 7729{4: }| 7730{7:E5601: Cannot close window, only floatin}| 7731{7:g window would remain} | 7732{8:Press ENTER or type command to continue}^ | 7733]] ) 7734end 7735 7736-- test message clear 7737feed ( '<cr>' ) 7738if multigrid then 7739screen : expect { 7740grid =[[ 7741## grid 1 7742[2:----------------------------------------]|*6 7743[3:----------------------------------------]| 7744## grid 2 7745x | 7746{0:~ }|*5 7747## grid 3 7748| 7749## grid 4 7750{1:^y }| 7751{2:~ }| 7752]] , 7753float_pos =expected_pos , 7754} 7755else 7756screen : expect ( [[ 7757x | 7758{0:~ }| 7759{0:~ }{1:^y }{0: }| 7760{0:~ }{2:~ }{0: }| 7761{0:~ }|*2 7762| 7763]] ) 7764end 7765end ) 7766 7767it ( 'o (:only) non-float with split' , function () 7768feed ( '<c-w>s' ) 7769if multigrid then 7770screen : expect { 7771grid =[[ 7772## grid 1 7773[5:----------------------------------------]|*2 7774{4:[No Name] [+] }| 7775[2:----------------------------------------]|*2 7776{5:[No Name] [+] }| 7777[3:----------------------------------------]| 7778## grid 2 7779x | 7780{0:~ }| 7781## grid 3 7782| 7783## grid 4 7784{1:y }| 7785{2:~ }| 7786## grid 5 7787^x | 7788{0:~ }| 7789]] , 7790float_pos =expected_pos , 7791} 7792else 7793screen : expect ( [[ 7794^x | 7795{0:~ }| 7796{4:[No N}{1:y }{4: }| 7797x {2:~ } | 7798{0:~ }| 7799{5:[No Name] [+] }| 7800| 7801]] ) 7802end 7803 7804feed ( '<c-w>o' ) 7805if multigrid then 7806screen : expect { 7807grid =[[ 7808## grid 1 7809[5:----------------------------------------]|*6 7810[3:----------------------------------------]| 7811## grid 3 7812| 7813## grid 5 7814^x | 7815{0:~ }|*5 7816]] , 7817} 7818else 7819screen : expect ( [[ 7820^x | 7821{0:~ }|*5 7822| 7823]] ) 7824end 7825end ) 7826 7827it ( 'o (:only) float with split' , function () 7828feed ( '<c-w>s<c-w>W' ) 7829if multigrid then 7830screen : expect { 7831grid =[[ 7832## grid 1 7833[5:----------------------------------------]|*2 7834{5:[No Name] [+] }| 7835[2:----------------------------------------]|*2 7836{5:[No Name] [+] }| 7837[3:----------------------------------------]| 7838## grid 2 7839x | 7840{0:~ }| 7841## grid 3 7842| 7843## grid 4 7844{1:^y }| 7845{2:~ }| 7846## grid 5 7847x | 7848{0:~ }| 7849]] , 7850float_pos =expected_pos , 7851} 7852else 7853screen : expect ( [[ 7854x | 7855{0:~ }| 7856{5:[No N}{1:^y }{5: }| 7857x {2:~ } | 7858{0:~ }| 7859{5:[No Name] [+] }| 7860| 7861]] ) 7862end 7863 7864feed ( '<c-w>o' ) 7865if multigrid then 7866screen : expect { 7867grid =[[ 7868## grid 1 7869[5:----------------------------------------]|*2 7870{5:[No Name] [+] }| 7871[2:----------------------------------------]| 7872[3:----------------------------------------]|*3 7873## grid 2 7874x | 7875{0:~ }| 7876## grid 3 7877{7:E5601: Cannot close window, only floatin}| 7878{7:g window would remain} | 7879{8:Press ENTER or type command to continue}^ | 7880## grid 4 7881{1:y }| 7882{2:~ }| 7883## grid 5 7884x | 7885{0:~ }| 7886]] , 7887float_pos =expected_pos , 7888} 7889else 7890screen : expect ( [[ 7891x | 7892{0:~ }| 7893{5:[No N}{1:y }{5: }| 7894{4: }| 7895{7:E5601: Cannot close window, only floatin}| 7896{7:g window would remain} | 7897{8:Press ENTER or type command to continue}^ | 7898]] ) 7899end 7900end ) 7901 7902it ( 'J (float)' , function () 7903feed ( '<c-w>w<c-w>J' ) 7904if multigrid then 7905screen : expect { 7906grid =[[ 7907## grid 1 7908[2:----------------------------------------]|*2 7909{5:[No Name] [+] }| 7910[4:----------------------------------------]|*2 7911{4:[No Name] [+] }| 7912[3:----------------------------------------]| 7913## grid 2 7914x | 7915{0:~ }| 7916## grid 3 7917| 7918## grid 4 7919^y | 7920{0:~ }| 7921]] , 7922} 7923else 7924screen : expect ( [[ 7925x | 7926{0:~ }| 7927{5:[No Name] [+] }| 7928^y | 7929{0:~ }| 7930{4:[No Name] [+] }| 7931| 7932]] ) 7933end 7934 7935if multigrid then 7936api . nvim_win_set_config ( 0 , { external =true , width =30 , height =2 } ) 7937expected_pos ={ [ 4 ] ={ external =true } } 7938screen : expect { 7939grid =[[ 7940## grid 1 7941[2:----------------------------------------]|*6 7942[3:----------------------------------------]| 7943## grid 2 7944x | 7945{0:~ }|*5 7946## grid 3 7947| 7948## grid 4 7949^y | 7950{0:~ }| 7951]] , 7952float_pos =expected_pos , 7953} 7954else 7955eq ( "UI doesn't support external windows" , pcall_err ( api . nvim_win_set_config , 0 , { external =true , width =30 , height =2 } )) 7956return 7957end 7958 7959feed ( '<c-w>J' ) 7960if multigrid then 7961screen : expect ( [[ 7962## grid 1 7963[2:----------------------------------------]|*2 7964{5:[No Name] [+] }| 7965[4:----------------------------------------]|*2 7966{4:[No Name] [+] }| 7967[3:----------------------------------------]| 7968## grid 2 7969x | 7970{0:~ }| 7971## grid 3 7972| 7973## grid 4 7974^y | 7975{0:~ }| 7976]] ) 7977end 7978end ) 7979 7980it ( 'J (float with border)' , function () 7981api . nvim_win_set_config ( win , { relative ='editor' , width =20 , height =2 , row =2 , col =5 , border ='single' } ) 7982if multigrid then 7983screen : expect { 7984grid =[[ 7985## grid 1 7986[2:----------------------------------------]|*6 7987[3:----------------------------------------]| 7988## grid 2 7989^x | 7990{0:~ }|*5 7991## grid 3 7992| 7993## grid 4 7994{33:┌────────────────────┐}| 7995{33:│}{1:y }{33:│}| 7996{33:│}{2:~ }{33:│}| 7997{33:└────────────────────┘}| 7998]] , 7999float_pos =expected_pos , 8000} 8001else 8002screen : expect ( [[ 8003^x | 8004{0:~ }| 8005{0:~ }{33:┌────────────────────┐}{0: }| 8006{0:~ }{33:│}{1:y }{33:│}{0: }| 8007{0:~ }{33:│}{2:~ }{33:│}{0: }| 8008{0:~ }{33:└────────────────────┘}{0: }| 8009| 8010]] ) 8011end 8012 8013feed ( '<c-w>w<c-w>J' ) 8014if multigrid then 8015screen : expect { 8016grid =[[ 8017## grid 1 8018[2:----------------------------------------]|*2 8019{5:[No Name] [+] }| 8020[4:----------------------------------------]|*2 8021{4:[No Name] [+] }| 8022[3:----------------------------------------]| 8023## grid 2 8024x | 8025{0:~ }| 8026## grid 3 8027| 8028## grid 4 8029^y | 8030{0:~ }| 8031]] , 8032} 8033else 8034screen : expect ( [[ 8035x | 8036{0:~ }| 8037{5:[No Name] [+] }| 8038^y | 8039{0:~ }| 8040{4:[No Name] [+] }| 8041| 8042]] ) 8043end 8044end ) 8045 8046it ( 'movements with nested split layout' , function () 8047command ( 'set hidden' ) 8048feed ( '<c-w>s<c-w>v<c-w>b<c-w>v' ) 8049if multigrid then 8050screen : expect { 8051grid =[[ 8052## grid 1 8053[6:--------------------]{5:│}[5:-------------------]|*2 8054{5:[No Name] [+] [No Name] [+] }| 8055[7:--------------------]{5:│}[2:-------------------]|*2 8056{4:[No Name] [+] }{5:[No Name] [+] }| 8057[3:----------------------------------------]| 8058## grid 2 8059x | 8060{0:~ }| 8061## grid 3 8062| 8063## grid 4 8064{1:y }| 8065{2:~ }| 8066## grid 5 8067x | 8068{0:~ }| 8069## grid 6 8070x | 8071{0:~ }| 8072## grid 7 8073^x | 8074{0:~ }| 8075]] , 8076float_pos =expected_pos , 8077} 8078else 8079screen : expect ( [[ 8080x {5:│}x | 8081{0:~ }{5:│}{0:~ }| 8082{5:[No N}{1:y }{5:Name] [+] }| 8083^x {2:~ } | 8084{0:~ }{5:│}{0:~ }| 8085{4:[No Name] [+] }{5:[No Name] [+] }| 8086| 8087]] ) 8088end 8089 8090-- verify that N<c-w>w works 8091for i =1 , 5 do 8092feed ( i .. '<c-w>w' ) 8093feed_command ( 'enew' ) 8094api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { tostring ( i ) } ) 8095end 8096 8097if multigrid then 8098screen : expect { 8099grid =[[ 8100## grid 1 8101[6:-------------------]{5:│}[5:--------------------]|*2 8102{5:[No Name] [+] [No Name] [+] }| 8103[7:-------------------]{5:│}[2:--------------------]|*2 8104{5:[No Name] [+] [No Name] [+] }| 8105[3:----------------------------------------]| 8106## grid 2 81074 | 8108{0:~ }| 8109## grid 3 8110:enew | 8111## grid 4 8112{1:^5 }| 8113{2:~ }| 8114## grid 5 81152 | 8116{0:~ }| 8117## grid 6 81181 | 8119{0:~ }| 8120## grid 7 81213 | 8122{0:~ }| 8123]] , 8124float_pos =expected_pos , 8125} 8126else 8127screen : expect ( [[ 81281 {5:│}2 | 8129{0:~ }{5:│}{0:~ }| 8130{5:[No N}{1:^5 }{5:ame] [+] }| 81313 {2:~ } | 8132{0:~ }{5:│}{0:~ }| 8133{5:[No Name] [+] [No Name] [+] }| 8134:enew | 8135]] ) 8136end 8137 8138local movements ={ 8139w ={ 2 , 3 , 4 , 5 , 1 } , 8140W ={ 5 , 1 , 2 , 3 , 4 } , 8141h ={ 1 , 1 , 3 , 3 , 3 } , 8142j ={ 3 , 3 , 3 , 4 , 4 } , 8143k ={ 1 , 2 , 1 , 1 , 1 } , 8144l ={ 2 , 2 , 4 , 4 , 4 } , 8145t ={ 1 , 1 , 1 , 1 , 1 } , 8146b ={ 4 , 4 , 4 , 4 , 4 } , 8147} 8148 8149for k , v in pairs ( movements ) do 8150for i =1 , 5 do 8151feed ( i .. '<c-w>w' ) 8152feed ( '<c-w>' .. k ) 8153local nr =fn . winnr () 8154eq ( v [ i ], nr , 'when using <c-w>' .. k .. ' from window ' .. i ) 8155end 8156end 8157 8158for i =1 , 5 do 8159feed ( i .. '<c-w>w' ) 8160for j =1 , 5 do 8161if j ~= i then 8162feed ( j .. '<c-w>w' ) 8163feed ( '<c-w>p' ) 8164local nr =fn . winnr () 8165eq ( i , nr , 'when using <c-w>p to window ' .. i .. ' from window ' .. j ) 8166end 8167end 8168end 8169end ) 8170 8171it ( ':tabnew and :tabnext' , function () 8172feed ( ':tabnew<cr>' ) 8173if multigrid then 8174-- grid is not freed, but float is marked as closed (should it rather be "invisible"?) 8175screen : expect { 8176grid =[[ 8177## grid 1 8178{9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}| 8179[5:----------------------------------------]|*5 8180[3:----------------------------------------]| 8181## grid 2 (hidden) 8182x | 8183{0:~ }|*5 8184## grid 3 8185:tabnew | 8186## grid 4 (hidden) 8187{1:y }| 8188{2:~ }| 8189## grid 5 8190^ | 8191{0:~ }|*4 8192]] , 8193} 8194else 8195screen : expect ( [[ 8196{9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}| 8197^ | 8198{0:~ }|*4 8199:tabnew | 8200]] ) 8201end 8202 8203feed ( ':tabnext<cr>' ) 8204if multigrid then 8205screen : expect { 8206grid =[[ 8207## grid 1 8208{3: }{34:2}{3:+ [No Name] }{9: [No Name] }{5: }{9:X}| 8209[2:----------------------------------------]|*5 8210[3:----------------------------------------]| 8211## grid 2 8212^x | 8213{0:~ }|*4 8214## grid 3 8215:tabnext | 8216## grid 4 8217{1:y }| 8218{2:~ }| 8219## grid 5 (hidden) 8220| 8221{0:~ }|*4 8222]] , 8223float_pos =expected_pos , 8224} 8225else 8226screen : expect ( [[ 8227{3: }{34:2}{3:+ [No Name] }{9: [No Name] }{5: }{9:X}| 8228^x | 8229{0:~ }{1:y }{0: }| 8230{0:~ }{2:~ }{0: }| 8231{0:~ }|*2 8232:tabnext | 8233]] ) 8234end 8235 8236feed ( ':tabnext<cr>' ) 8237if multigrid then 8238screen : expect { 8239grid =[[ 8240## grid 1 8241{9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}| 8242[5:----------------------------------------]|*5 8243[3:----------------------------------------]| 8244## grid 2 (hidden) 8245x | 8246{0:~ }|*4 8247## grid 3 8248:tabnext | 8249## grid 4 (hidden) 8250{1:y }| 8251{2:~ }| 8252## grid 5 8253^ | 8254{0:~ }|*4 8255]] , 8256} 8257else 8258screen : expect ( [[ 8259{9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}| 8260^ | 8261{0:~ }|*4 8262:tabnext | 8263]] ) 8264end 8265end ) 8266 8267it ( ':tabnew and :tabnext (external)' , function () 8268if multigrid then 8269-- also test external window wider than main screen 8270api . nvim_win_set_config ( win , { external =true , width =65 , height =4 } ) 8271expected_pos ={ [ 4 ] ={ external =true } } 8272feed ( ':tabnew<cr>' ) 8273screen : expect { 8274grid =[[ 8275## grid 1 8276{9: + [No Name] }{3: }{34:2}{3:+ [No Name] }{5: }{9:X}| 8277[5:----------------------------------------]|*5 8278[3:----------------------------------------]| 8279## grid 2 (hidden) 8280x | 8281{0:~ }|*5 8282## grid 3 8283:tabnew | 8284## grid 4 8285y | 8286{0:~ }|*3 8287## grid 5 8288^ | 8289{0:~ }|*4 8290]] , 8291float_pos =expected_pos , 8292} 8293else 8294eq ( "UI doesn't support external windows" , pcall_err ( api . nvim_win_set_config , 0 , { external =true , width =65 , height =4 } )) 8295end 8296 8297feed ( ':tabnext<cr>' ) 8298if multigrid then 8299screen : expect { 8300grid =[[ 8301## grid 1 8302{3: }{34:2}{3:+ [No Name] }{9: [No Name] }{5: }{9:X}| 8303[2:----------------------------------------]|*5 8304[3:----------------------------------------]| 8305## grid 2 8306^x | 8307{0:~ }|*4 8308## grid 3 8309:tabnext | 8310## grid 4 8311y | 8312{0:~ }|*3 8313## grid 5 (hidden) 8314| 8315{0:~ }|*4 8316]] , 8317float_pos =expected_pos , 8318} 8319end 8320 8321feed ( ':tabnext<cr>' ) 8322if multigrid then 8323screen : expect { 8324grid =[[ 8325## grid 1 8326{9: + [No Name] }{3: }{34:2}{3:+ [No Name] }{5: }{9:X}| 8327[5:----------------------------------------]|*5 8328[3:----------------------------------------]| 8329## grid 2 (hidden) 8330x | 8331{0:~ }|*4 8332## grid 3 8333:tabnext | 8334## grid 4 8335y | 8336{0:~ }|*3 8337## grid 5 8338^ | 8339{0:~ }|*4 8340]] , 8341float_pos =expected_pos , 8342} 8343end 8344end ) 8345end ) 8346 8347it ( 'left drag changes visual selection in float window' , function () 8348local buf =api . nvim_create_buf ( false , false ) 8349api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'foo' , 'bar' , 'baz' } ) 8350api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =3 , row =2 , col =5 } ) 8351if multigrid then 8352screen : expect { 8353grid =[[ 8354## grid 1 8355[2:----------------------------------------]|*6 8356[3:----------------------------------------]| 8357## grid 2 8358^ | 8359{0:~ }|*5 8360## grid 3 8361| 8362## grid 4 8363{1:foo }| 8364{1:bar }| 8365{1:baz }| 8366]] , 8367float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 8368win_viewport ={ 8369[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8370[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 8371} , 8372} 8373 8374if send_mouse_grid then 8375api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 0 , 0 ) 8376else 8377api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 5 ) 8378end 8379screen : expect { 8380grid =[[ 8381## grid 1 8382[2:----------------------------------------]|*6 8383[3:----------------------------------------]| 8384## grid 2 8385| 8386{0:~ }|*5 8387## grid 3 8388| 8389## grid 4 8390{1:^foo }| 8391{1:bar }| 8392{1:baz }| 8393]] , 8394float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 8395win_viewport ={ 8396[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8397[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 8398} , 8399} 8400 8401if send_mouse_grid then 8402api . nvim_input_mouse ( 'left' , 'drag' , '' , 4 , 1 , 2 ) 8403else 8404api . nvim_input_mouse ( 'left' , 'drag' , '' , 0 , 3 , 7 ) 8405end 8406screen : expect { 8407grid =[[ 8408## grid 1 8409[2:----------------------------------------]|*6 8410[3:----------------------------------------]| 8411## grid 2 8412| 8413{0:~ }|*5 8414## grid 3 8415{3:-- VISUAL --} | 8416## grid 4 8417{27:foo}{1: }| 8418{27:ba^r}{1: }| 8419{1:baz }| 8420]] , 8421float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 8422win_viewport ={ 8423[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8424[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =1 , curcol =2 , linecount =3 , sum_scroll_delta =0 } , 8425} , 8426} 8427else 8428screen : expect { 8429grid =[[ 8430^ | 8431{0:~ }| 8432{0:~ }{1:foo }{0: }| 8433{0:~ }{1:bar }{0: }| 8434{0:~ }{1:baz }{0: }| 8435{0:~ }| 8436| 8437]] , 8438} 8439 8440api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 5 ) 8441screen : expect { 8442grid =[[ 8443| 8444{0:~ }| 8445{0:~ }{1:^foo }{0: }| 8446{0:~ }{1:bar }{0: }| 8447{0:~ }{1:baz }{0: }| 8448{0:~ }| 8449| 8450]] , 8451} 8452 8453api . nvim_input_mouse ( 'left' , 'drag' , '' , 0 , 3 , 7 ) 8454screen : expect { 8455grid =[[ 8456| 8457{0:~ }| 8458{0:~ }{27:foo}{1: }{0: }| 8459{0:~ }{27:ba^r}{1: }{0: }| 8460{0:~ }{1:baz }{0: }| 8461{0:~ }| 8462{3:-- VISUAL --} | 8463]] , 8464} 8465end 8466end ) 8467 8468it ( 'left drag changes visual selection in float window with border' , function () 8469local buf =api . nvim_create_buf ( false , false ) 8470api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'foo' , 'bar' , 'baz' } ) 8471api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =3 , row =0 , col =5 , border ='single' } ) 8472if multigrid then 8473screen : expect { 8474grid =[[ 8475## grid 1 8476[2:----------------------------------------]|*6 8477[3:----------------------------------------]| 8478## grid 2 8479^ | 8480{0:~ }|*5 8481## grid 3 8482| 8483## grid 4 8484{33:┌────────────────────┐}| 8485{33:│}{1:foo }{33:│}| 8486{33:│}{1:bar }{33:│}| 8487{33:│}{1:baz }{33:│}| 8488{33:└────────────────────┘}| 8489]] , 8490float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 8491win_viewport ={ 8492[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8493[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 8494} , 8495} 8496 8497if send_mouse_grid then 8498api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 1 , 1 ) 8499else 8500api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 1 , 6 ) 8501end 8502screen : expect { 8503grid =[[ 8504## grid 1 8505[2:----------------------------------------]|*6 8506[3:----------------------------------------]| 8507## grid 2 8508| 8509{0:~ }|*5 8510## grid 3 8511| 8512## grid 4 8513{33:┌────────────────────┐}| 8514{33:│}{1:^foo }{33:│}| 8515{33:│}{1:bar }{33:│}| 8516{33:│}{1:baz }{33:│}| 8517{33:└────────────────────┘}| 8518]] , 8519float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 8520win_viewport ={ 8521[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8522[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 8523} , 8524} 8525 8526if send_mouse_grid then 8527api . nvim_input_mouse ( 'left' , 'drag' , '' , 4 , 2 , 3 ) 8528else 8529api . nvim_input_mouse ( 'left' , 'drag' , '' , 0 , 2 , 8 ) 8530end 8531screen : expect { 8532grid =[[ 8533## grid 1 8534[2:----------------------------------------]|*6 8535[3:----------------------------------------]| 8536## grid 2 8537| 8538{0:~ }|*5 8539## grid 3 8540{3:-- VISUAL --} | 8541## grid 4 8542{33:┌────────────────────┐}| 8543{33:│}{27:foo}{1: }{33:│}| 8544{33:│}{27:ba^r}{1: }{33:│}| 8545{33:│}{1:baz }{33:│}| 8546{33:└────────────────────┘}| 8547]] , 8548float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 8549win_viewport ={ 8550[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8551[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =1 , curcol =2 , linecount =3 , sum_scroll_delta =0 } , 8552} , 8553} 8554else 8555screen : expect { 8556grid =[[ 8557^ {33:┌────────────────────┐} | 8558{0:~ }{33:│}{1:foo }{33:│}{0: }| 8559{0:~ }{33:│}{1:bar }{33:│}{0: }| 8560{0:~ }{33:│}{1:baz }{33:│}{0: }| 8561{0:~ }{33:└────────────────────┘}{0: }| 8562{0:~ }| 8563| 8564]] , 8565} 8566 8567api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 1 , 6 ) 8568screen : expect { 8569grid =[[ 8570{33:┌────────────────────┐} | 8571{0:~ }{33:│}{1:^foo }{33:│}{0: }| 8572{0:~ }{33:│}{1:bar }{33:│}{0: }| 8573{0:~ }{33:│}{1:baz }{33:│}{0: }| 8574{0:~ }{33:└────────────────────┘}{0: }| 8575{0:~ }| 8576| 8577]] , 8578} 8579 8580api . nvim_input_mouse ( 'left' , 'drag' , '' , 0 , 2 , 8 ) 8581screen : expect { 8582grid =[[ 8583{33:┌────────────────────┐} | 8584{0:~ }{33:│}{27:foo}{1: }{33:│}{0: }| 8585{0:~ }{33:│}{27:ba^r}{1: }{33:│}{0: }| 8586{0:~ }{33:│}{1:baz }{33:│}{0: }| 8587{0:~ }{33:└────────────────────┘}{0: }| 8588{0:~ }| 8589{3:-- VISUAL --} | 8590]] , 8591} 8592end 8593end ) 8594 8595it ( 'left drag changes visual selection in float window with winbar' , function () 8596local buf =api . nvim_create_buf ( false , false ) 8597api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'foo' , 'bar' , 'baz' } ) 8598local float_win =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =4 , row =1 , col =5 } ) 8599api . nvim_set_option_value ( 'winbar' , 'floaty bar' , { win =float_win } ) 8600if multigrid then 8601screen : expect { 8602grid =[[ 8603## grid 1 8604[2:----------------------------------------]|*6 8605[3:----------------------------------------]| 8606## grid 2 8607^ | 8608{0:~ }|*5 8609## grid 3 8610| 8611## grid 4 8612{3:floaty bar }| 8613{1:foo }| 8614{1:bar }| 8615{1:baz }| 8616]] , 8617float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 5 , true , 50 , 1 , 1 , 5 } } , 8618win_viewport ={ 8619[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8620[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 8621} , 8622} 8623 8624if send_mouse_grid then 8625api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 1 , 0 ) 8626else 8627api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 5 ) 8628end 8629screen : expect { 8630grid =[[ 8631## grid 1 8632[2:----------------------------------------]|*6 8633[3:----------------------------------------]| 8634## grid 2 8635| 8636{0:~ }|*5 8637## grid 3 8638| 8639## grid 4 8640{3:floaty bar }| 8641{1:^foo }| 8642{1:bar }| 8643{1:baz }| 8644]] , 8645float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 5 , true , 50 , 1 , 1 , 5 } } , 8646win_viewport ={ 8647[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8648[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 8649} , 8650} 8651 8652if send_mouse_grid then 8653api . nvim_input_mouse ( 'left' , 'drag' , '' , 4 , 2 , 2 ) 8654else 8655api . nvim_input_mouse ( 'left' , 'drag' , '' , 0 , 3 , 7 ) 8656end 8657screen : expect { 8658grid =[[ 8659## grid 1 8660[2:----------------------------------------]|*6 8661[3:----------------------------------------]| 8662## grid 2 8663| 8664{0:~ }|*5 8665## grid 3 8666{3:-- VISUAL --} | 8667## grid 4 8668{3:floaty bar }| 8669{27:foo}{1: }| 8670{27:ba^r}{1: }| 8671{1:baz }| 8672]] , 8673float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 5 , true , 50 , 1 , 1 , 5 } } , 8674win_viewport ={ 8675[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8676[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =1 , curcol =2 , linecount =3 , sum_scroll_delta =0 } , 8677} , 8678} 8679else 8680screen : expect { 8681grid =[[ 8682^ | 8683{0:~ }{3:floaty bar }{0: }| 8684{0:~ }{1:foo }{0: }| 8685{0:~ }{1:bar }{0: }| 8686{0:~ }{1:baz }{0: }| 8687{0:~ }| 8688| 8689]] , 8690} 8691 8692api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 5 ) 8693screen : expect { 8694grid =[[ 8695| 8696{0:~ }{3:floaty bar }{0: }| 8697{0:~ }{1:^foo }{0: }| 8698{0:~ }{1:bar }{0: }| 8699{0:~ }{1:baz }{0: }| 8700{0:~ }| 8701| 8702]] , 8703} 8704 8705api . nvim_input_mouse ( 'left' , 'drag' , '' , 0 , 3 , 7 ) 8706screen : expect { 8707grid =[[ 8708| 8709{0:~ }{3:floaty bar }{0: }| 8710{0:~ }{27:foo}{1: }{0: }| 8711{0:~ }{27:ba^r}{1: }{0: }| 8712{0:~ }{1:baz }{0: }| 8713{0:~ }| 8714{3:-- VISUAL --} | 8715]] , 8716} 8717end 8718end ) 8719 8720it ( 'left drag changes visual selection if float window is turned into a split' , function () 8721local buf =api . nvim_create_buf ( false , false ) 8722api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'foo' , 'bar' , 'baz' } ) 8723api . nvim_open_win ( buf , true , { relative ='editor' , width =20 , height =3 , row =2 , col =5 } ) 8724command ( 'wincmd L' ) 8725if multigrid then 8726screen : expect ( [[ 8727## grid 1 8728[2:-------------------]{5:│}[4:--------------------]|*5 8729{5:[No Name] }{4:[No Name] [+] }| 8730[3:----------------------------------------]| 8731## grid 2 8732| 8733{0:~ }|*4 8734## grid 3 8735| 8736## grid 4 8737^foo | 8738bar | 8739baz | 8740{0:~ }|*2 8741]] ) 8742 8743if send_mouse_grid then 8744api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 2 , 2 ) 8745else 8746api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 22 ) 8747end 8748screen : expect ( [[ 8749## grid 1 8750[2:-------------------]{5:│}[4:--------------------]|*5 8751{5:[No Name] }{4:[No Name] [+] }| 8752[3:----------------------------------------]| 8753## grid 2 8754| 8755{0:~ }|*4 8756## grid 3 8757| 8758## grid 4 8759foo | 8760bar | 8761ba^z | 8762{0:~ }|*2 8763]] ) 8764 8765if send_mouse_grid then 8766api . nvim_input_mouse ( 'left' , 'drag' , '' , 4 , 1 , 1 ) 8767else 8768api . nvim_input_mouse ( 'left' , 'drag' , '' , 0 , 1 , 21 ) 8769end 8770screen : expect ( [[ 8771## grid 1 8772[2:-------------------]{5:│}[4:--------------------]|*5 8773{5:[No Name] }{4:[No Name] [+] }| 8774[3:----------------------------------------]| 8775## grid 2 8776| 8777{0:~ }|*4 8778## grid 3 8779{3:-- VISUAL --} | 8780## grid 4 8781foo | 8782b{27:^ar} | 8783{27:baz} | 8784{0:~ }|*2 8785]] ) 8786else 8787screen : expect ( [[ 8788{5:│}^foo | 8789{0:~ }{5:│}bar | 8790{0:~ }{5:│}baz | 8791{0:~ }{5:│}{0:~ }|*2 8792{5:[No Name] }{4:[No Name] [+] }| 8793| 8794]] ) 8795 8796api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 22 ) 8797screen : expect ( [[ 8798{5:│}foo | 8799{0:~ }{5:│}bar | 8800{0:~ }{5:│}ba^z | 8801{0:~ }{5:│}{0:~ }|*2 8802{5:[No Name] }{4:[No Name] [+] }| 8803| 8804]] ) 8805 8806api . nvim_input_mouse ( 'left' , 'drag' , '' , 0 , 1 , 21 ) 8807screen : expect ( [[ 8808{5:│}foo | 8809{0:~ }{5:│}b{27:^ar} | 8810{0:~ }{5:│}{27:baz} | 8811{0:~ }{5:│}{0:~ }|*2 8812{5:[No Name] }{4:[No Name] [+] }| 8813{3:-- VISUAL --} | 8814]] ) 8815end 8816end ) 8817 8818it ( 'left click sets correct curswant in float window with border' , function () 8819local buf =api . nvim_create_buf ( false , false ) 8820api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { '' , '' , '' } ) 8821api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =3 , row =0 , col =5 , border ='single' } ) 8822if multigrid then 8823screen : expect { 8824grid =[[ 8825## grid 1 8826[2:----------------------------------------]|*6 8827[3:----------------------------------------]| 8828## grid 2 8829^ | 8830{0:~ }|*5 8831## grid 3 8832| 8833## grid 4 8834{33:┌────────────────────┐}| 8835{33:│}{1: }{33:│}|*3 8836{33:└────────────────────┘}| 8837]] , 8838float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 8839win_viewport ={ 8840[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8841[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 8842} , 8843} 8844else 8845screen : expect { 8846grid =[[ 8847^ {33:┌────────────────────┐} | 8848{0:~ }{33:│}{1: }{33:│}{0: }|*3 8849{0:~ }{33:└────────────────────┘}{0: }| 8850{0:~ }| 8851| 8852]] , 8853} 8854end 8855 8856if send_mouse_grid then 8857api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 3 , 1 ) 8858else 8859api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 3 , 6 ) 8860end 8861eq ( { 0 , 3 , 1 , 0 , 1 } , fn . getcurpos ()) 8862 8863if send_mouse_grid then 8864api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 3 , 2 ) 8865else 8866api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 3 , 7 ) 8867end 8868eq ( { 0 , 3 , 1 , 0 , 2 } , fn . getcurpos ()) 8869 8870if send_mouse_grid then 8871api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 3 , 10 ) 8872else 8873api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 3 , 15 ) 8874end 8875eq ( { 0 , 3 , 1 , 0 , 10 } , fn . getcurpos ()) 8876 8877command ( 'setlocal foldcolumn=1' ) 8878feed ( 'zfkgg' ) 8879if multigrid then 8880screen : expect { 8881grid =[[ 8882## grid 1 8883[2:----------------------------------------]|*6 8884[3:----------------------------------------]| 8885## grid 2 8886| 8887{0:~ }|*5 8888## grid 3 8889| 8890## grid 4 8891{33:┌────────────────────┐}| 8892{33:│}{19: }{1:^ }{33:│}| 8893{33:│}{19:+}{28:+-- 2 lines: ·····}{33:│}| 8894{33:│}{2:~ }{33:│}| 8895{33:└────────────────────┘}| 8896]] , 8897float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 8898win_viewport ={ 8899[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8900[ 4 ] ={ win =1001 , topline =0 , botline =4 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 8901} , 8902} 8903else 8904screen : expect { 8905grid =[[ 8906{33:┌────────────────────┐} | 8907{0:~ }{33:│}{19: }{1:^ }{33:│}{0: }| 8908{0:~ }{33:│}{19:+}{28:+-- 2 lines: ·····}{33:│}{0: }| 8909{0:~ }{33:│}{2:~ }{33:│}{0: }| 8910{0:~ }{33:└────────────────────┘}{0: }| 8911{0:~ }| 8912| 8913]] , 8914} 8915end 8916 8917if send_mouse_grid then 8918api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 2 , 1 ) 8919else 8920api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 6 ) 8921end 8922if multigrid then 8923screen : expect { 8924grid =[[ 8925## grid 1 8926[2:----------------------------------------]|*6 8927[3:----------------------------------------]| 8928## grid 2 8929| 8930{0:~ }|*5 8931## grid 3 8932| 8933## grid 4 8934{33:┌────────────────────┐}| 8935{33:│}{19: }{1:^ }{33:│}| 8936{33:│}{19:-}{1: }{33:│}| 8937{33:│}{19:│}{1: }{33:│}| 8938{33:└────────────────────┘}| 8939]] , 8940float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 5 , true , 50 , 1 , 0 , 5 } } , 8941win_viewport ={ 8942[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 8943[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =0 , curcol =0 , linecount =3 , sum_scroll_delta =0 } , 8944} , 8945} 8946else 8947screen : expect { 8948grid =[[ 8949{33:┌────────────────────┐} | 8950{0:~ }{33:│}{19: }{1:^ }{33:│}{0: }| 8951{0:~ }{33:│}{19:-}{1: }{33:│}{0: }| 8952{0:~ }{33:│}{19:│}{1: }{33:│}{0: }| 8953{0:~ }{33:└────────────────────┘}{0: }| 8954{0:~ }| 8955| 8956]] , 8957} 8958end 8959 8960if send_mouse_grid then 8961api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 2 , 2 ) 8962else 8963api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 7 ) 8964end 8965eq ( { 0 , 2 , 1 , 0 , 1 } , fn . getcurpos ()) 8966 8967if send_mouse_grid then 8968api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 2 , 3 ) 8969else 8970api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 8 ) 8971end 8972eq ( { 0 , 2 , 1 , 0 , 2 } , fn . getcurpos ()) 8973 8974if send_mouse_grid then 8975api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 2 , 11 ) 8976else 8977api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 16 ) 8978end 8979eq ( { 0 , 2 , 1 , 0 , 10 } , fn . getcurpos ()) 8980end ) 8981 8982it ( "'winblend' option" , function () 8983screen : try_resize ( 50 , 9 ) 8984screen : set_default_attr_ids ( { 8985[ 1 ] ={ background =Screen . colors . LightMagenta } , 8986[ 2 ] ={ foreground =Screen . colors . Grey0 , background =tonumber ( '0xffcfff' ) } , 8987[ 3 ] ={ foreground =tonumber ( '0xb282b2' ), background =tonumber ( '0xffcfff' ) } , 8988[ 4 ] ={ foreground =Screen . colors . Red , background =Screen . colors . LightMagenta } , 8989[ 5 ] ={ foreground =tonumber ( '0x990000' ), background =tonumber ( '0xfff1ff' ) } , 8990[ 6 ] ={ foreground =tonumber ( '0x332533' ), background =tonumber ( '0xfff1ff' ) } , 8991[ 7 ] ={ background =tonumber ( '0xffcfff' ), bold =true , foreground =tonumber ( '0x0000d8' ) } , 8992[ 8 ] ={ background =Screen . colors . LightMagenta , bold =true , foreground =Screen . colors . Blue1 } , 8993[ 9 ] ={ background =Screen . colors . LightMagenta , blend =30 } , 8994[ 10 ] ={ foreground =Screen . colors . Red , background =Screen . colors . LightMagenta , blend =0 } , 8995[ 11 ] ={ foreground =Screen . colors . Red , background =Screen . colors . LightMagenta , blend =80 } , 8996[ 12 ] ={ background =Screen . colors . LightMagenta , bold =true , foreground =Screen . colors . Blue1 , blend =30 } , 8997[ 13 ] ={ foreground =Screen . colors . Black , background =Screen . colors . LightGray , blend =30 } , 8998[ 14 ] ={ foreground =Screen . colors . Black , background =Screen . colors . Grey88 } , 8999[ 15 ] ={ foreground =tonumber ( '0x939393' ), background =Screen . colors . Grey88 } , 9000[ 16 ] ={ background =Screen . colors . Grey90 } , 9001[ 17 ] ={ blend =100 } , 9002[ 18 ] ={ background =Screen . colors . LightMagenta , blend =100 } , 9003[ 19 ] ={ background =Screen . colors . LightMagenta , bold =true , blend =100 , foreground =Screen . colors . Blue1 } , 9004[ 20 ] ={ background =Screen . colors . White , foreground =Screen . colors . Gray0 } , 9005[ 21 ] ={ background =Screen . colors . White , bold =true , foreground =tonumber ( '0x00007f' ) } , 9006[ 22 ] ={ background =Screen . colors . Gray90 , foreground =Screen . colors . Gray0 } , 9007[ 23 ] ={ blend =100 , bold =true , foreground =Screen . colors . Magenta } , 9008[ 24 ] ={ foreground =tonumber ( '0x7f007f' ), bold =true , background =Screen . colors . White } , 9009[ 25 ] ={ foreground =tonumber ( '0x7f007f' ), bold =true , background =Screen . colors . Grey90 } , 9010[ 26 ] ={ foreground =Screen . colors . Black } , 9011[ 27 ] ={ bold =true , foreground =tonumber ( '0x7f007f' ) } , 9012[ 28 ] ={ foreground =tonumber ( '0x990000' ) } , 9013[ 29 ] ={ foreground =Screen . colors . Gray20 } , 9014[ 30 ] ={ bold =true , foreground =tonumber ( '0x00007f' ) } , 9015[ 31 ] ={ foreground =Screen . colors . Red , blend =80 } , 9016[ 32 ] ={ foreground =Screen . colors . Blue1 , blend =100 , bold =true } , 9017[ 33 ] ={ foreground =Screen . colors . Gray0 , underline =true } , 9018[ 34 ] ={ underline =true } , 9019[ 35 ] ={ foreground =Screen . colors . Black , underline =true , special =Screen . colors . Red } , 9020[ 36 ] ={ special =Screen . colors . Red , underline =true } , 9021} ) 9022insert ( [[ 9023Lorem ipsum dolor sit amet, consectetur 9024adipisicing elit, sed do eiusmod tempor 9025incididunt ut labore et dolore magna aliqua. 9026Ut enim ad minim veniam, quis nostrud 9027exercitation ullamco laboris nisi ut aliquip ex 9028ea commodo consequat. Duis aute irure dolor in 9029reprehenderit in voluptate velit esse cillum 9030dolore eu fugiat nulla pariatur. Excepteur sint 9031occaecat cupidatat non proident, sunt in culpa 9032qui officia deserunt mollit anim id est 9033laborum.]] ) 9034local curbufnr =api . nvim_get_current_buf () 9035local buf =api . nvim_create_buf ( false , false ) 9036local test_data ={ 'test' , '' , 'popup text' } 9037api . nvim_buf_set_lines ( buf , 0 , - 1 , true , test_data ) 9038local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =15 , height =3 , row =2 , col =5 } ) 9039if multigrid then 9040screen : expect { 9041grid =[[ 9042## grid 1 9043[2:--------------------------------------------------]|*8 9044[3:--------------------------------------------------]| 9045## grid 2 9046Ut enim ad minim veniam, quis nostrud | 9047exercitation ullamco laboris nisi ut aliquip ex | 9048ea commodo consequat. Duis aute irure dolor in | 9049reprehenderit in voluptate velit esse cillum | 9050dolore eu fugiat nulla pariatur. Excepteur sint | 9051occaecat cupidatat non proident, sunt in culpa | 9052qui officia deserunt mollit anim id est | 9053laborum^. | 9054## grid 3 9055| 9056## grid 4 9057{1:test }| 9058{1: }| 9059{1:popup text }| 9060]] , 9061float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 9062} 9063else 9064screen : expect ( [[ 9065Ut enim ad minim veniam, quis nostrud | 9066exercitation ullamco laboris nisi ut aliquip ex | 9067ea co{1:test }. Duis aute irure dolor in | 9068repre{1: }uptate velit esse cillum | 9069dolor{1:popup text }la pariatur. Excepteur sint | 9070occaecat cupidatat non proident, sunt in culpa | 9071qui officia deserunt mollit anim id est | 9072laborum^. | 9073| 9074]] ) 9075end 9076 9077api . nvim_set_option_value ( 'winblend' , 30 , { win =win } ) 9078if multigrid then 9079screen : expect { 9080grid =[[ 9081## grid 1 9082[2:--------------------------------------------------]|*8 9083[3:--------------------------------------------------]| 9084## grid 2 9085Ut enim ad minim veniam, quis nostrud | 9086exercitation ullamco laboris nisi ut aliquip ex | 9087ea commodo consequat. Duis aute irure dolor in | 9088reprehenderit in voluptate velit esse cillum | 9089dolore eu fugiat nulla pariatur. Excepteur sint | 9090occaecat cupidatat non proident, sunt in culpa | 9091qui officia deserunt mollit anim id est | 9092laborum^. | 9093## grid 3 9094| 9095## grid 4 9096{9:test }| 9097{9: }| 9098{9:popup text }| 9099]] , 9100float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 9101unchanged =true , 9102} 9103else 9104screen : expect ( [[ 9105Ut enim ad minim veniam, quis nostrud | 9106exercitation ullamco laboris nisi ut aliquip ex | 9107ea co{2:test}{3:o consequat}. Duis aute irure dolor in | 9108repre{3:henderit in vol}uptate velit esse cillum | 9109dolor{2:popup}{3:fugi}{2:text}{3:ul}la pariatur. Excepteur sint | 9110occaecat cupidatat non proident, sunt in culpa | 9111qui officia deserunt mollit anim id est | 9112laborum^. | 9113| 9114]] ) 9115end 9116 9117-- Treat for \u2800 (braille blank) as whitespace. 9118local braille_blank ='\226\160\128' 9119api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'test' .. braille_blank , '' , 'popup' .. braille_blank .. ' text' } ) 9120if multigrid then 9121screen : expect { 9122grid =[[ 9123## grid 1 9124[2:--------------------------------------------------]|*8 9125[3:--------------------------------------------------]| 9126## grid 2 9127Ut enim ad minim veniam, quis nostrud | 9128exercitation ullamco laboris nisi ut aliquip ex | 9129ea commodo consequat. Duis aute irure dolor in | 9130reprehenderit in voluptate velit esse cillum | 9131dolore eu fugiat nulla pariatur. Excepteur sint | 9132occaecat cupidatat non proident, sunt in culpa | 9133qui officia deserunt mollit anim id est | 9134laborum^. | 9135## grid 3 9136| 9137## grid 4 9138{9:test]] .. braille_blank .. [[ }| 9139{9: }| 9140{9:popup]] .. braille_blank .. [[ text }| 9141]] , 9142float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 9143unchanged =true , 9144} 9145else 9146screen : expect_unchanged () 9147end 9148api . nvim_buf_set_lines ( buf , 0 , - 1 , true , test_data ) 9149 9150-- Check that 'winblend' works with NormalNC highlight 9151api . nvim_set_option_value ( 'winhighlight' , 'NormalNC:Visual' , { win =win } ) 9152if multigrid then 9153screen : expect { 9154grid =[[ 9155## grid 1 9156[2:--------------------------------------------------]|*8 9157[3:--------------------------------------------------]| 9158## grid 2 9159Ut enim ad minim veniam, quis nostrud | 9160exercitation ullamco laboris nisi ut aliquip ex | 9161ea commodo consequat. Duis aute irure dolor in | 9162reprehenderit in voluptate velit esse cillum | 9163dolore eu fugiat nulla pariatur. Excepteur sint | 9164occaecat cupidatat non proident, sunt in culpa | 9165qui officia deserunt mollit anim id est | 9166laborum^. | 9167## grid 3 9168| 9169## grid 4 9170{13:test }| 9171{13: }| 9172{13:popup text }| 9173]] , 9174float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 9175} 9176else 9177screen : expect ( [[ 9178Ut enim ad minim veniam, quis nostrud | 9179exercitation ullamco laboris nisi ut aliquip ex | 9180ea co{14:test}{15:o consequat}. Duis aute irure dolor in | 9181repre{15:henderit in vol}uptate velit esse cillum | 9182dolor{14:popup}{15:fugi}{14:text}{15:ul}la pariatur. Excepteur sint | 9183occaecat cupidatat non proident, sunt in culpa | 9184qui officia deserunt mollit anim id est | 9185laborum^. | 9186| 9187]] ) 9188end 9189 9190-- Also test with global NormalNC highlight 9191exec_lua ( 9192[[ 9193vim.api.nvim_set_option_value('winhighlight', '', {win = ...}) 9194vim.api.nvim_set_hl(0, 'NormalNC', {link = 'Visual'}) 9195]] , 9196win 9197) 9198screen : expect_unchanged () 9199command ( 'hi clear NormalNC' ) 9200 9201command ( 'hi SpecialRegion guifg=Red blend=0' ) 9202api . nvim_buf_add_highlight ( buf , - 1 , 'SpecialRegion' , 2 , 0 , - 1 ) 9203if multigrid then 9204screen : expect { 9205grid =[[ 9206## grid 1 9207[2:--------------------------------------------------]|*8 9208[3:--------------------------------------------------]| 9209## grid 2 9210Ut enim ad minim veniam, quis nostrud | 9211exercitation ullamco laboris nisi ut aliquip ex | 9212ea commodo consequat. Duis aute irure dolor in | 9213reprehenderit in voluptate velit esse cillum | 9214dolore eu fugiat nulla pariatur. Excepteur sint | 9215occaecat cupidatat non proident, sunt in culpa | 9216qui officia deserunt mollit anim id est | 9217laborum^. | 9218## grid 3 9219| 9220## grid 4 9221{9:test }| 9222{9: }| 9223{10:popup text}{9: }| 9224]] , 9225float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 9226} 9227else 9228screen : expect ( [[ 9229Ut enim ad minim veniam, quis nostrud | 9230exercitation ullamco laboris nisi ut aliquip ex | 9231ea co{2:test}{3:o consequat}. Duis aute irure dolor in | 9232repre{3:henderit in vol}uptate velit esse cillum | 9233dolor{10:popup text}{3:ul}la pariatur. Excepteur sint | 9234occaecat cupidatat non proident, sunt in culpa | 9235qui officia deserunt mollit anim id est | 9236laborum^. | 9237| 9238]] ) 9239end 9240 9241command ( 'hi SpecialRegion guifg=Red blend=80' ) 9242if multigrid then 9243screen : expect { 9244grid =[[ 9245## grid 1 9246[2:--------------------------------------------------]|*8 9247[3:--------------------------------------------------]| 9248## grid 2 9249Ut enim ad minim veniam, quis nostrud | 9250exercitation ullamco laboris nisi ut aliquip ex | 9251ea commodo consequat. Duis aute irure dolor in | 9252reprehenderit in voluptate velit esse cillum | 9253dolore eu fugiat nulla pariatur. Excepteur sint | 9254occaecat cupidatat non proident, sunt in culpa | 9255qui officia deserunt mollit anim id est | 9256laborum^. | 9257## grid 3 9258| 9259## grid 4 9260{9:test }| 9261{9: }| 9262{11:popup text}{9: }| 9263]] , 9264float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 9265unchanged =true , 9266} 9267else 9268screen : expect ( [[ 9269Ut enim ad minim veniam, quis nostrud | 9270exercitation ullamco laboris nisi ut aliquip ex | 9271ea co{2:test}{3:o consequat}. Duis aute irure dolor in | 9272repre{3:henderit in vol}uptate velit esse cillum | 9273dolor{5:popup}{6:fugi}{5:text}{3:ul}la pariatur. Excepteur sint | 9274occaecat cupidatat non proident, sunt in culpa | 9275qui officia deserunt mollit anim id est | 9276laborum^. | 9277| 9278]] ) 9279end 9280 9281-- Test scrolling by mouse 9282if send_mouse_grid then 9283api . nvim_input_mouse ( 'wheel' , 'down' , '' , 4 , 2 , 2 ) 9284else 9285api . nvim_input_mouse ( 'wheel' , 'down' , '' , 0 , 4 , 7 ) 9286end 9287if multigrid then 9288screen : expect { 9289grid =[[ 9290## grid 1 9291[2:--------------------------------------------------]|*8 9292[3:--------------------------------------------------]| 9293## grid 2 9294Ut enim ad minim veniam, quis nostrud | 9295exercitation ullamco laboris nisi ut aliquip ex | 9296ea commodo consequat. Duis aute irure dolor in | 9297reprehenderit in voluptate velit esse cillum | 9298dolore eu fugiat nulla pariatur. Excepteur sint | 9299occaecat cupidatat non proident, sunt in culpa | 9300qui officia deserunt mollit anim id est | 9301laborum^. | 9302## grid 3 9303| 9304## grid 4 9305{11:popup text}{9: }| 9306{12:~ }|*2 9307]] , 9308float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 9309} 9310else 9311screen : expect ( [[ 9312Ut enim ad minim veniam, quis nostrud | 9313exercitation ullamco laboris nisi ut aliquip ex | 9314ea co{5:popup}{6: con}{5:text}{3:at}. Duis aute irure dolor in | 9315repre{7:~}{3:enderit in vol}uptate velit esse cillum | 9316dolor{7:~}{3: eu fugiat nul}la pariatur. Excepteur sint | 9317occaecat cupidatat non proident, sunt in culpa | 9318qui officia deserunt mollit anim id est | 9319laborum^. | 9320| 9321]] ) 9322end 9323 9324-- Check that 'winblend' applies to border/title/footer 9325api . nvim_win_set_config ( win , { border ='single' , title ='Title' , footer ='Footer' } ) 9326api . nvim_set_option_value ( 'winblend' , 100 , { win =win } ) 9327api . nvim_set_option_value ( 'cursorline' , true , { win =0 } ) 9328-- 'winblend' with transparent background. #18576 9329command ( 'hi clear VertSplit | hi Normal guibg=NONE ctermbg=NONE' ) 9330api . nvim_win_set_option ( win , 'winhighlight' , 'Normal:Normal' ) 9331feed ( 'k0' ) 9332if multigrid then 9333screen : expect ( { 9334grid =[[ 9335## grid 1 9336[2:--------------------------------------------------]|*8 9337[3:--------------------------------------------------]| 9338## grid 2 9339Ut enim ad minim veniam, quis nostrud | 9340exercitation ullamco laboris nisi ut aliquip ex | 9341ea commodo consequat. Duis aute irure dolor in | 9342reprehenderit in voluptate velit esse cillum | 9343dolore eu fugiat nulla pariatur. Excepteur sint | 9344occaecat cupidatat non proident, sunt in culpa | 9345{16:^qui officia deserunt mollit anim id est }| 9346laborum. | 9347## grid 3 9348| 9349## grid 4 9350{17:┌}{23:Title}{17:──────────┐}| 9351{17:│}{31:popup text}{17: │}| 9352{17:│}{32:~ }{17:│}|*2 9353{17:└}{23:Footer}{17:─────────┘}| 9354]] , 9355win_pos ={ [ 2 ] ={ height =8 , startcol =0 , startrow =0 , width =50 , win =1000 } } , 9356float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 9357win_viewport ={ 9358[ 2 ] ={ win =1000 , topline =3 , botline =11 , curline =9 , curcol =0 , linecount =11 , sum_scroll_delta =3 } , 9359[ 4 ] ={ win =1001 , topline =2 , botline =4 , curline =2 , curcol =7 , linecount =3 , sum_scroll_delta =2 } , 9360} , 9361win_viewport_margins ={ 9362[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 9363[ 4 ] ={ bottom =1 , left =1 , right =1 , top =1 , win =1001 } , 9364} , 9365} ) 9366else 9367screen : expect ( [[ 9368Ut enim ad minim veniam, quis nostrud | 9369exercitation ullamco laboris nisi ut aliquip ex | 9370ea co{26:┌}{27:Title}{26:──────────┐}Duis aute irure dolor in | 9371repre{26:│}{28:popup}{29:it i}{28:text}{26:lu│}tate velit esse cillum | 9372dolor{26:│}{30:~}{26:eu fugiat null│} pariatur. Excepteur sint | 9373occae{26:│}{30:~}{26:t cupidatat no│} proident, sunt in culpa | 9374{16:^qui o}{22:└}{25:Footer}{22:─────────┘}{16:ollit anim id est }| 9375laborum. | 9376| 9377]] ) 9378end 9379 9380-- winblend underline: without guisp follows the fg (#14453), with guisp keeps its sp (#34614). 9381command ( 'fclose | hi TestUnderLine gui=underline | hi TestUnderLineSp gui=underline guisp=Red' ) 9382api . nvim_buf_add_highlight ( curbufnr , - 1 , 'TestUnderLine' , 3 , 0 , - 1 ) 9383api . nvim_buf_add_highlight ( curbufnr , - 1 , 'TestUnderLineSp' , 4 , 0 , - 1 ) 9384api . nvim_buf_set_lines ( buf , 0 , - 1 , false , { '' , '' } ) 9385api . nvim_open_win ( buf , false , { relative ='win' , row =0 , col =0 , width =50 , height =2 } ) 9386if multigrid then 9387screen : expect ( { 9388grid =[[ 9389## grid 1 9390[2:--------------------------------------------------]|*8 9391[3:--------------------------------------------------]| 9392## grid 2 9393{34:Ut enim ad minim veniam, quis nostrud} | 9394{36:exercitation ullamco laboris nisi ut aliquip ex} | 9395ea commodo consequat. Duis aute irure dolor in | 9396reprehenderit in voluptate velit esse cillum | 9397dolore eu fugiat nulla pariatur. Excepteur sint | 9398occaecat cupidatat non proident, sunt in culpa | 9399{16:^qui officia deserunt mollit anim id est }| 9400laborum. | 9401## grid 3 9402| 9403## grid 5 9404{17: }|*2 9405]] , 9406win_pos ={ [ 2 ] ={ height =8 , startcol =0 , startrow =0 , width =50 , win =1000 } } , 9407float_pos ={ [ 5 ] ={ 1002 , 'NW' , 2 , 0 , 0 , true , 50 , 1 , 0 , 0 } } , 9408win_viewport ={ 9409[ 2 ] ={ win =1000 , topline =3 , botline =11 , curline =9 , curcol =0 , linecount =11 , sum_scroll_delta =3 } , 9410[ 5 ] ={ win =1002 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =2 , sum_scroll_delta =0 } , 9411} , 9412win_viewport_margins ={ 9413[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 9414[ 5 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1002 } , 9415} , 9416} ) 9417else 9418screen : expect ( [[ 9419{33:Ut enim ad minim veniam, quis nostrud}{26: }| 9420{35:exercitation ullamco laboris nisi ut aliquip ex}{26: }| 9421ea commodo consequat. Duis aute irure dolor in | 9422reprehenderit in voluptate velit esse cillum | 9423dolore eu fugiat nulla pariatur. Excepteur sint | 9424occaecat cupidatat non proident, sunt in culpa | 9425{16:^qui officia deserunt mollit anim id est }| 9426laborum. | 9427| 9428]] ) 9429end 9430end ) 9431 9432it ( 'can overlap doublewidth chars' , function () 9433insert ( [[ 9434# TODO: 测试字典信息的准确性 9435# FIXME: 测试字典信息的准确性]] ) 9436local buf =api . nvim_create_buf ( false , false ) 9437api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { '口' , '口' } ) 9438local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =5 , height =3 , row =0 , col =11 , style ='minimal' } ) 9439if multigrid then 9440screen : expect { 9441grid =[[ 9442## grid 1 9443[2:----------------------------------------]|*6 9444[3:----------------------------------------]| 9445## grid 2 9446# TODO: 测试字典信息的准确性 | 9447# FIXME: 测试字典信息的准确^性 | 9448{0:~ }|*4 9449## grid 3 9450| 9451## grid 4 9452{1:口 }|*2 9453{1: }| 9454]] , 9455float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 11 , true , 50 , 1 , 0 , 11 } } , 9456} 9457else 9458screen : expect ( [[ 9459# TODO: 测 {1:口 }信息的准确性 | 9460# FIXME: 测{1:口 } 信息的准确^性 | 9461{0:~ }{1: }{0: }| 9462{0:~ }|*3 9463| 9464]] ) 9465end 9466 9467api . nvim_win_close ( win , false ) 9468if multigrid then 9469screen : expect ( [[ 9470## grid 1 9471[2:----------------------------------------]|*6 9472[3:----------------------------------------]| 9473## grid 2 9474# TODO: 测试字典信息的准确性 | 9475# FIXME: 测试字典信息的准确^性 | 9476{0:~ }|*4 9477## grid 3 9478| 9479]] ) 9480else 9481screen : expect ( [[ 9482# TODO: 测试字典信息的准确性 | 9483# FIXME: 测试字典信息的准确^性 | 9484{0:~ }|*4 9485| 9486]] ) 9487end 9488 9489-- The interaction between 'winblend' and doublewidth chars in the background 9490-- does not look very good. But check no chars get incorrectly placed 9491-- at least. Also check invisible EndOfBuffer region blends correctly. 9492api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { ' x x x xx' , ' x x x x' } ) 9493win =api . nvim_open_win ( buf , false , { relative ='editor' , width =12 , height =3 , row =0 , col =11 , style ='minimal' } ) 9494api . nvim_set_option_value ( 'winblend' , 30 , { win =win } ) 9495screen : set_default_attr_ids ( { 9496[ 1 ] ={ foreground =tonumber ( '0xb282b2' ), background =tonumber ( '0xffcfff' ) } , 9497[ 2 ] ={ foreground =Screen . colors . Grey0 , background =tonumber ( '0xffcfff' ) } , 9498[ 3 ] ={ bold =true , foreground =Screen . colors . Blue1 } , 9499[ 4 ] ={ background =tonumber ( '0xffcfff' ), bold =true , foreground =tonumber ( '0xb282ff' ) } , 9500[ 5 ] ={ background =Screen . colors . LightMagenta , blend =30 } , 9501} ) 9502if multigrid then 9503screen : expect { 9504grid =[[ 9505## grid 1 9506[2:----------------------------------------]|*6 9507[3:----------------------------------------]| 9508## grid 2 9509# TODO: 测试字典信息的准确性 | 9510# FIXME: 测试字典信息的准确^性 | 9511{3:~ }|*4 9512## grid 3 9513| 9514## grid 5 9515{5: x x x xx}| 9516{5: x x x x}| 9517{5: }| 9518]] , 9519float_pos ={ [ 5 ] ={ 1002 , 'NW' , 1 , 0 , 11 , true , 50 , 1 , 0 , 11 } } , 9520} 9521else 9522screen : expect ( [[ 9523# TODO: 测 {2: x x x}{1:息}{2: xx} 确性 | 9524# FIXME: 测{1:试}{2:x x x}{1:息}{2: x}准确^性 | 9525{3:~ }{4: }{3: }| 9526{3:~ }|*3 9527| 9528]] ) 9529end 9530 9531api . nvim_win_set_config ( win , { relative ='editor' , row =0 , col =12 } ) 9532if multigrid then 9533screen : expect { 9534grid =[[ 9535## grid 1 9536[2:----------------------------------------]|*6 9537[3:----------------------------------------]| 9538## grid 2 9539# TODO: 测试字典信息的准确性 | 9540# FIXME: 测试字典信息的准确^性 | 9541{3:~ }|*4 9542## grid 3 9543| 9544## grid 5 9545{5: x x x xx}| 9546{5: x x x x}| 9547{5: }| 9548]] , 9549float_pos ={ [ 5 ] ={ 1002 , 'NW' , 1 , 0 , 12 , true , 50 , 1 , 0 , 12 } } , 9550} 9551else 9552screen : expect ( [[ 9553# TODO: 测试{2: x x}{1:信}{2:x }{1:的}{2:xx}确性 | 9554# FIXME: 测 {2: x x}{1:信}{2:x }{1:的}{2:x} 确^性 | 9555{3:~ }{4: }{3: }| 9556{3:~ }|*3 9557| 9558]] ) 9559end 9560end ) 9561 9562it ( 'correctly redraws when overlaid windows are resized #13991' , function () 9563n . source ( [[ 9564let popup_config = {"relative" : "editor", 9565\ "width" : 7, 9566\ "height" : 3, 9567\ "row" : 1, 9568\ "col" : 1, 9569\ "style" : "minimal"} 9570 9571let border_config = {"relative" : "editor", 9572\ "width" : 9, 9573\ "height" : 5, 9574\ "row" : 0, 9575\ "col" : 0, 9576\ "style" : "minimal"} 9577 9578let popup_buffer = nvim_create_buf(v:false, v:true) 9579let border_buffer = nvim_create_buf(v:false, v:true) 9580let popup_win = nvim_open_win(popup_buffer, v:true, popup_config) 9581let border_win = nvim_open_win(border_buffer, v:false, border_config) 9582 9583call nvim_buf_set_lines(popup_buffer, 0, -1, v:true, 9584\ ["long", "longer", "longest"]) 9585 9586call nvim_buf_set_lines(border_buffer, 0, -1, v:true, 9587\ ["---------", "- -", "- -"]) 9588]] ) 9589 9590if multigrid then 9591screen : expect { 9592grid =[[ 9593## grid 1 9594[2:----------------------------------------]|*6 9595[3:----------------------------------------]| 9596## grid 2 9597| 9598{1:~ }|*5 9599## grid 3 9600| 9601## grid 4 9602{2:^long }| 9603{2:longer }| 9604{2:longest}| 9605## grid 5 9606{2:---------}| 9607{2:- -}|*2 9608{2: }|*2 9609]] , 9610attr_ids ={ 9611[ 1 ] ={ foreground =Screen . colors . Blue1 , bold =true } , 9612[ 2 ] ={ background =Screen . colors . LightMagenta } , 9613} , 9614float_pos ={ 9615[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 2 , 1 , 1 } , 9616[ 5 ] ={ 1002 , 'NW' , 1 , 0 , 0 , true , 50 , 1 , 0 , 0 } , 9617} , 9618} 9619else 9620screen : expect ( [[ 9621{1:---------} | 9622{1:-^long -}{0: }| 9623{1:-longer -}{0: }| 9624{1: longest }{0: }| 9625{1: }{0: }| 9626{0:~ }| 9627| 9628]] ) 9629end 9630 9631n . source ( [[ 9632let new_popup_config = {"width" : 1, "height" : 3} 9633let new_border_config = {"width" : 3, "height" : 5} 9634 9635function! Resize() 9636call nvim_win_set_config(g:popup_win, g:new_popup_config) 9637call nvim_win_set_config(g:border_win, g:new_border_config) 9638 9639call nvim_buf_set_lines(g:border_buffer, 0, -1, v:true, 9640\ ["---", "- -", "- -"]) 9641endfunction 9642 9643nnoremap zz <cmd>call Resize()<cr> 9644]] ) 9645 9646n . feed ( 'zz' ) 9647if multigrid then 9648screen : expect { 9649grid =[[ 9650## grid 1 9651[2:----------------------------------------]|*6 9652[3:----------------------------------------]| 9653## grid 2 9654| 9655{1:~ }|*5 9656## grid 3 9657| 9658## grid 4 9659{2:^l}| 9660{2:o}| 9661{2:n}| 9662## grid 5 9663{2:---}| 9664{2:- -}|*2 9665{2: }|*2 9666]] , 9667attr_ids ={ 9668[ 1 ] ={ foreground =Screen . colors . Blue1 , bold =true } , 9669[ 2 ] ={ background =Screen . colors . LightMagenta } , 9670} , 9671float_pos ={ 9672[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 2 , 1 , 1 } , 9673[ 5 ] ={ 1002 , 'NW' , 1 , 0 , 0 , true , 50 , 1 , 0 , 0 } , 9674} , 9675} 9676else 9677screen : expect ( [[ 9678{1:---} | 9679{1:-^l-}{0: }| 9680{1:-o-}{0: }| 9681{1: n }{0: }| 9682{1: }{0: }| 9683{0:~ }| 9684| 9685]] ) 9686end 9687end ) 9688 9689it ( 'correctly orders multiple opened floats (current last)' , function () 9690local buf =api . nvim_create_buf ( false , false ) 9691local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =2 , row =2 , col =5 } ) 9692api . nvim_set_option_value ( 'winhl' , 'Normal:ErrorMsg,EndOfBuffer:ErrorMsg' , { win =win } ) 9693 9694if multigrid then 9695screen : expect { 9696grid =[[ 9697## grid 1 9698[2:----------------------------------------]|*6 9699[3:----------------------------------------]| 9700## grid 2 9701^ | 9702{0:~ }|*5 9703## grid 3 9704| 9705## grid 4 9706{7: }| 9707{7:~ }| 9708]] , 9709float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 9710win_viewport ={ 9711[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9712[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9713} , 9714} 9715else 9716screen : expect { 9717grid =[[ 9718^ | 9719{0:~ }| 9720{0:~ }{7: }{0: }| 9721{0:~ }{7:~ }{0: }| 9722{0:~ }|*2 9723| 9724]] , 9725} 9726end 9727 9728exec_lua [[ 9729local buf = vim.api.nvim_create_buf(false,false) 9730local win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8}) 9731vim.wo[win].winhl = "EndOfBuffer:Normal" 9732buf = vim.api.nvim_create_buf(false,false) 9733win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10}) 9734vim.wo[win].winhl = "Normal:Search,EndOfBuffer:Search" 9735]] 9736 9737if multigrid then 9738screen : expect { 9739grid =[[ 9740## grid 1 9741[2:----------------------------------------]|*6 9742[3:----------------------------------------]| 9743## grid 2 9744| 9745{0:~ }|*5 9746## grid 3 9747| 9748## grid 4 9749{7: }| 9750{7:~ }| 9751## grid 5 9752{1: }| 9753{1:~ }| 9754## grid 6 9755{17:^ }| 9756{17:~ }| 9757]] , 9758float_pos ={ 9759[ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } , 9760[ 5 ] ={ 1002 , 'NW' , 1 , 3 , 8 , true , 50 , 2 , 3 , 8 } , 9761[ 6 ] ={ 1003 , 'NW' , 1 , 4 , 10 , true , 50 , 3 , 4 , 10 } , 9762} , 9763win_viewport ={ 9764[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9765[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9766[ 5 ] ={ win =1002 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9767[ 6 ] ={ win =1003 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9768} , 9769} 9770else 9771screen : expect { 9772grid =[[ 9773| 9774{0:~ }| 9775{0:~ }{7: }{0: }| 9776{0:~ }{7:~ }{1: }{7: }{0: }| 9777{0:~ }{1:~ }{17:^ }{1: }{0: }| 9778{0:~ }{17:~ }{0: }| 9779| 9780]] , 9781} 9782end 9783 9784-- This should bring win into focus on top 9785api . nvim_set_current_win ( win ) 9786if multigrid then 9787screen : expect ( { 9788grid =[[ 9789## grid 1 9790[2:----------------------------------------]|*6 9791[3:----------------------------------------]| 9792## grid 2 9793| 9794{0:~ }|*5 9795## grid 3 9796| 9797## grid 4 9798{7:^ }| 9799{7:~ }| 9800## grid 5 9801{1: }| 9802{1:~ }| 9803## grid 6 9804{17: }| 9805{17:~ }| 9806]] , 9807win_pos ={ [ 2 ] ={ height =6 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 9808float_pos ={ 9809[ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 3 , 2 , 5 } , 9810[ 5 ] ={ 1002 , 'NW' , 1 , 3 , 8 , true , 50 , 1 , 3 , 8 } , 9811[ 6 ] ={ 1003 , 'NW' , 1 , 4 , 10 , true , 50 , 2 , 4 , 10 } , 9812} , 9813win_viewport ={ 9814[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9815[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9816[ 5 ] ={ win =1002 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9817[ 6 ] ={ win =1003 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9818} , 9819} ) 9820else 9821screen : expect ( [[ 9822| 9823{0:~ }| 9824{0:~ }{7:^ }{0: }| 9825{0:~ }{7:~ }{0: }| 9826{0:~ }{1:~ }{17: }{1: }{0: }| 9827{0:~ }{17:~ }{0: }| 9828| 9829]] ) 9830end 9831end ) 9832 9833it ( 'correctly orders multiple opened floats (non-current last)' , function () 9834local buf =api . nvim_create_buf ( false , false ) 9835local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =2 , row =2 , col =5 } ) 9836api . nvim_set_option_value ( 'winhl' , 'Normal:ErrorMsg,EndOfBuffer:ErrorMsg' , { win =win } ) 9837 9838if multigrid then 9839screen : expect { 9840grid =[[ 9841## grid 1 9842[2:----------------------------------------]|*6 9843[3:----------------------------------------]| 9844## grid 2 9845^ | 9846{0:~ }|*5 9847## grid 3 9848| 9849## grid 4 9850{7: }| 9851{7:~ }| 9852]] , 9853float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } } , 9854win_viewport ={ 9855[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9856[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9857} , 9858} 9859else 9860screen : expect { 9861grid =[[ 9862^ | 9863{0:~ }| 9864{0:~ }{7: }{0: }| 9865{0:~ }{7:~ }{0: }| 9866{0:~ }|*2 9867| 9868]] , 9869} 9870end 9871 9872exec_lua [[ 9873local buf = vim.api.nvim_create_buf(false,false) 9874local win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10}) 9875vim.wo[win].winhl = "Normal:Search,EndOfBuffer:Search" 9876buf = vim.api.nvim_create_buf(false,false) 9877win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8}) 9878vim.wo[win].winhl = "EndOfBuffer:Normal" 9879]] 9880 9881if multigrid then 9882screen : expect { 9883grid =[[ 9884## grid 1 9885[2:----------------------------------------]|*6 9886[3:----------------------------------------]| 9887## grid 2 9888| 9889{0:~ }|*5 9890## grid 3 9891| 9892## grid 4 9893{7: }| 9894{7:~ }| 9895## grid 5 9896{17:^ }| 9897{17:~ }| 9898## grid 6 9899{1: }| 9900{1:~ }| 9901]] , 9902float_pos ={ 9903[ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } , 9904[ 5 ] ={ 1002 , 'NW' , 1 , 4 , 10 , true , 50 , 3 , 4 , 10 } , 9905[ 6 ] ={ 1003 , 'NW' , 1 , 3 , 8 , true , 50 , 2 , 3 , 8 } , 9906} , 9907win_viewport ={ 9908[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9909[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9910[ 5 ] ={ win =1002 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9911[ 6 ] ={ win =1003 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9912} , 9913} 9914else 9915screen : expect { 9916grid =[[ 9917| 9918{0:~ }| 9919{0:~ }{7: }{0: }| 9920{0:~ }{7:~ }{1: }{7: }{0: }| 9921{0:~ }{1:~ }{17:^ }{1: }{0: }| 9922{0:~ }{17:~ }{0: }| 9923| 9924]] , 9925} 9926end 9927 9928-- This should bring win into focus on top 9929api . nvim_set_current_win ( win ) 9930if multigrid then 9931screen : expect ( { 9932grid =[[ 9933## grid 1 9934[2:----------------------------------------]|*6 9935[3:----------------------------------------]| 9936## grid 2 9937| 9938{0:~ }|*5 9939## grid 3 9940| 9941## grid 4 9942{7:^ }| 9943{7:~ }| 9944## grid 5 9945{17: }| 9946{17:~ }| 9947## grid 6 9948{1: }| 9949{1:~ }| 9950]] , 9951win_pos ={ [ 2 ] ={ height =6 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 9952float_pos ={ 9953[ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 3 , 2 , 5 } , 9954[ 5 ] ={ 1002 , 'NW' , 1 , 4 , 10 , true , 50 , 2 , 4 , 10 } , 9955[ 6 ] ={ 1003 , 'NW' , 1 , 3 , 8 , true , 50 , 1 , 3 , 8 } , 9956} , 9957win_viewport ={ 9958[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9959[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9960[ 5 ] ={ win =1002 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9961[ 6 ] ={ win =1003 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 9962} , 9963} ) 9964else 9965screen : expect ( [[ 9966| 9967{0:~ }| 9968{0:~ }{7:^ }{0: }| 9969{0:~ }{7:~ }{0: }| 9970{0:~ }{1:~ }{17: }{1: }{0: }| 9971{0:~ }{17:~ }{0: }| 9972| 9973]] ) 9974end 9975end ) 9976 9977it ( 'can use z-index' , function () 9978local buf =api . nvim_create_buf ( false , false ) 9979local win1 =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =3 , row =1 , col =5 , zindex =30 } ) 9980api . nvim_set_option_value ( 'winhl' , 'Normal:ErrorMsg,EndOfBuffer:ErrorMsg' , { win =win1 } ) 9981local win2 =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =3 , row =2 , col =6 , zindex =50 } ) 9982api . nvim_set_option_value ( 'winhl' , 'Normal:Search,EndOfBuffer:Search' , { win =win2 } ) 9983local win3 =api . nvim_open_win ( buf , false , { relative ='editor' , width =20 , height =3 , row =3 , col =7 , zindex =40 } ) 9984api . nvim_set_option_value ( 'winhl' , 'Normal:Question,EndOfBuffer:Question' , { win =win3 } ) 9985 9986if multigrid then 9987screen : expect { 9988grid =[[ 9989## grid 1 9990[2:----------------------------------------]|*6 9991[3:----------------------------------------]| 9992## grid 2 9993^ | 9994{0:~ }|*5 9995## grid 3 9996| 9997## grid 4 9998{7: }| 9999{7:~ }|*2 10000## grid 5 10001{17: }| 10002{17:~ }|*2 10003## grid 6 10004{8: }| 10005{8:~ }|*2 10006]] , 10007float_pos ={ 10008[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 5 , true , 30 , 1 , 1 , 5 } , 10009[ 5 ] ={ 1002 , 'NW' , 1 , 2 , 6 , true , 50 , 3 , 2 , 6 } , 10010[ 6 ] ={ 1003 , 'NW' , 1 , 3 , 7 , true , 40 , 2 , 3 , 7 } , 10011} , 10012win_viewport ={ 10013[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10014[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10015[ 5 ] ={ win =1002 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10016[ 6 ] ={ win =1003 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10017} , 10018} 10019else 10020screen : expect { 10021grid =[[ 10022^ | 10023{0:~ }{7: }{0: }| 10024{0:~ }{7:~}{17: }{0: }| 10025{0:~ }{7:~}{17:~ }{8: }{0: }| 10026{0:~ }{17:~ }{8: }{0: }| 10027{0:~ }{8:~ }{0: }| 10028| 10029]] , 10030} 10031end 10032 10033-- 10034-- Check that floats are positioned correctly after changing the zindexes. 10035-- 10036command ( 'fclose' ) 10037exec_lua ( 10038[[ 10039local win1, win3 = ... 10040vim.api.nvim_win_set_config(win1, { zindex = 400, title = 'win_400', title_pos = 'center', border = 'double' }) 10041vim.api.nvim_win_set_config(win3, { zindex = 300, title = 'win_300', title_pos = 'center', border = 'single' }) 10042]] , 10043win1 , 10044win3 10045) 10046if multigrid then 10047screen : expect ( { 10048grid =[[ 10049## grid 1 10050[2:----------------------------------------]|*6 10051[3:----------------------------------------]| 10052## grid 2 10053^ | 10054{0:~ }|*5 10055## grid 3 10056| 10057## grid 4 10058{35:╔══════}{36:win_400}{35:═══════╗}| 10059{35:║}{7: }{35:║}| 10060{35:║}{7:~ }{35:║}|*2 10061{35:╚════════════════════╝}| 10062## grid 6 10063{37:┌──────}{34:win_300}{37:───────┐}| 10064{37:│}{8: }{37:│}| 10065{37:│}{8:~ }{37:│}|*2 10066{37:└────────────────────┘}| 10067]] , 10068float_pos ={ 10069[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 5 , true , 400 , 3 , 1 , 5 } , 10070[ 6 ] ={ 1003 , 'NW' , 1 , 3 , 7 , true , 300 , 2 , 2 , 7 } , 10071} , 10072win_viewport ={ 10073[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10074[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10075[ 6 ] ={ win =1003 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10076} , 10077win_viewport_margins ={ 10078[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 10079[ 4 ] ={ bottom =1 , left =1 , right =1 , top =1 , win =1001 } , 10080[ 6 ] ={ bottom =1 , left =1 , right =1 , top =1 , win =1003 } , 10081} , 10082} ) 10083else 10084screen : expect ( { 10085grid =[[ 10086^ | 10087{0:~ }{35:╔══════}{36:win_400}{35:═══════╗}{0: }| 10088{0:~ }{35:║}{7: }{35:║}{37:─┐}{0: }| 10089{0:~ }{35:║}{7:~ }{35:║}{8: }{37:│}{0: }|*2 10090{0:~ }{35:╚════════════════════╝}{8: }{37:│}{0: }| 10091{37:└────────────────────┘} | 10092]] , 10093} ) 10094end 10095exec_lua ( 10096[[ 10097local win1, win3 = ... 10098vim.api.nvim_win_set_config(win1, { zindex = 100, title='win_100' }) 10099vim.api.nvim_win_set_config(win3, { zindex = 150, title='win_150' }) 10100]] , 10101win1 , 10102win3 10103) 10104if multigrid then 10105screen : expect ( { 10106grid =[[ 10107## grid 1 10108[2:----------------------------------------]|*6 10109[3:----------------------------------------]| 10110## grid 2 10111^ | 10112{0:~ }|*5 10113## grid 3 10114| 10115## grid 4 10116{35:╔══════}{36:win_100}{35:═══════╗}| 10117{35:║}{7: }{35:║}| 10118{35:║}{7:~ }{35:║}|*2 10119{35:╚════════════════════╝}| 10120## grid 6 10121{37:┌──────}{34:win_150}{37:───────┐}| 10122{37:│}{8: }{37:│}| 10123{37:│}{8:~ }{37:│}|*2 10124{37:└────────────────────┘}| 10125]] , 10126float_pos ={ 10127[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 5 , true , 100 , 1 , 1 , 5 } , 10128[ 6 ] ={ 1003 , 'NW' , 1 , 3 , 7 , true , 150 , 2 , 1 , 7 } , 10129} , 10130win_viewport ={ 10131[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10132[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10133[ 6 ] ={ win =1003 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10134} , 10135win_viewport_margins ={ 10136[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 10137[ 4 ] ={ bottom =1 , left =1 , right =1 , top =1 , win =1001 } , 10138[ 6 ] ={ bottom =1 , left =1 , right =1 , top =1 , win =1003 } , 10139} , 10140} ) 10141else 10142screen : expect ( [[ 10143^ | 10144{0:~ }{35:╔═}{37:┌──────}{34:win_150}{37:───────┐}{0: }| 10145{0:~ }{35:║}{7: }{37:│}{8: }{37:│}{0: }| 10146{0:~ }{35:║}{7:~}{37:│}{8:~ }{37:│}{0: }|*2 10147{0:~ }{35:╚═}{37:└────────────────────┘}{0: }| 10148| 10149]] ) 10150end 10151end ) 10152 10153it ( 'can use winbar' , function () 10154local buf =api . nvim_create_buf ( false , false ) 10155local win1 =api . nvim_open_win ( buf , false , { relative ='editor' , width =15 , height =3 , row =1 , col =5 } ) 10156api . nvim_set_option_value ( 'winbar' , 'floaty bar' , { win =win1 } ) 10157 10158if multigrid then 10159screen : expect { 10160grid =[[ 10161## grid 1 10162[2:----------------------------------------]|*6 10163[3:----------------------------------------]| 10164## grid 2 10165^ | 10166{0:~ }|*5 10167## grid 3 10168| 10169## grid 4 10170{3:floaty bar }| 10171{1: }| 10172{2:~ }| 10173]] , 10174float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 5 , true , 50 , 1 , 1 , 5 } } , 10175win_viewport ={ 10176[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10177[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10178} , 10179} 10180else 10181screen : expect { 10182grid =[[ 10183^ | 10184{0:~ }{3:floaty bar }{0: }| 10185{0:~ }{1: }{0: }| 10186{0:~ }{2:~ }{0: }| 10187{0:~ }|*2 10188| 10189]] , 10190} 10191end 10192 10193-- resize and add a border 10194api . nvim_win_set_config ( win1 , { relative ='editor' , width =15 , height =4 , row =0 , col =4 , border ='single' } ) 10195 10196if multigrid then 10197screen : expect { 10198grid =[[ 10199## grid 1 10200[2:----------------------------------------]|*6 10201[3:----------------------------------------]| 10202## grid 2 10203^ | 10204{0:~ }|*5 10205## grid 3 10206| 10207## grid 4 10208{33:┌───────────────┐}| 10209{33:│}{3:floaty bar }{33:│}| 10210{33:│}{1: }{33:│}| 10211{33:│}{2:~ }{33:│}|*2 10212{33:└───────────────┘}| 10213]] , 10214float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 0 , 4 , true , 50 , 1 , 0 , 4 } } , 10215win_viewport ={ 10216[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10217[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10218} , 10219win_viewport_margins ={ 10220[ 2 ] ={ win =1000 , top =0 , bottom =0 , left =0 , right =0 } , 10221[ 4 ] ={ win =1001 , top =2 , bottom =1 , left =1 , right =1 } , 10222} , 10223} 10224else 10225screen : expect { 10226grid =[[ 10227^ {33:┌───────────────┐} | 10228{0:~ }{33:│}{3:floaty bar }{33:│}{0: }| 10229{0:~ }{33:│}{1: }{33:│}{0: }| 10230{0:~ }{33:│}{2:~ }{33:│}{0: }|*2 10231{0:~ }{33:└───────────────┘}{0: }| 10232| 10233]] , 10234} 10235end 10236end ) 10237 10238it ( 'it can be resized with messages and cmdheight=0 #20106' , function () 10239screen : try_resize ( 40 , 9 ) 10240command 'set cmdheight=0' 10241local buf =api . nvim_create_buf ( false , true ) 10242local win =api . nvim_open_win ( buf , false , { 10243relative ='editor' , 10244width =40 , 10245height =4 , 10246anchor ='SW' , 10247row =9 , 10248col =0 , 10249style ='minimal' , 10250border ='single' , 10251noautocmd =true , 10252} ) 10253 10254if multigrid then 10255screen : expect { 10256grid =[[ 10257## grid 1 10258[2:----------------------------------------]|*9 10259## grid 2 10260^ | 10261{0:~ }|*8 10262## grid 3 10263## grid 4 10264{33:┌────────────────────────────────────────┐}| 10265{33:│}{1: }{33:│}|*4 10266{33:└────────────────────────────────────────┘}| 10267]] , 10268float_pos ={ [ 4 ] ={ 1001 , 'SW' , 1 , 9 , 0 , true , 50 , 1 , 3 , 0 } } , 10269win_viewport ={ 10270[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10271[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10272} , 10273} 10274else 10275screen : expect { 10276grid =[[ 10277^ | 10278{0:~ }|*2 10279{33:┌──────────────────────────────────────┐}| 10280{33:│}{1: }{33:│}|*4 10281{33:└──────────────────────────────────────┘}| 10282]] , 10283} 10284end 10285 10286exec_lua ( 10287[[ 10288local win = ... 10289vim.api.nvim_win_set_height(win, 2) 10290vim.api.nvim_echo({ { "" } }, false, {}) 10291]] , 10292win 10293) 10294 10295if multigrid then 10296screen : expect { 10297grid =[[ 10298## grid 1 10299[2:----------------------------------------]|*9 10300## grid 2 10301^ | 10302{0:~ }|*8 10303## grid 3 10304## grid 4 10305{33:┌────────────────────────────────────────┐}| 10306{33:│}{1: }{33:│}|*2 10307{33:└────────────────────────────────────────┘}| 10308]] , 10309float_pos ={ [ 4 ] ={ 1001 , 'SW' , 1 , 9 , 0 , true , 50 , 1 , 5 , 0 } } , 10310win_viewport ={ 10311[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10312[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10313} , 10314} 10315else 10316screen : expect { 10317grid =[[ 10318^ | 10319{0:~ }|*4 10320{33:┌──────────────────────────────────────┐}| 10321{33:│}{1: }{33:│}|*2 10322{33:└──────────────────────────────────────┘}| 10323]] , 10324} 10325end 10326 10327api . nvim_win_close ( win , true ) 10328if multigrid then 10329screen : expect { 10330grid =[[ 10331## grid 1 10332[2:----------------------------------------]|*9 10333## grid 2 10334^ | 10335{0:~ }|*8 10336## grid 3 10337]] , 10338win_viewport ={ 10339[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10340} , 10341} 10342else 10343screen : expect { 10344grid =[[ 10345^ | 10346{0:~ }|*8 10347]] , 10348} 10349end 10350end ) 10351 10352it ( 'it can be resized with messages and cmdheight=1' , function () 10353screen : try_resize ( 40 , 9 ) 10354local buf =api . nvim_create_buf ( false , true ) 10355local win =api . nvim_open_win ( buf , false , { 10356relative ='editor' , 10357width =40 , 10358height =4 , 10359anchor ='SW' , 10360row =8 , 10361col =0 , 10362style ='minimal' , 10363border ='single' , 10364noautocmd =true , 10365} ) 10366 10367if multigrid then 10368screen : expect { 10369grid =[[ 10370## grid 1 10371[2:----------------------------------------]|*8 10372[3:----------------------------------------]| 10373## grid 2 10374^ | 10375{0:~ }|*7 10376## grid 3 10377| 10378## grid 4 10379{33:┌────────────────────────────────────────┐}| 10380{33:│}{1: }{33:│}|*4 10381{33:└────────────────────────────────────────┘}| 10382]] , 10383float_pos ={ [ 4 ] ={ 1001 , 'SW' , 1 , 8 , 0 , true , 50 , 1 , 2 , 0 } } , 10384win_viewport ={ 10385[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10386[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10387} , 10388} 10389else 10390screen : expect { 10391grid =[[ 10392^ | 10393{0:~ }| 10394{33:┌──────────────────────────────────────┐}| 10395{33:│}{1: }{33:│}|*4 10396{33:└──────────────────────────────────────┘}| 10397| 10398]] , 10399} 10400end 10401 10402exec_lua ( 10403[[ 10404-- echo prompt is blocking, so schedule 10405local win = ... 10406vim.schedule(function() 10407vim.api.nvim_win_set_height(win, 2) 10408vim.api.nvim_echo({ { "\n" } }, false, {}) 10409end) 10410]] , 10411win 10412) 10413 10414if multigrid then 10415screen : expect { 10416grid =[[ 10417## grid 1 10418[2:----------------------------------------]|*7 10419[3:----------------------------------------]|*2 10420## grid 2 10421| 10422{0:~ }|*7 10423## grid 3 10424| 10425{8:Press ENTER or type command to continue}^ | 10426## grid 4 10427{33:┌────────────────────────────────────────┐}| 10428{33:│}{1: }{33:│}|*4 10429{33:└────────────────────────────────────────┘}| 10430]] , 10431float_pos ={ [ 4 ] ={ 1001 , 'SW' , 1 , 8 , 0 , true , 50 , 1 , 4 , 0 } } , 10432win_viewport ={ 10433[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10434[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10435} , 10436} 10437else 10438screen : expect { 10439grid =[[ 10440| 10441{0:~ }| 10442{33:┌──────────────────────────────────────┐}| 10443{33:│}{1: }{33:│}|*3 10444{4: }| 10445| 10446{8:Press ENTER or type command to continue}^ | 10447]] , 10448} 10449end 10450 10451feed ( '<cr>' ) 10452if multigrid then 10453screen : expect { 10454grid =[[ 10455## grid 1 10456[2:----------------------------------------]|*8 10457[3:----------------------------------------]| 10458## grid 2 10459^ | 10460{0:~ }|*7 10461## grid 3 10462| 10463## grid 4 10464{33:┌────────────────────────────────────────┐}| 10465{33:│}{1: }{33:│}|*2 10466{33:└────────────────────────────────────────┘}| 10467]] , 10468float_pos ={ [ 4 ] ={ 1001 , 'SW' , 1 , 8 , 0 , true , 50 , 1 , 4 , 0 } } , 10469win_viewport ={ 10470[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10471[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10472} , 10473} 10474else 10475screen : expect { 10476grid =[[ 10477^ | 10478{0:~ }|*3 10479{33:┌──────────────────────────────────────┐}| 10480{33:│}{1: }{33:│}|*2 10481{33:└──────────────────────────────────────┘}| 10482| 10483]] , 10484} 10485end 10486 10487api . nvim_win_close ( win , true ) 10488if multigrid then 10489screen : expect { 10490grid =[[ 10491## grid 1 10492[2:----------------------------------------]|*8 10493[3:----------------------------------------]| 10494## grid 2 10495^ | 10496{0:~ }|*7 10497## grid 3 10498| 10499]] , 10500win_viewport ={ 10501[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10502} , 10503} 10504else 10505screen : expect { 10506grid =[[ 10507^ | 10508{0:~ }|*7 10509| 10510]] , 10511} 10512end 10513end ) 10514 10515describe ( 'no crash after moving and closing float window #21547' , function () 10516local function test_float_move_close ( cmd ) 10517local float_opts ={ relative ='editor' , row =1 , col =1 , width =10 , height =10 } 10518api . nvim_open_win ( api . nvim_create_buf ( false , false ), true , float_opts ) 10519if multigrid then 10520screen : expect ( { float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 1 , 0 , 1 } } } ) 10521end 10522command ( cmd ) 10523exec_lua ( [[ 10524vim.api.nvim_win_set_config(0, {relative = 'editor', row = 2, col = 2}) 10525vim.api.nvim_win_close(0, {}) 10526vim.api.nvim_echo({{''}}, false, {}) 10527]] ) 10528if multigrid then 10529screen : expect ( { float_pos ={} } ) 10530end 10531assert_alive () 10532end 10533 10534it ( 'if WinClosed autocommand flushes UI' , function () 10535test_float_move_close ( 'autocmd WinClosed * ++once redraw' ) 10536end ) 10537 10538it ( 'if closing buffer flushes UI' , function () 10539test_float_move_close ( 'autocmd BufWinLeave * ++once redraw' ) 10540end ) 10541end ) 10542 10543it ( 'no crash when closing a floating window from a non-current tab' , function () 10544local buf =api . nvim_create_buf ( false , true ) 10545local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =5 , height =5 , row =0 , col =0 } ) 10546local triggered =exec_lua ( function () 10547vim . cmd . tabnew () 10548vim . api . nvim_win_call ( win , vim . cmd . redraw ) 10549local triggered =false 10550vim . api . nvim_create_autocmd ( 'BufHidden' , { 10551once =true , 10552buf =buf , 10553callback =function () 10554vim . api . nvim_win_call ( win , vim . cmd . redraw ) 10555triggered =true 10556end , 10557} ) 10558vim . api . nvim_win_close ( win , true ) 10559return triggered 10560end ) 10561eq ( true , triggered ) 10562end ) 10563 10564it ( ':sleep cursor placement #22639' , function () 10565local float_opts ={ relative ='editor' , row =1 , col =1 , width =4 , height =3 } 10566local win =api . nvim_open_win ( api . nvim_create_buf ( false , false ), true , float_opts ) 10567feed ( 'iab<CR>cd<Esc>' ) 10568feed ( ':sleep 100' ) 10569if multigrid then 10570screen : expect { 10571grid =[[ 10572## grid 1 10573[2:----------------------------------------]|*6 10574[3:----------------------------------------]| 10575## grid 2 10576| 10577{0:~ }|*5 10578## grid 3 10579:sleep 100^ | 10580## grid 4 10581{1:ab }| 10582{1:cd }| 10583{2:~ }| 10584]] , 10585float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 1 , 1 , 1 } } , 10586win_viewport ={ 10587[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10588[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =1 , curcol =1 , linecount =2 , sum_scroll_delta =0 } , 10589} , 10590} 10591else 10592screen : expect { 10593grid =[[ 10594| 10595{0:~}{1:ab }{0: }| 10596{0:~}{1:cd }{0: }| 10597{0:~}{2:~ }{0: }| 10598{0:~ }|*2 10599:sleep 100^ | 10600]] , 10601} 10602end 10603 10604feed ( '<CR>' ) 10605if multigrid then 10606screen : expect { 10607grid =[[ 10608## grid 1 10609[2:----------------------------------------]|*6 10610[3:----------------------------------------]| 10611## grid 2 10612| 10613{0:~ }|*5 10614## grid 3 10615:sleep 100 | 10616## grid 4 10617{1:ab }| 10618{1:c^d }| 10619{2:~ }| 10620]] , 10621float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 1 , 1 , 1 } } , 10622win_viewport ={ 10623[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10624[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =1 , curcol =1 , linecount =2 , sum_scroll_delta =0 } , 10625} , 10626} 10627else 10628screen : expect { 10629grid =[[ 10630| 10631{0:~}{1:ab }{0: }| 10632{0:~}{1:c^d }{0: }| 10633{0:~}{2:~ }{0: }| 10634{0:~ }|*2 10635:sleep 100 | 10636]] , 10637} 10638end 10639feed ( '<C-C>' ) 10640screen : expect_unchanged () 10641 10642api . nvim_win_set_config ( win , { border ='single' } ) 10643feed ( ':sleep 100' ) 10644if multigrid then 10645screen : expect { 10646grid =[[ 10647## grid 1 10648[2:----------------------------------------]|*6 10649[3:----------------------------------------]| 10650## grid 2 10651| 10652{0:~ }|*5 10653## grid 3 10654:sleep 100^ | 10655## grid 4 10656{33:┌────┐}| 10657{33:│}{1:ab }{33:│}| 10658{33:│}{1:cd }{33:│}| 10659{33:│}{2:~ }{33:│}| 10660{33:└────┘}| 10661]] , 10662float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 1 , 1 , 1 } } , 10663win_viewport ={ 10664[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10665[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =1 , curcol =1 , linecount =2 , sum_scroll_delta =0 } , 10666} , 10667} 10668else 10669screen : expect { 10670grid =[[ 10671| 10672{0:~}{33:┌────┐}{0: }| 10673{0:~}{33:│}{1:ab }{33:│}{0: }| 10674{0:~}{33:│}{1:cd }{33:│}{0: }| 10675{0:~}{33:│}{2:~ }{33:│}{0: }| 10676{0:~}{33:└────┘}{0: }| 10677:sleep 100^ | 10678]] , 10679} 10680end 10681 10682feed ( '<CR>' ) 10683if multigrid then 10684screen : expect { 10685grid =[[ 10686## grid 1 10687[2:----------------------------------------]|*6 10688[3:----------------------------------------]| 10689## grid 2 10690| 10691{0:~ }|*5 10692## grid 3 10693:sleep 100 | 10694## grid 4 10695{33:┌────┐}| 10696{33:│}{1:ab }{33:│}| 10697{33:│}{1:c^d }{33:│}| 10698{33:│}{2:~ }{33:│}| 10699{33:└────┘}| 10700]] , 10701float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 1 , 1 , 1 } } , 10702win_viewport ={ 10703[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10704[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =1 , curcol =1 , linecount =2 , sum_scroll_delta =0 } , 10705} , 10706} 10707else 10708screen : expect { 10709grid =[[ 10710| 10711{0:~}{33:┌────┐}{0: }| 10712{0:~}{33:│}{1:ab }{33:│}{0: }| 10713{0:~}{33:│}{1:c^d }{33:│}{0: }| 10714{0:~}{33:│}{2:~ }{33:│}{0: }| 10715{0:~}{33:└────┘}{0: }| 10716:sleep 100 | 10717]] , 10718} 10719end 10720feed ( '<C-C>' ) 10721screen : expect_unchanged () 10722 10723command ( 'setlocal winbar=foo' ) 10724feed ( ':sleep 100' ) 10725if multigrid then 10726screen : expect { 10727grid =[[ 10728## grid 1 10729[2:----------------------------------------]|*6 10730[3:----------------------------------------]| 10731## grid 2 10732| 10733{0:~ }|*5 10734## grid 3 10735:sleep 100^ | 10736## grid 4 10737{33:┌────┐}| 10738{33:│}{3:foo }{33:│}| 10739{33:│}{1:ab }{33:│}| 10740{33:│}{1:cd }{33:│}| 10741{33:└────┘}| 10742]] , 10743float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 1 , 1 , 1 } } , 10744win_viewport ={ 10745[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10746[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =1 , curcol =1 , linecount =2 , sum_scroll_delta =0 } , 10747} , 10748} 10749else 10750screen : expect { 10751grid =[[ 10752| 10753{0:~}{33:┌────┐}{0: }| 10754{0:~}{33:│}{3:foo }{33:│}{0: }| 10755{0:~}{33:│}{1:ab }{33:│}{0: }| 10756{0:~}{33:│}{1:cd }{33:│}{0: }| 10757{0:~}{33:└────┘}{0: }| 10758:sleep 100^ | 10759]] , 10760} 10761end 10762 10763feed ( '<CR>' ) 10764if multigrid then 10765screen : expect { 10766grid =[[ 10767## grid 1 10768[2:----------------------------------------]|*6 10769[3:----------------------------------------]| 10770## grid 2 10771| 10772{0:~ }|*5 10773## grid 3 10774:sleep 100 | 10775## grid 4 10776{33:┌────┐}| 10777{33:│}{3:foo }{33:│}| 10778{33:│}{1:ab }{33:│}| 10779{33:│}{1:c^d }{33:│}| 10780{33:└────┘}| 10781]] , 10782float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 1 , 1 , 1 } } , 10783win_viewport ={ 10784[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10785[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =1 , curcol =1 , linecount =2 , sum_scroll_delta =0 } , 10786} , 10787} 10788else 10789screen : expect { 10790grid =[[ 10791| 10792{0:~}{33:┌────┐}{0: }| 10793{0:~}{33:│}{3:foo }{33:│}{0: }| 10794{0:~}{33:│}{1:ab }{33:│}{0: }| 10795{0:~}{33:│}{1:c^d }{33:│}{0: }| 10796{0:~}{33:└────┘}{0: }| 10797:sleep 100 | 10798]] , 10799} 10800end 10801feed ( '<C-C>' ) 10802screen : expect_unchanged () 10803end ) 10804 10805it ( 'with rightleft and border #22640' , function () 10806local float_opts ={ relative ='editor' , width =5 , height =3 , row =1 , col =1 , border ='single' } 10807api . nvim_open_win ( api . nvim_create_buf ( false , false ), true , float_opts ) 10808command ( 'setlocal rightleft' ) 10809feed ( 'iabc<CR>def<Esc>' ) 10810if multigrid then 10811screen : expect { 10812grid =[[ 10813## grid 1 10814[2:----------------------------------------]|*6 10815[3:----------------------------------------]| 10816## grid 2 10817| 10818{0:~ }|*5 10819## grid 3 10820| 10821## grid 4 10822{33:┌─────┐}| 10823{33:│}{1: cba}{33:│}| 10824{33:│}{1: ^fed}{33:│}| 10825{33:│}{2: ~}{33:│}| 10826{33:└─────┘}| 10827]] , 10828float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 1 , 1 , true , 50 , 1 , 1 , 1 } } , 10829win_viewport ={ 10830[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10831[ 4 ] ={ win =1001 , topline =0 , botline =3 , curline =1 , curcol =2 , linecount =2 , sum_scroll_delta =0 } , 10832} , 10833} 10834else 10835screen : expect { 10836grid =[[ 10837| 10838{0:~}{33:┌─────┐}{0: }| 10839{0:~}{33:│}{1: cba}{33:│}{0: }| 10840{0:~}{33:│}{1: ^fed}{33:│}{0: }| 10841{0:~}{33:│}{2: ~}{33:│}{0: }| 10842{0:~}{33:└─────┘}{0: }| 10843| 10844]] , 10845} 10846end 10847end ) 10848 10849it ( 'float window with hide option' , function () 10850local cwin =api . nvim_get_current_win () 10851local buf =api . nvim_create_buf ( false , false ) 10852local win =api . nvim_open_win ( buf , false , { relative ='editor' , width =10 , height =2 , row =2 , col =5 , hide =true } ) 10853local expected_pos ={ 10854[ 4 ] ={ 1001 , 'NW' , 1 , 2 , 5 , true , 50 , 1 , 2 , 5 } , 10855} 10856 10857if multigrid then 10858screen : expect { 10859grid =[[ 10860## grid 1 10861[2:----------------------------------------]|*6 10862[3:----------------------------------------]| 10863## grid 2 10864^ | 10865{0:~ }|*5 10866## grid 3 10867| 10868 10869## grid 4 (hidden) 10870{1: }| 10871{2:~ }| 10872]] , 10873float_pos ={} , 10874} 10875else 10876screen : expect ( [[ 10877^ | 10878{0:~ }|*5 10879| 10880]] ) 10881end 10882 10883api . nvim_win_set_config ( win , { hide =false } ) 10884if multigrid then 10885screen : expect { 10886grid =[[ 10887## grid 1 10888[2:----------------------------------------]|*6 10889[3:----------------------------------------]| 10890## grid 2 10891^ | 10892{0:~ }|*5 10893## grid 3 10894| 10895 10896## grid 4 10897{1: }| 10898{2:~ }| 10899]] , 10900float_pos =expected_pos , 10901} 10902else 10903screen : expect ( [[ 10904^ | 10905{0:~ }| 10906{0:~ }{1: }{0: }| 10907{0:~ }{2:~ }{0: }| 10908{0:~ }|*2 10909| 10910]] ) 10911end 10912 10913api . nvim_win_set_config ( win , { hide =true } ) 10914if multigrid then 10915screen : expect { 10916grid =[[ 10917## grid 1 10918[2:----------------------------------------]|*6 10919[3:----------------------------------------]| 10920## grid 2 10921^ | 10922{0:~ }|*5 10923## grid 3 10924| 10925 10926## grid 4 (hidden) 10927{1: }| 10928{2:~ }| 10929]] , 10930float_pos ={} , 10931} 10932else 10933screen : expect ( [[ 10934^ | 10935{0:~ }|*5 10936| 10937]] ) 10938end 10939 10940-- 10941-- Cursor visibility: 10942-- 10943-- Cursor is not visible in a hide=true floating window. 10944api . nvim_set_current_win ( win ) 10945if multigrid then 10946screen : expect ( { 10947grid =[[ 10948## grid 1 10949[2:----------------------------------------]|*6 10950[3:----------------------------------------]| 10951## grid 2 10952| 10953{0:~ }|*5 10954## grid 3 10955| 10956## grid 4 (hidden) 10957{1: }| 10958{2:~ }| 10959]] , 10960win_viewport ={ 10961[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10962[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10963} , 10964win_viewport_margins ={ 10965[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 10966[ 4 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1001 } , 10967} , 10968} ) 10969else 10970screen : expect ( { 10971grid =[[ 10972| 10973{0:~ }|*5 10974| 10975]] , 10976} ) 10977end 10978 10979-- Show cursor if cmdline is entered while curwin is a hide=true floating window. 10980feed ( ':' ) 10981if multigrid then 10982screen : expect ( { 10983grid =[[ 10984## grid 1 10985[2:----------------------------------------]|*6 10986[3:----------------------------------------]| 10987## grid 2 10988| 10989{0:~ }|*5 10990## grid 3 10991:^ | 10992## grid 4 (hidden) 10993{1: }| 10994{2:~ }| 10995]] , 10996win_viewport ={ 10997[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10998[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 10999} , 11000win_viewport_margins ={ 11001[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 11002[ 4 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1001 } , 11003} , 11004} ) 11005else 11006screen : expect ( { 11007grid =[[ 11008| 11009{0:~ }|*5 11010:^ | 11011]] , 11012} ) 11013end 11014 11015command ( 'set keymap=dvorak' ) 11016feed ( '<C-^>' ) 11017screen : expect_unchanged () 11018 11019feed ( '<C-^>' ) 11020command ( 'set keymap&' ) 11021screen : expect_unchanged () 11022 11023feed ( '<ESC>' ) 11024 11025-- Show cursor after switching to a normal window (hide=false). 11026api . nvim_set_current_win ( cwin ) 11027if multigrid then 11028screen : expect ( { 11029grid =[[ 11030## grid 1 11031[2:----------------------------------------]|*6 11032[3:----------------------------------------]| 11033## grid 2 11034^ | 11035{0:~ }|*5 11036## grid 3 11037| 11038## grid 4 (hidden) 11039{1: }| 11040{2:~ }| 11041]] , 11042win_viewport ={ 11043[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11044[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11045} , 11046win_viewport_margins ={ 11047[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 11048[ 4 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1001 } , 11049} , 11050} ) 11051else 11052screen : expect ( { 11053grid =[[ 11054^ | 11055{0:~ }|*5 11056| 11057]] , 11058} ) 11059end 11060api . nvim_set_current_win ( win ) 11061local win1 =api . nvim_open_win ( buf , false , { relative ='editor' , width =4 , height =4 , row =1 , col =2 } ) 11062api . nvim_set_current_win ( win1 ) 11063if multigrid then 11064screen : expect ( { 11065grid =[[ 11066## grid 1 11067[2:----------------------------------------]|*6 11068[3:----------------------------------------]| 11069## grid 2 11070| 11071{0:~ }|*5 11072## grid 3 11073| 11074## grid 4 (hidden) 11075{1: }| 11076{2:~ }| 11077## grid 5 11078{1:^ }| 11079{2:~ }|*3 11080]] , 11081float_pos ={ [ 5 ] ={ 1002 , 'NW' , 1 , 1 , 2 , true , 50 , 1 , 1 , 2 } } , 11082win_viewport ={ 11083[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11084[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11085[ 5 ] ={ win =1002 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11086} , 11087win_viewport_margins ={ 11088[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 11089[ 4 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1001 } , 11090[ 5 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1002 } , 11091} , 11092} ) 11093else 11094screen : expect ( { 11095grid =[[ 11096| 11097{0:~ }{1:^ }{0: }| 11098{0:~ }{2:~ }{0: }|*3 11099{0:~ }| 11100| 11101]] , 11102} ) 11103end 11104api . nvim_win_close ( win1 , true ) 11105 11106-- check window jump with hide 11107feed ( '<C-W><C-W>' ) 11108-- should keep on current window 11109eq ( cwin , api . nvim_get_current_win ()) 11110api . nvim_win_set_config ( win , { hide =false } ) 11111api . nvim_set_current_win ( win ) 11112local win3 =api . nvim_open_win ( buf , true , { relative ='editor' , width =4 , height =4 , row =2 , col =5 , hide =false } ) 11113api . nvim_win_set_config ( win , { hide =true } ) 11114feed ( '<C-W>w' ) 11115-- should goto the first window with prev 11116eq ( cwin , api . nvim_get_current_win ()) 11117-- windo 11118command ( 'windo set winheight=6' ) 11119eq ( win3 , api . nvim_get_current_win ()) 11120eq ( 6 , api . nvim_win_get_height ( win3 )) 11121eq ( 2 , api . nvim_win_get_height ( win )) 11122end ) 11123 11124it ( ':fclose command #9663' , function () 11125local buf_a =api . nvim_create_buf ( false , false ) 11126local buf_b =api . nvim_create_buf ( false , false ) 11127local buf_c =api . nvim_create_buf ( false , false ) 11128local buf_d =api . nvim_create_buf ( false , false ) 11129local config_a ={ relative ='editor' , width =11 , height =11 , row =5 , col =5 , border ='single' , zindex =50 } 11130local config_b ={ relative ='editor' , width =8 , height =8 , row =7 , col =7 , border ='single' , zindex =70 } 11131local config_c ={ relative ='editor' , width =4 , height =4 , row =9 , col =9 , border ='single' , zindex =90 } 11132local config_d ={ relative ='editor' , width =2 , height =2 , row =10 , col =10 , border ='single' , zindex =100 } 11133api . nvim_open_win ( buf_a , false , config_a ) 11134api . nvim_open_win ( buf_b , false , config_b ) 11135api . nvim_open_win ( buf_c , false , config_c ) 11136api . nvim_open_win ( buf_d , false , config_d ) 11137local expected_pos ={ 11138[ 4 ] ={ 1001 , 'NW' , 1 , 5 , 5 , true , 50 , 1 , 0 , 5 } , 11139[ 5 ] ={ 1002 , 'NW' , 1 , 7 , 7 , true , 70 , 2 , 0 , 7 } , 11140[ 6 ] ={ 1003 , 'NW' , 1 , 9 , 9 , true , 90 , 3 , 0 , 9 } , 11141[ 7 ] ={ 1004 , 'NW' , 1 , 10 , 10 , true , 100 , 4 , 2 , 10 } , 11142} 11143if multigrid then 11144screen : expect { 11145grid =[[ 11146## grid 1 11147[2:----------------------------------------]|*6 11148[3:----------------------------------------]| 11149## grid 2 11150^ | 11151{0:~ }|*5 11152## grid 3 11153| 11154## grid 4 11155{33:┌───────────┐}| 11156{33:│}{1: }{33:│}| 11157{33:│}{2:~ }{33:│}|*10 11158{33:└───────────┘}| 11159## grid 5 11160{33:┌────────┐}| 11161{33:│}{1: }{33:│}| 11162{33:│}{2:~ }{33:│}|*7 11163{33:└────────┘}| 11164## grid 6 11165{33:┌────┐}| 11166{33:│}{1: }{33:│}| 11167{33:│}{2:~ }{33:│}|*3 11168{33:└────┘}| 11169## grid 7 11170{33:┌──┐}| 11171{33:│}{1: }{33:│}| 11172{33:│}{2:~ }{33:│}| 11173{33:└──┘}| 11174]] , 11175float_pos =expected_pos , 11176} 11177else 11178screen : expect ( [[ 11179^ {33:┌─┌─┌────┐─┐┐} | 11180{0:~ }{33:│}{1: }{33:│}{1: }{33:│}{1: }{33:│}{1: }{33:││}{0: }| 11181{0:~ }{33:│}{2:~}{33:│}{2:~}{33:│┌──┐│}{2: }{33:││}{0: }| 11182{0:~ }{33:│}{2:~}{33:│}{2:~}{33:││}{1: }{33:││}{2: }{33:││}{0: }| 11183{0:~ }{33:│}{2:~}{33:│}{2:~}{33:││}{2:~ }{33:││}{2: }{33:││}{0: }| 11184{0:~ }{33:└─└─└└──┘┘─┘┘}{0: }| 11185| 11186]] ) 11187end 11188-- close the window with the highest zindex value 11189command ( 'fclose' ) 11190expected_pos [ 7 ] =nil 11191if multigrid then 11192screen : expect { 11193grid =[[ 11194## grid 1 11195[2:----------------------------------------]|*6 11196[3:----------------------------------------]| 11197## grid 2 11198^ | 11199{0:~ }|*5 11200## grid 3 11201| 11202 11203## grid 4 11204{33:┌───────────┐}| 11205{33:│}{1: }{33:│}| 11206{33:│}{2:~ }{33:│}|*10 11207{33:└───────────┘}| 11208## grid 5 11209{33:┌────────┐}| 11210{33:│}{1: }{33:│}| 11211{33:│}{2:~ }{33:│}|*7 11212{33:└────────┘}| 11213## grid 6 11214{33:┌────┐}| 11215{33:│}{1: }{33:│}| 11216{33:│}{2:~ }{33:│}|*3 11217{33:└────┘}| 11218]] , 11219float_pos =expected_pos , 11220} 11221else 11222screen : expect ( [[ 11223^ {33:┌─┌─┌────┐─┐┐} | 11224{0:~ }{33:│}{1: }{33:│}{1: }{33:│}{1: }{33:│}{1: }{33:││}{0: }| 11225{0:~ }{33:│}{2:~}{33:│}{2:~}{33:│}{2:~ }{33:│}{2: }{33:││}{0: }|*3 11226{0:~ }{33:└─└─└────┘─┘┘}{0: }| 11227| 11228]] ) 11229end 11230-- with range 11231command ( '1fclose' ) 11232expected_pos [ 6 ] =nil 11233if multigrid then 11234screen : expect { 11235grid =[[ 11236## grid 1 11237[2:----------------------------------------]|*6 11238[3:----------------------------------------]| 11239## grid 2 11240^ | 11241{0:~ }|*5 11242## grid 3 11243| 11244 11245## grid 4 11246{33:┌───────────┐}| 11247{33:│}{1: }{33:│}| 11248{33:│}{2:~ }{33:│}|*10 11249{33:└───────────┘}| 11250## grid 5 11251{33:┌────────┐}| 11252{33:│}{1: }{33:│}| 11253{33:│}{2:~ }{33:│}|*7 11254{33:└────────┘}| 11255]] , 11256float_pos =expected_pos , 11257} 11258else 11259screen : expect ( [[ 11260^ {33:┌─┌────────┐┐} | 11261{0:~ }{33:│}{1: }{33:│}{1: }{33:││}{0: }| 11262{0:~ }{33:│}{2:~}{33:│}{2:~ }{33:││}{0: }|*3 11263{0:~ }{33:└─└────────┘┘}{0: }| 11264| 11265]] ) 11266end 11267-- with bang 11268command ( 'fclose!' ) 11269if multigrid then 11270screen : expect { 11271grid =[[ 11272## grid 1 11273[2:----------------------------------------]|*6 11274[3:----------------------------------------]| 11275## grid 2 11276^ | 11277{0:~ }|*5 11278## grid 3 11279| 11280 11281]] , 11282float_pos ={} , 11283} 11284else 11285screen : expect ( [[ 11286^ | 11287{0:~ }|*5 11288| 11289]] ) 11290end 11291-- allow use with trailing bar 11292eq ( 'hello' , n . exec_capture ( 'fclose | echo "hello"' )) 11293end ) 11294 11295it ( 'correctly placed in or above message area' , function () 11296local float_opts ={ relative ='editor' , width =5 , height =1 , row =100 , col =1 , border ='single' } 11297api . nvim_set_option_value ( 'cmdheight' , 3 , {} ) 11298command ( "echo 'cmdline'" ) 11299local win =api . nvim_open_win ( api . nvim_create_buf ( false , false ), true , float_opts ) 11300-- Not hidden behind message area but placed above it. 11301if multigrid then 11302screen : expect { 11303grid =[[ 11304## grid 1 11305[2:----------------------------------------]|*4 11306[3:----------------------------------------]|*3 11307## grid 2 11308| 11309{0:~ }|*3 11310## grid 3 11311cmdline | 11312|*2 11313## grid 4 11314{33:┌─────┐}| 11315{33:│}{1:^ }{33:│}| 11316{33:└─────┘}| 11317]] , 11318float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 100 , 1 , true , 50 , 1 , 1 , 1 } } , 11319win_viewport ={ 11320[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11321[ 4 ] ={ win =1001 , topline =0 , botline =1 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11322} , 11323} 11324else 11325screen : expect { 11326grid =[[ 11327| 11328{0:~}{33:┌─────┐}{0: }| 11329{0:~}{33:│}{1:^ }{33:│}{0: }| 11330{0:~}{33:└─────┘}{0: }| 11331cmdline | 11332|*2 11333]] , 11334} 11335end 11336-- Not placed above message area and visible on top of it. 11337api . nvim_win_set_config ( win , { zindex =300 } ) 11338if multigrid then 11339screen : expect { 11340grid =[[ 11341## grid 1 11342[2:----------------------------------------]|*4 11343[3:----------------------------------------]|*3 11344## grid 2 11345| 11346{0:~ }|*3 11347## grid 3 11348cmdline | 11349|*2 11350## grid 4 11351{33:┌─────┐}| 11352{33:│}{1:^ }{33:│}| 11353{33:└─────┘}| 11354]] , 11355float_pos ={ [ 4 ] ={ 1001 , 'NW' , 1 , 100 , 1 , true , 300 , 2 , 4 , 1 } } , 11356win_viewport ={ 11357[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11358[ 4 ] ={ win =1001 , topline =0 , botline =1 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11359} , 11360} 11361else 11362screen : expect { 11363grid =[[ 11364| 11365{0:~ }|*3 11366c{33:┌─────┐} | 11367{33:│}{1:^ }{33:│} | 11368{33:└─────┘} | 11369]] , 11370} 11371end 11372end ) 11373 11374it ( 'attempt to turn into split with no room' , function () 11375eq ( 'Vim(split):E36: Not enough room' , pcall_err ( command , 'execute "split |"->repeat(&lines)' )) 11376command ( 'vsplit | wincmd | | wincmd p' ) 11377api . nvim_open_win ( 0 , true , { relative ='editor' , row =0 , col =0 , width =5 , height =5 } ) 11378local config =api . nvim_win_get_config ( 0 ) 11379eq ( 'editor' , config . relative ) 11380 11381local layout =fn . winlayout () 11382local restcmd =fn . winrestcmd () 11383eq ( 'Vim(wincmd):E36: Not enough room' , pcall_err ( command , 'wincmd K' )) 11384eq ( 'Vim(wincmd):E36: Not enough room' , pcall_err ( command , 'wincmd J' )) 11385eq ( layout , fn . winlayout ()) 11386eq ( restcmd , fn . winrestcmd ()) 11387eq ( config , api . nvim_win_get_config ( 0 )) 11388end ) 11389 11390it ( 'error when relative to itself' , function () 11391local buf =api . nvim_create_buf ( false , true ) 11392local config ={ relative ='win' , width =5 , height =2 , row =3 , col =3 } 11393local winid =api . nvim_open_win ( buf , false , config ) 11394api . nvim_set_current_win ( winid ) 11395eq ( 'floating window cannot be relative to itself' , pcall_err ( api . nvim_win_set_config , winid , config )) 11396eq ( 'floating window cannot be relative to itself' , pcall_err ( api . nvim_win_set_config , winid , { win =winid } )) 11397-- Don't assume win=0 if no win given for existing relative=win float; so no error. 11398api . nvim_win_set_config ( winid , { width =7 } ) 11399eq ( 7 , api . nvim_win_get_config ( winid ). width ) 11400-- Don't expect the error when configuring to something other than relative=win, as win=self 11401-- is fine in those cases. (though maybe pointless) Other errors might be expected, though. 11402eq ( 'Cannot split a floating window' , pcall_err ( api . nvim_win_set_config , winid , { split ='above' , win =winid } )) 11403eq ( 'win' , api . nvim_win_get_config ( winid ). relative ) 11404api . nvim_win_set_config ( winid , { relative ='editor' , win =winid , row =3 , col =3 } ) 11405eq ( 'editor' , api . nvim_win_get_config ( winid ). relative ) 11406-- An error when configuring split into relative=win float. 11407command ( 'split' ) 11408eq ( 'floating window cannot be relative to itself' , pcall_err ( api . nvim_win_set_config , 0 , config )) 11409end ) 11410 11411it ( 'bufpos out of range' , function () 11412local buf =api . nvim_create_buf ( false , true ) 11413api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , {} ) 11414local config ={ relative ='win' , width =5 , height =2 , row =0 , col =0 , bufpos ={ 3 , 3 } } 11415api . nvim_open_win ( buf , false , config ) 11416if multigrid then 11417screen : expect ( { 11418grid =[[ 11419## grid 1 11420[2:----------------------------------------]|*6 11421[3:----------------------------------------]| 11422## grid 2 11423^ | 11424{0:~ }|*5 11425## grid 3 11426| 11427## grid 4 11428{1: }| 11429{2:~ }| 11430]] , 11431float_pos ={ [ 4 ] ={ 1001 , 'NW' , 2 , 0 , 0 , true , 50 , 1 , 0 , 0 } } , 11432win_viewport ={ 11433[ 2 ] ={ win =1000 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11434[ 4 ] ={ win =1001 , topline =0 , botline =2 , curline =0 , curcol =0 , linecount =1 , sum_scroll_delta =0 } , 11435} , 11436} ) 11437else 11438screen : expect ( { 11439grid =[[ 11440{1:^ } | 11441{2:~ }{0: }| 11442{0:~ }|*4 11443| 11444]] , 11445} ) 11446end 11447end ) 11448 11449it ( "1-line float does not inherit 'winbar' #19464" , function () 11450local res =exec_lua ( [[ 11451local win = vim.api.nvim_get_current_win() 11452vim.wo[win].winbar = '%f' 11453local grp = vim.api.nvim_create_augroup('asdf', { clear = true }) 11454vim.api.nvim_create_autocmd('WinEnter', { 11455group = grp, 11456pattern = '*', 11457desc = 'winbar crash?', 11458callback = function() 11459vim.wo[win].winbar = '%f' 11460end, 11461}) 11462 11463local buf = vim.api.nvim_create_buf(false, true) 11464local float_winid = vim.api.nvim_open_win(buf, true, { 11465relative = 'win', 11466win = win, 11467border = 'single', 11468col = 1, 11469row = 1, 11470height = 1, 11471width = 40, 11472}) 11473return {vim.wo[win].winbar, vim.wo[float_winid].winbar} 11474]] ) 11475eq ( { '%f' , '' } , res ) 11476end ) 11477 11478it ( 'winborder option' , function () 11479local buf =api . nvim_create_buf ( false , false ) 11480local config ={ relative ='editor' , width =4 , height =4 , row =2 , col =2 } 11481command ( 'set winborder=single' ) 11482local winid =api . nvim_open_win ( buf , true , config ) 11483eq ( '┌' , api . nvim_win_get_config ( winid ). border [ 1 ]) 11484command ( 'fclose' ) 11485 11486command ( 'set winborder=double' ) 11487winid =api . nvim_open_win ( buf , true , config ) 11488eq ( '╔' , api . nvim_win_get_config ( winid ). border [ 1 ]) 11489command ( 'fclose!' ) 11490 11491command ( 'set winborder=none' ) 11492winid =api . nvim_open_win ( buf , true , config ) 11493eq ( 'none' , api . nvim_win_get_config ( winid ). border ) 11494command ( 'fclose!' ) 11495 11496-- respect config.border 11497command ( 'set winborder=rounded' ) 11498config . border ='single' 11499winid =api . nvim_open_win ( buf , false , config ) 11500eq ( '┌' , api . nvim_win_get_config ( winid ). border [ 1 ]) 11501 11502-- don't use winborder when reconfig a floating window 11503-- still show a single border 11504config . border =nil 11505api . nvim_win_set_config ( winid , config ) 11506eq ( '┌' , api . nvim_win_get_config ( winid ). border [ 1 ]) 11507command ( 'fclose!' ) 11508 11509command ( 'set winborder=bold' ) 11510winid =api . nvim_open_win ( buf , false , config ) 11511eq ( '┏' , api . nvim_win_get_config ( winid ). border [ 1 ]) 11512 11513command ( [[set winborder=+,-,+,\|,+,-,+,\|]] ) 11514winid =api . nvim_open_win ( buf , false , config ) 11515eq ( '+' , api . nvim_win_get_config ( winid ). border [ 1 ]) 11516 11517command ( [[set winborder=●,○,●,○,●,○,●,○]] ) 11518winid =api . nvim_open_win ( buf , false , config ) 11519eq ( '●' , api . nvim_win_get_config ( winid ). border [ 1 ]) 11520 11521-- Single-space border char. 11522command ( [[lua vim.opt.winborder=",,, ,,,, "]] ) 11523winid =api . nvim_open_win ( buf , false , config ) 11524eq ( { '' , '' , '' , ' ' , '' , '' , '' , ' ' } , api . nvim_win_get_config ( winid ). border ) 11525 11526-- Trailing comma hides the last side 11527command ( [[set winborder=+,-,+,\|,+,-,+,]] ) 11528winid =api . nvim_open_win ( buf , false , config ) 11529eq ( { '+' , '-' , '+' , '|' , '+' , '-' , '+' , '' } , api . nvim_win_get_config ( winid ). border ) 11530command ( 'fclose!' ) 11531 11532eq ( 'Vim(set):E474: Invalid argument: winborder=,,' , pcall_err ( command , 'set winborder=,,' )) 11533eq ( 'Vim(set):E474: Invalid argument: winborder=custom' , pcall_err ( command , 'set winborder=custom' )) 11534end ) 11535 11536it ( 'cursor shape when the cursor is covered by a floating window' , function () 11537local normal_win =api . nvim_get_current_win () 11538api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'one' , 'two' } ) 11539api . nvim_win_set_cursor ( 0 , { 2 , 2 } ) 11540local buf =api . nvim_create_buf ( false , false ) 11541api . nvim_buf_set_lines ( buf , 0 , 0 , true , { 'the only line' } ) 11542local win =api . nvim_open_win ( buf , false , { relative ='editor' , row =0 , col =0 , height =2 , width =20 } ) 11543if multigrid then 11544screen : expect ( { 11545grid =[[ 11546## grid 1 11547[2:----------------------------------------]|*6 11548[3:----------------------------------------]| 11549## grid 2 11550one | 11551tw^o | 11552{0:~ }|*4 11553## grid 3 11554| 11555## grid 4 11556{1:the only line }| 11557{1: }| 11558]] , 11559win_pos ={ 11560[ 2 ] ={ height =6 , startcol =0 , startrow =0 , width =40 , win =1000 } , 11561} , 11562float_pos ={ 11563[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 0 , true , 50 , 1 , 0 , 0 } , 11564} , 11565mode ='normal' , 11566} ) 11567else 11568screen : expect { 11569grid =[[ 11570{1:the only line } | 11571{1: ^ } | 11572{0:~ }|*4 11573| 11574]] , 11575mode ='replace' , 11576} 11577end 11578api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'one' , 'two' , 'three' } ) 11579feed ( '<Down>' ) 11580if multigrid then 11581screen : expect ( { 11582grid =[[ 11583## grid 1 11584[2:----------------------------------------]|*6 11585[3:----------------------------------------]| 11586## grid 2 11587one | 11588two | 11589th^ree | 11590{0:~ }|*3 11591## grid 3 11592| 11593## grid 4 11594{1:the only line }| 11595{1: }| 11596]] , 11597win_pos ={ 11598[ 2 ] ={ height =6 , startcol =0 , startrow =0 , width =40 , win =1000 } , 11599} , 11600float_pos ={ 11601[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 0 , true , 50 , 1 , 0 , 0 } , 11602} , 11603mode ='normal' , 11604} ) 11605else 11606screen : expect { mode ='normal' } 11607end 11608-- Cursor shape on a lower z-index floating window 11609buf =api . nvim_create_buf ( false , false ) 11610api . nvim_buf_set_lines ( buf , 0 , 0 , true , { 'highest' } ) 11611local high_win =api . nvim_open_win ( buf , false , { relative ='editor' , row =0 , col =0 , height =2 , width =7 , zindex =150 } ) 11612api . nvim_set_current_win ( win ) 11613api . nvim_win_set_cursor ( win , { 2 , 1 } ) 11614if multigrid then 11615screen : expect ( { 11616grid =[[ 11617## grid 1 11618[2:----------------------------------------]|*6 11619[3:----------------------------------------]| 11620## grid 2 11621one | 11622two | 11623three | 11624{0:~ }|*3 11625## grid 3 11626| 11627## grid 4 11628{1:the only line }| 11629{1:^ }| 11630## grid 5 11631{1:highest}| 11632{1: }| 11633]] , 11634win_pos ={ 11635[ 2 ] ={ height =6 , startcol =0 , startrow =0 , width =40 , win =1000 } , 11636} , 11637float_pos ={ 11638[ 5 ] ={ 1002 , 'NW' , 1 , 0 , 0 , true , 150 , 2 , 0 , 0 } , 11639[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 0 , true , 50 , 1 , 0 , 0 } , 11640} , 11641mode ='normal' , 11642} ) 11643else 11644screen : expect { mode ='replace' } 11645end 11646 11647api . nvim_set_current_win ( high_win ) 11648if multigrid then 11649screen : expect ( { 11650grid =[[ 11651## grid 1 11652[2:----------------------------------------]|*6 11653[3:----------------------------------------]| 11654## grid 2 11655one | 11656two | 11657three | 11658{0:~ }|*3 11659## grid 3 11660| 11661## grid 4 11662{1:the only line }| 11663{1: }| 11664## grid 5 11665{1:^highest}| 11666{1: }| 11667]] , 11668win_pos ={ 11669[ 2 ] ={ height =6 , startcol =0 , startrow =0 , width =40 , win =1000 } , 11670} , 11671float_pos ={ 11672[ 5 ] ={ 1002 , 'NW' , 1 , 0 , 0 , true , 150 , 2 , 0 , 0 } , 11673[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 0 , true , 50 , 1 , 0 , 0 } , 11674} , 11675mode ='normal' , 11676} ) 11677else 11678screen : expect { 11679grid =[[ 11680{1:^highesty line } | 11681{1: } | 11682three | 11683{0:~ }|*3 11684| 11685]] , 11686mode ='normal' , 11687} 11688end 11689 11690buf =api . nvim_create_buf ( false , false ) 11691api . nvim_buf_set_lines ( buf , 0 , 0 , true , { 'another' } ) 11692api . nvim_open_win ( buf , true , { relative ='editor' , row =0 , col =0 , height =2 , width =7 , zindex =160 } ) 11693if multigrid then 11694screen : expect ( { 11695grid =[[ 11696## grid 1 11697[2:----------------------------------------]|*6 11698[3:----------------------------------------]| 11699## grid 2 11700one | 11701two | 11702three | 11703{0:~ }|*3 11704## grid 3 11705| 11706## grid 4 11707{1:the only line }| 11708{1: }| 11709## grid 5 11710{1:highest}| 11711{1: }| 11712## grid 6 11713{1:^another}| 11714{1: }| 11715]] , 11716win_pos ={ 11717[ 2 ] ={ height =6 , startcol =0 , startrow =0 , width =40 , win =1000 } , 11718} , 11719float_pos ={ 11720[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 0 , true , 50 , 1 , 0 , 0 } , 11721[ 5 ] ={ 1002 , 'NW' , 1 , 0 , 0 , true , 150 , 2 , 0 , 0 } , 11722[ 6 ] ={ 1003 , 'NW' , 1 , 0 , 0 , true , 160 , 3 , 0 , 0 } , 11723} , 11724mode ='normal' , 11725} ) 11726else 11727screen : expect { 11728grid =[[ 11729{1:^anothery line } | 11730{1: } | 11731three | 11732{0:~ }|*3 11733| 11734]] , 11735mode ='normal' , 11736} 11737end 11738api . nvim_set_current_win ( normal_win ) 11739command ( 'only' ) 11740screen : try_resize ( 50 , 20 ) 11741buf =api . nvim_create_buf ( false , false ) 11742api . nvim_buf_set_lines ( buf , 0 , - 1 , true , { 'x' } ) 11743local float_win =api . nvim_open_win ( buf , true , { 11744relative ='editor' , 11745width =5 , 11746height =5 , 11747row =8 , 11748col =9 , 11749border ='single' , 11750} ) 11751local buf2 =api . nvim_create_buf ( false , false ) 11752local float_win_above =api . nvim_open_win ( buf2 , false , { 11753relative ='editor' , 11754width =10 , 11755height =10 , 11756row =0 , 11757col =0 , 11758zindex =100 , 11759} ) 11760if multigrid then 11761screen : expect ( { 11762grid =[[ 11763## grid 1 11764[2:--------------------------------------------------]|*19 11765[3:--------------------------------------------------]| 11766## grid 2 11767one | 11768two | 11769three | 11770{0:~ }|*16 11771## grid 3 11772| 11773## grid 7 11774{33:┌─────┐}| 11775{33:│}{1:^x }{33:│}| 11776{33:│}{2:~ }{33:│}|*4 11777{33:└─────┘}| 11778## grid 8 11779{1: }| 11780{2:~ }|*9 11781]] , 11782win_pos ={ 11783[ 2 ] ={ height =19 , startcol =0 , startrow =0 , width =50 , win =1000 } , 11784} , 11785float_pos ={ 11786[ 7 ] ={ 1004 , 'NW' , 1 , 8 , 9 , true , 50 , 1 , 8 , 9 } , 11787[ 8 ] ={ 1005 , 'NW' , 1 , 0 , 0 , true , 100 , 2 , 0 , 0 } , 11788} , 11789mode ='normal' , 11790} ) 11791else 11792screen : expect { 11793grid =[[ 11794{1: } | 11795{2:~ } |*2 11796{2:~ }{0: }|*5 11797{2:~ }{33:─────┐}{0: }| 11798{2:~ }{1:^x }{33:│}{0: }| 11799{0:~ }{33:│}{2:~ }{33:│}{0: }|*4 11800{0:~ }{33:└─────┘}{0: }| 11801{0:~ }|*4 11802| 11803]] , 11804mode ='normal' , 11805} 11806end 11807-- Move window 11808api . nvim_win_set_config ( float_win , { relative ='editor' , row =9 , col =8 } ) 11809if multigrid then 11810screen : expect ( { 11811grid =[[ 11812## grid 1 11813[2:--------------------------------------------------]|*19 11814[3:--------------------------------------------------]| 11815## grid 2 11816one | 11817two | 11818three | 11819{0:~ }|*16 11820## grid 3 11821| 11822## grid 7 11823{33:┌─────┐}| 11824{33:│}{1:^x }{33:│}| 11825{33:│}{2:~ }{33:│}|*4 11826{33:└─────┘}| 11827## grid 8 11828{1: }| 11829{2:~ }|*9 11830]] , 11831win_pos ={ 11832[ 2 ] ={ height =19 , startcol =0 , startrow =0 , width =50 , win =1000 } , 11833} , 11834float_pos ={ 11835[ 7 ] ={ 1004 , 'NW' , 1 , 9 , 8 , true , 50 , 1 , 9 , 8 } , 11836[ 8 ] ={ 1005 , 'NW' , 1 , 0 , 0 , true , 100 , 2 , 0 , 0 } , 11837} , 11838mode ='normal' , 11839} ) 11840else 11841screen : expect { 11842grid =[[ 11843{1: } | 11844{2:~ } |*2 11845{2:~ }{0: }|*6 11846{2:~ }{33:────┐}{0: }| 11847{0:~ }{33:│}{1:^x }{33:│}{0: }| 11848{0:~ }{33:│}{2:~ }{33:│}{0: }|*4 11849{0:~ }{33:└─────┘}{0: }| 11850{0:~ }|*3 11851| 11852]] , 11853mode ='normal' , 11854} 11855end 11856 11857-- rightleft 11858api . nvim_win_set_config ( float_win , { relative ='editor' , row =8 , col =8 } ) 11859command ( 'set rightleft' ) 11860if multigrid then 11861screen : expect ( { 11862grid =[[ 11863## grid 1 11864[2:--------------------------------------------------]|*19 11865[3:--------------------------------------------------]| 11866## grid 2 11867one | 11868two | 11869three | 11870{0:~ }|*16 11871## grid 3 11872| 11873## grid 7 11874{33:┌─────┐}| 11875{33:│}{1: ^x}{33:│}| 11876{33:│}{2: ~}{33:│}|*4 11877{33:└─────┘}| 11878## grid 8 11879{1: }| 11880{2:~ }|*9 11881]] , 11882win_pos ={ 11883[ 2 ] ={ height =19 , startcol =0 , startrow =0 , width =50 , win =1000 } , 11884} , 11885float_pos ={ 11886[ 7 ] ={ 1004 , 'NW' , 1 , 8 , 8 , true , 50 , 1 , 8 , 8 } , 11887[ 8 ] ={ 1005 , 'NW' , 1 , 0 , 0 , true , 100 , 2 , 0 , 0 } , 11888} , 11889mode ='normal' , 11890} ) 11891else 11892screen : expect { 11893grid =[[ 11894{1: } | 11895{2:~ } |*2 11896{2:~ }{0: }|*5 11897{2:~ }{33:────┐}{0: }| 11898{2:~ }{1: ^x}{33:│}{0: }| 11899{0:~ }{33:│}{2: ~}{33:│}{0: }|*4 11900{0:~ }{33:└─────┘}{0: }| 11901{0:~ }|*4 11902| 11903]] , 11904mode ='normal' , 11905} 11906end 11907 11908command ( 'set virtualedit=all' ) 11909fn . setpos ( '.' , { 0 , 1 , 1 , 4 } ) 11910if multigrid then 11911screen : expect ( { 11912grid =[[ 11913## grid 1 11914[2:--------------------------------------------------]|*19 11915[3:--------------------------------------------------]| 11916## grid 2 11917one | 11918two | 11919three | 11920{0:~ }|*16 11921## grid 3 11922| 11923## grid 7 11924{33:┌─────┐}| 11925{33:│}{1:^ x}{33:│}| 11926{33:│}{2: ~}{33:│}|*4 11927{33:└─────┘}| 11928## grid 8 11929{1: }| 11930{2:~ }|*9 11931]] , 11932win_pos ={ 11933[ 2 ] ={ height =19 , startcol =0 , startrow =0 , width =50 , win =1000 } , 11934} , 11935float_pos ={ 11936[ 7 ] ={ 1004 , 'NW' , 1 , 8 , 8 , true , 50 , 1 , 8 , 8 } , 11937[ 8 ] ={ 1005 , 'NW' , 1 , 0 , 0 , true , 100 , 2 , 0 , 0 } , 11938} , 11939mode ='normal' , 11940} ) 11941else 11942screen : expect { mode ='replace' } 11943end 11944-- Not obscured when zindex doesn't exceed the zindex of the current grid + 50 (#37703). 11945api . nvim_win_set_config ( float_win_above , { zindex =99 } ) 11946if not multigrid then 11947screen : expect { mode ='normal' } 11948end 11949 11950-- Not obscured by a hidden floatwin. 11951api . nvim_win_set_config ( float_win_above , { hide =true , zindex =100 } ) 11952if multigrid then 11953screen : expect ( { 11954grid =[[ 11955## grid 1 11956[2:--------------------------------------------------]|*19 11957[3:--------------------------------------------------]| 11958## grid 2 11959one | 11960two | 11961three | 11962{0:~ }|*16 11963## grid 3 11964| 11965## grid 7 11966{33:┌─────┐}| 11967{33:│}{1:^ x}{33:│}| 11968{33:│}{2: ~}{33:│}|*4 11969{33:└─────┘}| 11970## grid 8 (hidden) 11971{1: }| 11972{2:~ }|*9 11973]] , 11974float_pos ={ 11975[ 7 ] ={ 1004 , 'NW' , 1 , 8 , 8 , true , 50 , 1 , 8 , 8 } , 11976} , 11977mode ='normal' , 11978} ) 11979else 11980screen : expect ( { 11981grid =[[ 11982one | 11983two | 11984three | 11985{0:~ }|*5 11986{0:~ }{33:┌─────┐}{0: }| 11987{0:~ }{33:│}{1:^ x}{33:│}{0: }| 11988{0:~ }{33:│}{2: ~}{33:│}{0: }|*4 11989{0:~ }{33:└─────┘}{0: }| 11990{0:~ }|*4 11991| 11992]] , 11993mode ='normal' , 11994} ) 11995end 11996 11997-- Not obscured in the command-line if curwin's cursor is obscured. 11998api . nvim_win_set_config ( float_win_above , { hide =false } ) 11999feed ( ':' ) 12000if multigrid then 12001screen : expect ( { 12002grid =[[ 12003## grid 1 12004[2:--------------------------------------------------]|*19 12005[3:--------------------------------------------------]| 12006## grid 2 12007one | 12008two | 12009three | 12010{0:~ }|*16 12011## grid 3 12012:^ | 12013## grid 7 12014{33:┌─────┐}| 12015{33:│}{1: x}{33:│}| 12016{33:│}{2: ~}{33:│}|*4 12017{33:└─────┘}| 12018## grid 8 12019{1: }| 12020{2:~ }|*9 12021]] , 12022float_pos ={ 12023[ 7 ] ={ 1004 , 'NW' , 1 , 8 , 8 , true , 50 , 1 , 8 , 8 } , 12024[ 8 ] ={ 1005 , 'NW' , 1 , 0 , 0 , true , 100 , 2 , 0 , 0 } , 12025} , 12026mode ='cmdline_normal' , 12027} ) 12028else 12029screen : expect { mode ='cmdline_normal' } 12030end 12031end ) 12032 12033it ( "window is not enlarged behind 'cmdheight'" , function () 12034local opts ={ relative ='editor' , width =10 , height =4 , row =0 , col =0 , zindex =199 } 12035opts . border ='single' 12036api . nvim_open_win ( 0 , true , opts ) 12037opts . zindex , opts . col =200 , 12 12038local above =api . nvim_open_win ( 0 , false , opts ) 12039command ( 'echo "cmdline" | wincmd +' ) 12040if multigrid then 12041screen : expect ( { 12042grid =[[ 12043## grid 1 12044[2:----------------------------------------]|*6 12045[3:----------------------------------------]| 12046## grid 2 12047| 12048{0:~ }|*5 12049## grid 3 12050cmdline | 12051## grid 4 12052{33:┌──────────┐}| 12053{33:│}{1:^ }{33:│}| 12054{33:│}{2:~ }{33:│}|*4 12055{33:└──────────┘}| 12056## grid 5 12057{33:┌──────────┐}| 12058{33:│}{1: }{33:│}| 12059{33:│}{2:~ }{33:│}|*3 12060{33:└──────────┘}| 12061]] , 12062float_pos ={ 12063[ 5 ] ={ 1002 , 'NW' , 1 , 0 , 12 , true , 200 , 3 , 0 , 12 } , 12064[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 0 , true , 199 , 1 , 0 , 0 } , 12065} , 12066} ) 12067else 12068screen : expect ( [[ 12069{33:┌──────────┐┌──────────┐} | 12070{33:│}{1:^ }{33:││}{1: }{33:│}{0: }| 12071{33:│}{2:~ }{33:││}{2:~ }{33:│}{0: }|*3 12072{33:└──────────┘└──────────┘}{0: }| 12073cmdline | 12074]] ) 12075end 12076api . nvim_set_current_win ( above ) 12077command ( 'wincmd +' ) 12078if multigrid then 12079screen : expect ( { 12080grid =[[ 12081## grid 1 12082[2:----------------------------------------]|*6 12083[3:----------------------------------------]| 12084## grid 2 12085| 12086{0:~ }|*5 12087## grid 3 12088cmdline | 12089## grid 4 12090{33:┌──────────┐}| 12091{33:│}{1: }{33:│}| 12092{33:│}{2:~ }{33:│}|*4 12093{33:└──────────┘}| 12094## grid 5 12095{33:┌──────────┐}| 12096{33:│}{1:^ }{33:│}| 12097{33:│}{2:~ }{33:│}|*4 12098{33:└──────────┘}| 12099]] , 12100float_pos ={ 12101[ 5 ] ={ 1002 , 'NW' , 1 , 0 , 12 , true , 200 , 3 , 0 , 12 } , 12102[ 4 ] ={ 1001 , 'NW' , 1 , 0 , 0 , true , 199 , 1 , 0 , 0 } , 12103} , 12104} ) 12105else 12106screen : expect ( [[ 12107{33:┌──────────┐┌──────────┐} | 12108{33:│}{1: }{33:││}{1:^ }{33:│}{0: }| 12109{33:│}{2:~ }{33:││}{2:~ }{33:│}{0: }|*3 12110{33:└──────────┘│}{2:~ }{33:│}{0: }| 12111cmdline {33:└──────────┘} | 12112]] ) 12113end 12114end ) 12115 12116it ( 'redrawn after moving tabpages via nvim_win_set_config()' , function () 12117local tab1_win =api . nvim_get_current_win () 12118fn . setline ( 1 , 'hello' ) 12119command ( 'tab split' ) 12120local tab2_win =api . nvim_get_current_win () 12121-- Schedule an UPD_NOT_VALID redraw, but in one event move the float out of curtab before it's 12122-- handled. Do not flush before then. 12123local float =exec_lua ( function () 12124local float =vim . api . nvim_open_win ( 0 , true , { relative ='editor' , width =10 , height =5 , row =1 , col =1 } ) 12125vim . api . nvim__redraw ( { valid =false , flush =false } ) 12126vim . api . nvim_win_set_config ( float , { win =tab1_win } ) 12127return float 12128end ) 12129 12130if multigrid then 12131screen : expect ( { 12132grid =[[ 12133## grid 1 12134{9: }{10:2}{9:+ [No Name] }{3: + [No Name] }{5: }{9:X}| 12135[4:----------------------------------------]|*5 12136[3:----------------------------------------]| 12137## grid 2 (hidden) 12138hello | 12139{0:~ }|*5 12140## grid 3 12141| 12142## grid 4 12143^hello | 12144{0:~ }|*4 12145]] , 12146} ) 12147else 12148screen : expect ( [[ 12149{9: }{10:2}{9:+ [No Name] }{3: + [No Name] }{5: }{9:X}| 12150^hello | 12151{0:~ }|*4 12152| 12153]] ) 12154end 12155 12156-- Importantly, want tabline redrawn and float's hl attribs to be correct here. 12157api . nvim_win_set_config ( float , { win =0 } ) 12158if multigrid then 12159screen : expect ( { 12160grid =[[ 12161## grid 1 12162{9: + [No Name] }{3: }{34:2}{3:+ [No Name] }{5: }{9:X}| 12163[4:----------------------------------------]|*5 12164[3:----------------------------------------]| 12165## grid 2 (hidden) 12166hello | 12167{0:~ }|*5 12168## grid 3 12169| 12170## grid 4 12171^hello | 12172{0:~ }|*4 12173## grid 5 12174{1:hello }| 12175{2:~ }|*4 12176]] , 12177float_pos ={ 12178[ 5 ] ={ 1002 , 'NW' , 1 , 1 , 1 , true , 50 , 1 , 1 , 1 } , 12179} , 12180} ) 12181else 12182screen : expect ( [[ 12183{9: + [No Name] }{3: }{34:2}{3:+ [No Name] }{5: }{9:X}| 12184^h{1:hello } | 12185{0:~}{2:~ }{0: }|*4 12186| 12187]] ) 12188end 12189 12190-- Autocommand runs within the first tabpage, but won't refresh grids when switching to it due 12191-- to switch_win_noblock having no_display set. 12192command ( 12193( 'autocmd OptionSet rightleft ++once call nvim_win_set_config(%d, #{relative: "win", win: %d, row: 0, col: 0})' ): format ( 12194float , 12195tab1_win 12196) 12197) 12198api . nvim_set_option_value ( 'rightleft' , true , { win =tab1_win } ) 12199-- Stale grids should not have caused issues with removing the float's grid. 12200if multigrid then 12201screen : expect ( { 12202grid =[[ 12203## grid 1 12204{9: }{10:2}{9:+ [No Name] }{3: + [No Name] }{5: }{9:X}| 12205[4:----------------------------------------]|*5 12206[3:----------------------------------------]| 12207## grid 2 (hidden) 12208hello | 12209{0:~ }|*5 12210## grid 3 12211| 12212## grid 4 12213^hello | 12214{0:~ }|*4 12215## grid 5 (hidden) 12216{1:hello }| 12217{2:~ }|*4 12218]] , 12219} ) 12220else 12221screen : expect ( [[ 12222{9: }{10:2}{9:+ [No Name] }{3: + [No Name] }{5: }{9:X}| 12223^hello | 12224{0:~ }|*4 12225| 12226]] ) 12227end 12228 12229command ( 'tabfirst' ) 12230if multigrid then 12231screen : expect ( { 12232grid =[[ 12233## grid 1 12234{3: }{34:2}{3:+ [No Name] }{9: + [No Name] }{5: }{9:X}| 12235[2:----------------------------------------]|*5 12236[3:----------------------------------------]| 12237## grid 2 12238olle^h| 12239{0: ~}|*4 12240## grid 3 12241| 12242## grid 4 (hidden) 12243hello | 12244{0:~ }|*4 12245## grid 5 12246{1:hello }| 12247{2:~ }|*4 12248]] , 12249float_pos ={ 12250[ 5 ] ={ 1002 , 'NW' , 2 , 0 , 0 , true , 50 , 1 , 1 , 0 } , 12251} , 12252} ) 12253else 12254screen : expect ( [[ 12255{3: }{34:2}{3:+ [No Name] }{9: + [No Name] }{5: }{9:X}| 12256{1:hello } olle^h| 12257{2:~ }{0: ~}|*4 12258| 12259]] ) 12260end 12261 12262-- Check tablines are redrawn even when moving floats between two non-current tabpages. 12263command ( 'tabnew' ) 12264local tab3_win =api . nvim_get_current_win () 12265if multigrid then 12266screen : expect ( { 12267grid =[[ 12268## grid 1 12269{9: }{10:2}{9:+ No Name] }{3: [No Name] }{9: + [No Name] }{5: }{9:X}| 12270[6:----------------------------------------]|*5 12271[3:----------------------------------------]| 12272## grid 2 (hidden) 12273olleh| 12274{0: ~}|*4 12275## grid 3 12276| 12277## grid 4 (hidden) 12278hello | 12279{0:~ }|*4 12280## grid 5 (hidden) 12281{1:hello }| 12282{2:~ }|*4 12283## grid 6 12284^ | 12285{0: ~}|*4 12286]] , 12287} ) 12288else 12289screen : expect ( [[ 12290{9: }{10:2}{9:+ No Name] }{3: [No Name] }{9: + [No Name] }{5: }{9:X}| 12291^ | 12292{0: ~}|*4 12293| 12294]] ) 12295end 12296 12297api . nvim_win_set_config ( float , { win =tab2_win } ) 12298if multigrid then 12299screen : expect ( { 12300grid =[[ 12301## grid 1 12302{9: + [No Name] }{3: [No Name] }{9: }{10:2}{9:+ No Name] }{5: }{9:X}| 12303[6:----------------------------------------]|*5 12304[3:----------------------------------------]| 12305## grid 2 (hidden) 12306olleh| 12307{0: ~}|*4 12308## grid 3 12309| 12310## grid 4 (hidden) 12311hello | 12312{0:~ }|*4 12313## grid 5 (hidden) 12314{1:hello }| 12315{2:~ }|*4 12316## grid 6 12317^ | 12318{0: ~}|*4 12319]] , 12320} ) 12321else 12322screen : expect ( [[ 12323{9: + [No Name] }{3: [No Name] }{9: }{10:2}{9:+ No Name] }{5: }{9:X}| 12324^ | 12325{0: ~}|*4 12326| 12327]] ) 12328end 12329 12330-- Try converting a split to a float, then moving it to another tabpage in one call. 12331command ( 'set norightleft | new' ) 12332fn . setline ( 1 , 'floaty mcfloatface' ) 12333api . nvim_win_set_config ( 0 , { relative ='editor' , win =tab1_win , row =3 , col =3 , width =15 , height =5 } ) 12334if multigrid then 12335screen : expect ( { 12336grid =[[ 12337## grid 1 12338{9: }{10:2}{9:+ No Name] }{3: [No Name] }{9: }{10:2}{9:+ No Name] }{5: }{9:X}| 12339[6:----------------------------------------]|*5 12340[3:----------------------------------------]| 12341## grid 2 (hidden) 12342olleh| 12343{0: ~}|*4 12344## grid 3 12345| 12346## grid 4 (hidden) 12347hello | 12348{0:~ }|*4 12349## grid 5 (hidden) 12350{1:hello }| 12351{2:~ }|*4 12352## grid 6 12353^ | 12354{0:~ }|*4 12355## grid 7 (hidden) 12356floaty mcfloatface | 12357{0:~ }| 12358]] , 12359} ) 12360else 12361screen : expect ( [[ 12362{9: }{10:2}{9:+ No Name] }{3: [No Name] }{9: }{10:2}{9:+ No Name] }{5: }{9:X}| 12363^ | 12364{0:~ }|*4 12365| 12366]] ) 12367end 12368 12369command ( 'tabfirst' ) 12370if multigrid then 12371screen : expect ( { 12372grid =[[ 12373## grid 1 12374{3: }{34:2}{3:+ No Name] }{9: [No Name] }{10:2}{9:+ No Name] }{5: }{9:X}| 12375[2:----------------------------------------]|*5 12376[3:----------------------------------------]| 12377## grid 2 12378olle^h| 12379{0: ~}|*4 12380## grid 3 12381| 12382## grid 4 (hidden) 12383hello | 12384{0:~ }|*4 12385## grid 5 (hidden) 12386{1:hello }| 12387{2:~ }|*4 12388## grid 6 (hidden) 12389| 12390{0:~ }|*4 12391## grid 7 12392{1:floaty mcfloatf}| 12393{1:ace }| 12394{2:~ }|*3 12395]] , 12396float_pos ={ 12397[ 7 ] ={ 1004 , 'NW' , 1 , 3 , 3 , true , 50 , 1 , 1 , 3 } , 12398} , 12399} ) 12400else 12401screen : expect ( [[ 12402{3: }{34:2}{3:+ No Name] }{9: [No Name] }{10:2}{9:+ No Name] }{5: }{9:X}| 12403{1:floaty mcfloatf} olle^h| 12404{0: }{1:ace }{0: ~}| 12405{0: }{2:~ }{0: ~}|*3 12406| 12407]] ) 12408end 12409 12410-- Works when doing the same between two non-current tabpages. 12411local float2 =api . nvim_open_win ( 0 , false , { split ='below' , win =tab3_win } ) 12412api . nvim_win_set_config ( float2 , { relative ='win' , win =tab2_win , row =2 , col =7 , width =4 , height =4 , border ='single' } ) 12413if multigrid then 12414screen : expect ( { 12415grid =[[ 12416## grid 1 12417{3: }{34:2}{3:+ No Name] }{9: [No Name] }{10:3}{9:+ No Name] }{5: }{9:X}| 12418[2:----------------------------------------]|*5 12419[3:----------------------------------------]| 12420## grid 2 12421olle^h| 12422{0: ~}|*4 12423## grid 3 12424| 12425## grid 4 (hidden) 12426hello | 12427{0:~ }|*4 12428## grid 5 (hidden) 12429{1:hello }| 12430{2:~ }|*4 12431## grid 6 (hidden) 12432| 12433{0:~ }|*4 12434## grid 7 12435{1:floaty mcfloatf}| 12436{1:ace }| 12437{2:~ }|*3 12438]] , 12439float_pos ={ 12440[ 7 ] ={ 1004 , 'NW' , 1 , 3 , 3 , true , 50 , 1 , 1 , 3 } , 12441} , 12442} ) 12443else 12444screen : expect ( [[ 12445{3: }{34:2}{3:+ No Name] }{9: [No Name] }{10:3}{9:+ No Name] }{5: }{9:X}| 12446{1:floaty mcfloatf} olle^h| 12447{0: }{1:ace }{0: ~}| 12448{0: }{2:~ }{0: ~}|*3 12449| 12450]] ) 12451end 12452 12453command ( 'tabnext' ) 12454if multigrid then 12455screen : expect ( { 12456grid =[[ 12457## grid 1 12458{9: }{10:2}{9:+ No Name] }{3: [No Name] }{9: }{10:3}{9:+ No Name] }{5: }{9:X}| 12459[6:----------------------------------------]|*5 12460[3:----------------------------------------]| 12461## grid 2 (hidden) 12462olleh| 12463{0: ~}|*4 12464## grid 3 12465| 12466## grid 4 (hidden) 12467hello | 12468{0:~ }|*4 12469## grid 5 (hidden) 12470{1:hello }| 12471{2:~ }|*4 12472## grid 6 12473^ | 12474{0:~ }|*4 12475## grid 7 (hidden) 12476{1:floaty mcfloatf}| 12477{1:ace }| 12478{2:~ }|*3 12479]] , 12480} ) 12481else 12482screen : expect ( [[ 12483{9: }{10:2}{9:+ No Name] }{3: [No Name] }{9: }{10:3}{9:+ No Name] }{5: }{9:X}| 12484^ | 12485{0:~ }|*4 12486| 12487]] ) 12488end 12489 12490command ( 'tabnext' ) 12491if multigrid then 12492screen : expect ( { 12493grid =[[ 12494## grid 1 12495{9: }{10:2}{9:+ No Name] [No Name] }{3: }{34:3}{3:+ No Name] }{5: }{9:X}| 12496[4:----------------------------------------]|*5 12497[3:----------------------------------------]| 12498## grid 2 (hidden) 12499olleh| 12500{0: ~}|*4 12501## grid 3 12502| 12503## grid 4 12504^hello | 12505{0:~ }|*4 12506## grid 5 12507{1:hello }| 12508{2:~ }|*4 12509## grid 6 (hidden) 12510| 12511{0:~ }|*4 12512## grid 7 (hidden) 12513{1:floaty mcfloatf}| 12514{1:ace }| 12515{2:~ }|*3 12516## grid 8 12517{33:┌────┐}| 12518{33:│}{1:lleh}{33:│}| 12519{33:│}{1: o}{33:│}| 12520{33:│}{2: ~}{33:│}|*2 12521{33:└────┘}| 12522]] , 12523float_pos ={ 12524[ 5 ] ={ 1002 , 'NW' , 4 , 0 , 0 , true , 50 , 1 , 1 , 0 } , 12525[ 8 ] ={ 1005 , 'NW' , 4 , 2 , 7 , true , 50 , 2 , 0 , 7 } , 12526} , 12527} ) 12528else 12529screen : expect ( [[ 12530{9: }{10:2}{9:+ No }{33:┌────┐}{9: [No Name] }{3: }{34:3}{3:+ No Name] }{5: }{9:X}| 12531{1:^hello }{33:│}{1:lleh}{33:│} | 12532{2:~ }{33:│}{1: o}{33:│}{0: }| 12533{2:~ }{33:│}{2: ~}{33:│}{0: }|*2 12534{2:~ }{33:└────┘}{0: }| 12535| 12536]] ) 12537end 12538 12539-- Used relative=win on two floats relative to this window. 12540-- Split it to the right to ensure both follow. 12541command ( 'topleft vsplit' ) 12542if multigrid then 12543screen : expect ( { 12544grid =[[ 12545## grid 1 12546{9: }{10:2}{9:+ No Name] [No Name] }{3: }{34:4}{3:+ No Name] }{5: }{9:X}| 12547[9:--------------------]{5:│}[4:-------------------]|*4 12548{4:[No Name] [+] }{5:[No Name] [+] }| 12549[3:----------------------------------------]| 12550## grid 2 (hidden) 12551olleh| 12552{0: ~}|*4 12553## grid 3 12554| 12555## grid 4 12556hello | 12557{0:~ }|*3 12558## grid 5 12559{1:hello }| 12560{2:~ }|*4 12561## grid 6 (hidden) 12562| 12563{0:~ }|*4 12564## grid 7 (hidden) 12565{1:floaty mcfloatf}| 12566{1:ace }| 12567{2:~ }|*3 12568## grid 8 12569{33:┌────┐}| 12570{33:│}{1:lleh}{33:│}| 12571{33:│}{1: o}{33:│}| 12572{33:│}{2: ~}{33:│}|*2 12573{33:└────┘}| 12574## grid 9 12575^hello | 12576{0:~ }|*3 12577]] , 12578float_pos ={ 12579[ 5 ] ={ 1002 , 'NW' , 4 , 0 , 0 , true , 50 , 1 , 1 , 21 } , 12580[ 8 ] ={ 1005 , 'NW' , 4 , 2 , 7 , true , 50 , 2 , 0 , 28 } , 12581} , 12582} ) 12583else 12584screen : expect ( [[ 12585{9: }{10:2}{9:+ No Name] [No Name] }{3: }{34:4}{3:+ }{33:┌────┐}{3:e] }{5: }{9:X}| 12586^hello {5:│}{1:hello }{33:│}{1:lleh}{33:│} | 12587{0:~ }{5:│}{2:~ }{33:│}{1: o}{33:│}{0: }| 12588{0:~ }{5:│}{2:~ }{33:│}{2: ~}{33:│}{0: }|*2 12589{4:[No Name] [+] }{2:~ }{33:└────┘}{5: }| 12590| 12591]] ) 12592end 12593end ) 12594end 12595 12596describe ( 'with ext_multigrid and actual mouse grid' , function () 12597with_ext_multigrid ( true , true ) 12598end ) 12599 12600describe ( 'with ext_multigrid and mouse grid 0' , function () 12601with_ext_multigrid ( true , false ) 12602end ) 12603 12604describe ( 'without ext_multigrid' , function () 12605with_ext_multigrid ( false , false ) 12606end ) 12607end )