Bram Moolenaar | c31f9ae | 2017-07-23 22:02:02 +0200 | [diff] [blame] | 1 | " Tests for the preview window |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 2 | |
Bram Moolenaar | 5a4c308 | 2019-12-01 15:23:11 +0100 | [diff] [blame] | 3 | source check.vim |
| 4 | CheckFeature quickfix |
Bram Moolenaar | c31f9ae | 2017-07-23 22:02:02 +0200 | [diff] [blame] | 5 | |
| 6 | func 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 |
| 16 | endfunc |
Bram Moolenaar | ee4e0c1 | 2020-04-06 21:35:05 +0200 | [diff] [blame] | 17 | |
| 18 | func 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 Moolenaar | 0fe937f | 2020-06-16 22:42:04 +0200 | [diff] [blame] | 29 | call assert_equal('preview', win_gettype()) |
Bram Moolenaar | ee4e0c1 | 2020-04-06 21:35:05 +0200 | [diff] [blame] | 30 | |
| 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:') |
| 37 | endfunc |
| 38 | |
| 39 | func Test_window_preview_from_help() |
| 40 | CheckFeature quickfix |
| 41 | |
| 42 | filetype on |
Bram Moolenaar | 145d1fd | 2022-09-30 21:57:11 +0100 | [diff] [blame] | 43 | call writefile(['/* some C code */'], 'Xpreview.c', 'D') |
Bram Moolenaar | ee4e0c1 | 2020-04-06 21:35:05 +0200 | [diff] [blame] | 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 |
Bram Moolenaar | ee4e0c1 | 2020-04-06 21:35:05 +0200 | [diff] [blame] | 53 | endfunc |
| 54 | |
| 55 | func Test_multiple_preview_windows() |
| 56 | new |
| 57 | set previewwindow |
| 58 | new |
| 59 | call assert_fails('set previewwindow', 'E590:') |
| 60 | %bw! |
| 61 | endfunc |
| 62 | |
| 63 | " vim: shiftwidth=2 sts=2 expandtab |