robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqvim-patch:9.1.0948: Missing cmdline completion for :pbuffer (#31645)889f9a0c5d

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