blob: 3d13d99ba136f6dfc03fe5335dccc7780883e4ea [file] [log] [blame]
Bram Moolenaarc31f9ae2017-07-23 22:02:02 +02001" Tests for the preview window
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +02002
Bram Moolenaar5a4c3082019-12-01 15:23:11 +01003source check.vim
4CheckFeature quickfix
Bram Moolenaarc31f9ae2017-07-23 22:02:02 +02005
6func Test_Psearch()
7 " this used to cause ml_get errors
8 help
9 let wincount = winnr('$')
10 0f
11 ps.
12 call assert_equal(wincount + 1, winnr('$'))
13 pclose
14 call assert_equal(wincount, winnr('$'))
15 bwipe
16endfunc
Bram Moolenaaree4e0c12020-04-06 21:35:05 +020017
18func Test_window_preview()
19 CheckFeature quickfix
20
21 " Open a preview window
22 pedit Xa
23 call assert_equal(2, winnr('$'))
24 call assert_equal(0, &previewwindow)
25
26 " Go to the preview window
27 wincmd P
28 call assert_equal(1, &previewwindow)
Bram Moolenaar0fe937f2020-06-16 22:42:04 +020029 call assert_equal('preview', win_gettype())
Bram Moolenaaree4e0c12020-04-06 21:35:05 +020030
31 " Close preview window
32 wincmd z
33 call assert_equal(1, winnr('$'))
34 call assert_equal(0, &previewwindow)
35
36 call assert_fails('wincmd P', 'E441:')
37endfunc
38
39func Test_window_preview_from_help()
40 CheckFeature quickfix
41
42 filetype on
Bram Moolenaar145d1fd2022-09-30 21:57:11 +010043 call writefile(['/* some C code */'], 'Xpreview.c', 'D')
Bram Moolenaaree4e0c12020-04-06 21:35:05 +020044 help
45 pedit Xpreview.c
46 wincmd P
47 call assert_equal(1, &previewwindow)
48 call assert_equal('c', &filetype)
49 wincmd z
50
51 filetype off
52 close
Bram Moolenaaree4e0c12020-04-06 21:35:05 +020053endfunc
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