blob: 1bf1d3f8be25bafec795d7e66b1c19ce551b4061 [file] [log] [blame]
Bram Moolenaarc31f9ae2017-07-23 22:02:02 +02001" Tests for the preview window
Bram Moolenaar5a4c3082019-12-01 15:23:11 +01002source check.vim
3CheckFeature quickfix
Bram Moolenaarc31f9ae2017-07-23 22:02:02 +02004
5func Test_Psearch()
6 " this used to cause ml_get errors
7 help
8 let wincount = winnr('$')
9 0f
10 ps.
11 call assert_equal(wincount + 1, winnr('$'))
12 pclose
13 call assert_equal(wincount, winnr('$'))
14 bwipe
15endfunc
Bram Moolenaaree4e0c12020-04-06 21:35:05 +020016
17func Test_window_preview()
18 CheckFeature quickfix
19
20 " Open a preview window
21 pedit Xa
22 call assert_equal(2, winnr('$'))
23 call assert_equal(0, &previewwindow)
24
25 " Go to the preview window
26 wincmd P
27 call assert_equal(1, &previewwindow)
Bram Moolenaar0fe937f2020-06-16 22:42:04 +020028 call assert_equal('preview', win_gettype())
Bram Moolenaaree4e0c12020-04-06 21:35:05 +020029
30 " Close preview window
31 wincmd z
32 call assert_equal(1, winnr('$'))
33 call assert_equal(0, &previewwindow)
34
35 call assert_fails('wincmd P', 'E441:')
36endfunc
37
38func Test_window_preview_from_help()
39 CheckFeature quickfix
40
41 filetype on
42 call writefile(['/* some C code */'], 'Xpreview.c')
43 help
44 pedit Xpreview.c
45 wincmd P
46 call assert_equal(1, &previewwindow)
47 call assert_equal('c', &filetype)
48 wincmd z
49
50 filetype off
51 close
52 call delete('Xpreview.c')
53endfunc
54
55func Test_multiple_preview_windows()
56 new
57 set previewwindow
58 new
59 call assert_fails('set previewwindow', 'E590:')
60 %bw!
61endfunc
62
63" vim: shiftwidth=2 sts=2 expandtab