robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
889f9a0c5d
master
1" Tests for the preview window 2 3source check.vim 4CheckFeature quickfix 5 6func Test_Psearch () 7" this used to cause ml_get errors 8help 9let wincount = winnr ( '$' ) 100 f 11ps . 12call assert_equal ( wincount + 1 , winnr ( '$' )) 13pclose 14call assert_equal ( wincount , winnr ( '$' )) 15bwipe 16endfunc 17 18func s: goto_preview_and_close () 19" Go to the preview window 20wincmd P 21call assert_equal ( 1 , & previewwindow ) 22call assert_equal ( 'preview' , win_gettype ()) 23 24" Close preview window 25wincmd z 26call assert_equal ( 1 , winnr ( '$' )) 27call assert_equal ( 0 , & previewwindow ) 28 29call assert_fails ( 'wincmd P' , 'E441:' ) 30endfunc 31 32func Test_window_preview () 33CheckFeature quickfix 34 35" Open a preview window 36pedit Xa 37call assert_equal ( 2 , winnr ( '$' )) 38call assert_equal ( 0 , & previewwindow ) 39 40call s: goto_preview_and_close () 41endfunc 42 43func Test_window_preview_from_pbuffer () 44CheckFeature quickfix 45 46call writefile ([ '/* some C code */' ], 'Xpreview.c' , 'D' ) 47edit Xpreview.c 48const buf_num = bufnr ( '%' ) 49enew 50 51call feedkeys ( ":pbuffer Xpre\<C-A>\<C-B>\"\<CR>" , 'xt' ) 52call assert_equal ( "\"pbuffer Xpreview.c" , @:) 53 54call assert_equal ( 1 , winnr ( '$' )) 55exe 'pbuffer ' . buf_num 56call assert_equal ( 2 , winnr ( '$' )) 57call assert_equal ( 0 , & previewwindow ) 58 59call s: goto_preview_and_close () 60 61call assert_equal ( 1 , winnr ( '$' )) 62pbuffer Xpreview.c 63call assert_equal ( 2 , winnr ( '$' )) 64call assert_equal ( 0 , & previewwindow ) 65 66call s: goto_preview_and_close () 67endfunc 68 69func Test_window_preview_terminal () 70CheckFeature quickfix 71" CheckFeature terminal 72 73" term ++curwin 74term 75const buf_num = bufnr ( '$' ) 76call assert_equal ( 1 , winnr ( '$' )) 77exe 'pbuffer' . buf_num 78call assert_equal ( 2 , winnr ( '$' )) 79call assert_equal ( 0 , & previewwindow ) 80 81call s: goto_preview_and_close () 82endfunc 83 84func Test_window_preview_from_help () 85CheckFeature quickfix 86 87filetype on 88call writefile ([ '/* some C code */' ], 'Xpreview.c' ) 89help 90pedit Xpreview.c 91wincmd P 92call assert_equal ( 1 , & previewwindow ) 93call assert_equal ( 'c' , & filetype ) 94wincmd z 95 96filetype off 97close 98call delete ( 'Xpreview.c' ) 99endfunc 100 101func Test_multiple_preview_windows () 102new 103set previewwindow 104new 105call assert_fails ( 'set previewwindow' , 'E590:' ) 106 %bw ! 107endfunc 108 109" vim: shiftwidth=2 sts=2 expandtab