blob: 6c9ddc289a530e780d0a006c70268e100d60fa3c [file] [log] [blame]
Bram Moolenaar991dea32016-05-24 11:31:32 +02001" Tests for window cmd (:wincmd, :split, :vsplit, :resize and etc...)
2
3func Test_window_cmd_ls0_with_split()
4 set ls=0
5 set splitbelow
6 split
7 quit
8 call assert_equal(0, &lines - &cmdheight - winheight(0))
9 new | only!
10 "
11 set splitbelow&vim
12 botright split
13 quit
14 call assert_equal(0, &lines - &cmdheight - winheight(0))
15 new | only!
16 set ls&vim
17endfunc
18
19func Test_window_cmd_cmdwin_with_vsp()
20 let efmt='Expected 0 but got %d (in ls=%d, %s window)'
21 for v in range(0, 2)
22 exec "set ls=" . v
23 vsplit
24 call feedkeys("q:\<CR>")
25 let ac = &lines - (&cmdheight + winheight(0) + !!v)
26 let emsg = printf(efmt, ac, v, 'left')
27 call assert_equal(0, ac, emsg)
28 wincmd w
29 let ac = &lines - (&cmdheight + winheight(0) + !!v)
30 let emsg = printf(efmt, ac, v, 'right')
31 call assert_equal(0, ac, emsg)
32 new | only!
33 endfor
34 set ls&vim
35endfunc
36
Bram Moolenaar5d2ca042016-06-26 17:11:21 +020037function Test_window_cmd_wincmd_gf()
38 let fname = 'test_gf.txt'
39 let swp_fname = '.' . fname . '.swp'
40 call writefile([], fname)
41 call writefile([], swp_fname)
42 function s:swap_exists()
43 let v:swapchoice = s:swap_choice
44 endfunc
45 augroup test_window_cmd_wincmd_gf
46 autocmd!
47 exec "autocmd SwapExists " . fname . " call s:swap_exists()"
48 augroup END
49
50 call setline(1, fname)
51 " (E)dit anyway
52 let s:swap_choice = 'e'
53 wincmd gf
54 call assert_equal(2, tabpagenr())
55 call assert_equal(fname, bufname("%"))
56 quit!
57
58 " (Q)uit
59 let s:swap_choice = 'q'
60 wincmd gf
61 call assert_equal(1, tabpagenr())
62 call assert_notequal(fname, bufname("%"))
63 new | only!
64
65 call delete(fname)
66 call delete(swp_fname)
67 augroup! test_window_cmd_wincmd_gf
68endfunc
69
Bram Moolenaarf79225e2017-03-18 23:11:04 +010070func Test_next_split_all()
71 " This was causing an illegal memory access.
72 n x
73 norm axxx
74 split
75 split
76 s/x
77 s/x
78 all
79 bwipe!
80endfunc
81
Bram Moolenaar9e4d8212016-08-18 23:04:48 +020082" vim: shiftwidth=2 sts=2 expandtab