blob: b7b908e76136713b6db202e03fc40692aa691ee6 [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
43 call writefile(['/* some C code */'], 'Xpreview.c')
44 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
53 call delete('Xpreview.c')
54endfunc
55
56func Test_multiple_preview_windows()
57 new
58 set previewwindow
59 new
60 call assert_fails('set previewwindow', 'E590:')
61 %bw!
62endfunc
63
64" vim: shiftwidth=2 sts=2 expandtab