Bram Moolenaar | 991dea3 | 2016-05-24 11:31:32 +0200 | [diff] [blame] | 1 | " Tests for window cmd (:wincmd, :split, :vsplit, :resize and etc...) |
| 2 | |
Bram Moolenaar | a27e1dc | 2019-10-07 22:27:36 +0200 | [diff] [blame] | 3 | so check.vim |
| 4 | |
Bram Moolenaar | 991dea3 | 2016-05-24 11:31:32 +0200 | [diff] [blame] | 5 | func Test_window_cmd_ls0_with_split() |
| 6 | set ls=0 |
| 7 | set splitbelow |
| 8 | split |
| 9 | quit |
| 10 | call assert_equal(0, &lines - &cmdheight - winheight(0)) |
| 11 | new | only! |
| 12 | " |
| 13 | set splitbelow&vim |
| 14 | botright split |
| 15 | quit |
| 16 | call assert_equal(0, &lines - &cmdheight - winheight(0)) |
| 17 | new | only! |
| 18 | set ls&vim |
| 19 | endfunc |
| 20 | |
| 21 | func Test_window_cmd_cmdwin_with_vsp() |
Bram Moolenaar | 72cf47a | 2018-05-10 18:23:29 +0200 | [diff] [blame] | 22 | let efmt = 'Expected 0 but got %d (in ls=%d, %s window)' |
Bram Moolenaar | 991dea3 | 2016-05-24 11:31:32 +0200 | [diff] [blame] | 23 | for v in range(0, 2) |
| 24 | exec "set ls=" . v |
| 25 | vsplit |
| 26 | call feedkeys("q:\<CR>") |
| 27 | let ac = &lines - (&cmdheight + winheight(0) + !!v) |
| 28 | let emsg = printf(efmt, ac, v, 'left') |
| 29 | call assert_equal(0, ac, emsg) |
| 30 | wincmd w |
| 31 | let ac = &lines - (&cmdheight + winheight(0) + !!v) |
| 32 | let emsg = printf(efmt, ac, v, 'right') |
| 33 | call assert_equal(0, ac, emsg) |
| 34 | new | only! |
| 35 | endfor |
| 36 | set ls&vim |
| 37 | endfunc |
| 38 | |
Bram Moolenaar | 5d2ca04 | 2016-06-26 17:11:21 +0200 | [diff] [blame] | 39 | function Test_window_cmd_wincmd_gf() |
| 40 | let fname = 'test_gf.txt' |
| 41 | let swp_fname = '.' . fname . '.swp' |
| 42 | call writefile([], fname) |
| 43 | call writefile([], swp_fname) |
| 44 | function s:swap_exists() |
| 45 | let v:swapchoice = s:swap_choice |
| 46 | endfunc |
Bram Moolenaar | eaa49e4 | 2019-07-13 18:08:59 +0200 | [diff] [blame] | 47 | " Remove the catch-all that runtest.vim adds |
| 48 | au! SwapExists |
Bram Moolenaar | 5d2ca04 | 2016-06-26 17:11:21 +0200 | [diff] [blame] | 49 | augroup test_window_cmd_wincmd_gf |
| 50 | autocmd! |
| 51 | exec "autocmd SwapExists " . fname . " call s:swap_exists()" |
| 52 | augroup END |
| 53 | |
| 54 | call setline(1, fname) |
| 55 | " (E)dit anyway |
| 56 | let s:swap_choice = 'e' |
| 57 | wincmd gf |
| 58 | call assert_equal(2, tabpagenr()) |
| 59 | call assert_equal(fname, bufname("%")) |
| 60 | quit! |
| 61 | |
| 62 | " (Q)uit |
| 63 | let s:swap_choice = 'q' |
| 64 | wincmd gf |
| 65 | call assert_equal(1, tabpagenr()) |
| 66 | call assert_notequal(fname, bufname("%")) |
| 67 | new | only! |
| 68 | |
| 69 | call delete(fname) |
| 70 | call delete(swp_fname) |
| 71 | augroup! test_window_cmd_wincmd_gf |
| 72 | endfunc |
| 73 | |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 74 | func Test_window_quit() |
| 75 | e Xa |
| 76 | split Xb |
Bram Moolenaar | f92e58c | 2019-09-08 21:51:41 +0200 | [diff] [blame] | 77 | call assert_equal(2, '$'->winnr()) |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 78 | call assert_equal('Xb', bufname(winbufnr(1))) |
| 79 | call assert_equal('Xa', bufname(winbufnr(2))) |
| 80 | |
| 81 | wincmd q |
| 82 | call assert_equal(1, winnr('$')) |
| 83 | call assert_equal('Xa', bufname(winbufnr(1))) |
| 84 | |
| 85 | bw Xa Xb |
| 86 | endfunc |
| 87 | |
| 88 | func Test_window_horizontal_split() |
| 89 | call assert_equal(1, winnr('$')) |
| 90 | 3wincmd s |
| 91 | call assert_equal(2, winnr('$')) |
| 92 | call assert_equal(3, winheight(0)) |
Bram Moolenaar | f92e58c | 2019-09-08 21:51:41 +0200 | [diff] [blame] | 93 | call assert_equal(winwidth(1), 2->winwidth()) |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 94 | |
| 95 | call assert_fails('botright topleft wincmd s', 'E442:') |
| 96 | bw |
| 97 | endfunc |
| 98 | |
| 99 | func Test_window_vertical_split() |
| 100 | call assert_equal(1, winnr('$')) |
| 101 | 3wincmd v |
| 102 | call assert_equal(2, winnr('$')) |
| 103 | call assert_equal(3, winwidth(0)) |
| 104 | call assert_equal(winheight(1), winheight(2)) |
| 105 | |
| 106 | call assert_fails('botright topleft wincmd v', 'E442:') |
| 107 | bw |
| 108 | endfunc |
| 109 | |
Bram Moolenaar | 1bbb619 | 2018-11-10 16:02:01 +0100 | [diff] [blame] | 110 | " Test the ":wincmd ^" and "<C-W>^" commands. |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 111 | func Test_window_split_edit_alternate() |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 112 | |
Bram Moolenaar | 1bbb619 | 2018-11-10 16:02:01 +0100 | [diff] [blame] | 113 | " Test for failure when the alternate buffer/file no longer exists. |
| 114 | edit Xfoo | %bw |
| 115 | call assert_fails(':wincmd ^', 'E23') |
| 116 | |
| 117 | " Test for the expected behavior when we have two named buffers. |
| 118 | edit Xfoo | edit Xbar |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 119 | wincmd ^ |
Bram Moolenaar | 1bbb619 | 2018-11-10 16:02:01 +0100 | [diff] [blame] | 120 | call assert_equal('Xfoo', bufname(winbufnr(1))) |
| 121 | call assert_equal('Xbar', bufname(winbufnr(2))) |
| 122 | only |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 123 | |
Bram Moolenaar | 1bbb619 | 2018-11-10 16:02:01 +0100 | [diff] [blame] | 124 | " Test for the expected behavior when the alternate buffer is not named. |
| 125 | enew | let l:nr1 = bufnr('%') |
| 126 | edit Xfoo | let l:nr2 = bufnr('%') |
| 127 | wincmd ^ |
| 128 | call assert_equal(l:nr1, winbufnr(1)) |
| 129 | call assert_equal(l:nr2, winbufnr(2)) |
| 130 | only |
| 131 | |
Bram Moolenaar | d42333d | 2018-11-10 20:28:19 +0100 | [diff] [blame] | 132 | " FIXME: this currently fails on AppVeyor, but passes locally |
| 133 | if !has('win32') |
| 134 | " Test the Normal mode command. |
| 135 | call feedkeys("\<C-W>\<C-^>", 'tx') |
| 136 | call assert_equal(l:nr2, winbufnr(1)) |
| 137 | call assert_equal(l:nr1, winbufnr(2)) |
| 138 | endif |
Bram Moolenaar | 1bbb619 | 2018-11-10 16:02:01 +0100 | [diff] [blame] | 139 | |
| 140 | %bw! |
| 141 | endfunc |
| 142 | |
| 143 | " Test the ":[count]wincmd ^" and "[count]<C-W>^" commands. |
| 144 | func Test_window_split_edit_bufnr() |
| 145 | |
| 146 | %bwipeout |
| 147 | let l:nr = bufnr('%') + 1 |
| 148 | call assert_fails(':execute "normal! ' . l:nr . '\<C-W>\<C-^>"', 'E92') |
| 149 | call assert_fails(':' . l:nr . 'wincmd ^', 'E16') |
| 150 | call assert_fails(':0wincmd ^', 'E16') |
| 151 | |
| 152 | edit Xfoo | edit Xbar | edit Xbaz |
| 153 | let l:foo_nr = bufnr('Xfoo') |
| 154 | let l:bar_nr = bufnr('Xbar') |
| 155 | let l:baz_nr = bufnr('Xbaz') |
| 156 | |
Bram Moolenaar | 8617b40 | 2018-11-10 20:47:48 +0100 | [diff] [blame] | 157 | " FIXME: this currently fails on AppVeyor, but passes locally |
| 158 | if !has('win32') |
| 159 | call feedkeys(l:foo_nr . "\<C-W>\<C-^>", 'tx') |
| 160 | call assert_equal('Xfoo', bufname(winbufnr(1))) |
| 161 | call assert_equal('Xbaz', bufname(winbufnr(2))) |
| 162 | only |
Bram Moolenaar | 1bbb619 | 2018-11-10 16:02:01 +0100 | [diff] [blame] | 163 | |
Bram Moolenaar | 8617b40 | 2018-11-10 20:47:48 +0100 | [diff] [blame] | 164 | call feedkeys(l:bar_nr . "\<C-W>\<C-^>", 'tx') |
| 165 | call assert_equal('Xbar', bufname(winbufnr(1))) |
| 166 | call assert_equal('Xfoo', bufname(winbufnr(2))) |
| 167 | only |
Bram Moolenaar | 1bbb619 | 2018-11-10 16:02:01 +0100 | [diff] [blame] | 168 | |
Bram Moolenaar | 8617b40 | 2018-11-10 20:47:48 +0100 | [diff] [blame] | 169 | execute l:baz_nr . 'wincmd ^' |
| 170 | call assert_equal('Xbaz', bufname(winbufnr(1))) |
| 171 | call assert_equal('Xbar', bufname(winbufnr(2))) |
| 172 | endif |
Bram Moolenaar | 1bbb619 | 2018-11-10 16:02:01 +0100 | [diff] [blame] | 173 | |
| 174 | %bw! |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 175 | endfunc |
| 176 | |
| 177 | func Test_window_preview() |
Bram Moolenaar | 5a4c308 | 2019-12-01 15:23:11 +0100 | [diff] [blame] | 178 | CheckFeature quickfix |
| 179 | |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 180 | " Open a preview window |
| 181 | pedit Xa |
| 182 | call assert_equal(2, winnr('$')) |
| 183 | call assert_equal(0, &previewwindow) |
| 184 | |
| 185 | " Go to the preview window |
| 186 | wincmd P |
| 187 | call assert_equal(1, &previewwindow) |
| 188 | |
| 189 | " Close preview window |
| 190 | wincmd z |
| 191 | call assert_equal(1, winnr('$')) |
| 192 | call assert_equal(0, &previewwindow) |
| 193 | |
| 194 | call assert_fails('wincmd P', 'E441:') |
| 195 | endfunc |
| 196 | |
Bram Moolenaar | 026587b | 2019-08-17 15:08:00 +0200 | [diff] [blame] | 197 | func Test_window_preview_from_help() |
Bram Moolenaar | 5a4c308 | 2019-12-01 15:23:11 +0100 | [diff] [blame] | 198 | CheckFeature quickfix |
| 199 | |
Bram Moolenaar | 026587b | 2019-08-17 15:08:00 +0200 | [diff] [blame] | 200 | filetype on |
| 201 | call writefile(['/* some C code */'], 'Xpreview.c') |
| 202 | help |
| 203 | pedit Xpreview.c |
| 204 | wincmd P |
| 205 | call assert_equal(1, &previewwindow) |
| 206 | call assert_equal('c', &filetype) |
| 207 | wincmd z |
| 208 | |
| 209 | filetype off |
| 210 | close |
| 211 | call delete('Xpreview.c') |
| 212 | endfunc |
| 213 | |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 214 | func Test_window_exchange() |
| 215 | e Xa |
| 216 | |
| 217 | " Nothing happens with window exchange when there is 1 window |
| 218 | wincmd x |
| 219 | call assert_equal(1, winnr('$')) |
| 220 | |
| 221 | split Xb |
| 222 | split Xc |
| 223 | |
| 224 | call assert_equal('Xc', bufname(winbufnr(1))) |
| 225 | call assert_equal('Xb', bufname(winbufnr(2))) |
| 226 | call assert_equal('Xa', bufname(winbufnr(3))) |
| 227 | |
| 228 | " Exchange current window 1 with window 3 |
| 229 | 3wincmd x |
| 230 | call assert_equal('Xa', bufname(winbufnr(1))) |
| 231 | call assert_equal('Xb', bufname(winbufnr(2))) |
| 232 | call assert_equal('Xc', bufname(winbufnr(3))) |
| 233 | |
| 234 | " Exchange window with next when at the top window |
| 235 | wincmd x |
| 236 | call assert_equal('Xb', bufname(winbufnr(1))) |
| 237 | call assert_equal('Xa', bufname(winbufnr(2))) |
| 238 | call assert_equal('Xc', bufname(winbufnr(3))) |
| 239 | |
| 240 | " Exchange window with next when at the middle window |
| 241 | wincmd j |
| 242 | wincmd x |
| 243 | call assert_equal('Xb', bufname(winbufnr(1))) |
| 244 | call assert_equal('Xc', bufname(winbufnr(2))) |
| 245 | call assert_equal('Xa', bufname(winbufnr(3))) |
| 246 | |
| 247 | " Exchange window with next when at the bottom window. |
| 248 | " When there is no next window, it exchanges with the previous window. |
| 249 | wincmd j |
| 250 | wincmd x |
| 251 | call assert_equal('Xb', bufname(winbufnr(1))) |
| 252 | call assert_equal('Xa', bufname(winbufnr(2))) |
| 253 | call assert_equal('Xc', bufname(winbufnr(3))) |
| 254 | |
| 255 | bw Xa Xb Xc |
| 256 | endfunc |
| 257 | |
| 258 | func Test_window_rotate() |
| 259 | e Xa |
| 260 | split Xb |
| 261 | split Xc |
| 262 | call assert_equal('Xc', bufname(winbufnr(1))) |
| 263 | call assert_equal('Xb', bufname(winbufnr(2))) |
| 264 | call assert_equal('Xa', bufname(winbufnr(3))) |
| 265 | |
| 266 | " Rotate downwards |
| 267 | wincmd r |
| 268 | call assert_equal('Xa', bufname(winbufnr(1))) |
| 269 | call assert_equal('Xc', bufname(winbufnr(2))) |
| 270 | call assert_equal('Xb', bufname(winbufnr(3))) |
| 271 | |
| 272 | 2wincmd r |
| 273 | call assert_equal('Xc', bufname(winbufnr(1))) |
| 274 | call assert_equal('Xb', bufname(winbufnr(2))) |
| 275 | call assert_equal('Xa', bufname(winbufnr(3))) |
| 276 | |
| 277 | " Rotate upwards |
| 278 | wincmd R |
| 279 | call assert_equal('Xb', bufname(winbufnr(1))) |
| 280 | call assert_equal('Xa', bufname(winbufnr(2))) |
| 281 | call assert_equal('Xc', bufname(winbufnr(3))) |
| 282 | |
| 283 | 2wincmd R |
| 284 | call assert_equal('Xc', bufname(winbufnr(1))) |
| 285 | call assert_equal('Xb', bufname(winbufnr(2))) |
| 286 | call assert_equal('Xa', bufname(winbufnr(3))) |
| 287 | |
| 288 | bot vsplit |
| 289 | call assert_fails('wincmd R', 'E443:') |
| 290 | |
| 291 | bw Xa Xb Xc |
| 292 | endfunc |
| 293 | |
| 294 | func Test_window_height() |
| 295 | e Xa |
| 296 | split Xb |
| 297 | |
| 298 | let [wh1, wh2] = [winheight(1), winheight(2)] |
| 299 | " Active window (1) should have the same height or 1 more |
| 300 | " than the other window. |
| 301 | call assert_inrange(wh2, wh2 + 1, wh1) |
| 302 | |
| 303 | wincmd - |
| 304 | call assert_equal(wh1 - 1, winheight(1)) |
| 305 | call assert_equal(wh2 + 1, winheight(2)) |
| 306 | |
| 307 | wincmd + |
| 308 | call assert_equal(wh1, winheight(1)) |
Bram Moolenaar | f92e58c | 2019-09-08 21:51:41 +0200 | [diff] [blame] | 309 | call assert_equal(wh2, 2->winheight()) |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 310 | |
| 311 | 2wincmd _ |
| 312 | call assert_equal(2, winheight(1)) |
| 313 | call assert_equal(wh1 + wh2 - 2, winheight(2)) |
| 314 | |
| 315 | wincmd = |
| 316 | call assert_equal(wh1, winheight(1)) |
| 317 | call assert_equal(wh2, winheight(2)) |
| 318 | |
| 319 | 2wincmd _ |
| 320 | set winfixheight |
| 321 | split Xc |
| 322 | let [wh1, wh2, wh3] = [winheight(1), winheight(2), winheight(3)] |
| 323 | call assert_equal(2, winheight(2)) |
| 324 | call assert_inrange(wh3, wh3 + 1, wh1) |
| 325 | 3wincmd + |
| 326 | call assert_equal(2, winheight(2)) |
| 327 | call assert_equal(wh1 + 3, winheight(1)) |
| 328 | call assert_equal(wh3 - 3, winheight(3)) |
| 329 | wincmd = |
| 330 | call assert_equal(2, winheight(2)) |
| 331 | call assert_equal(wh1, winheight(1)) |
| 332 | call assert_equal(wh3, winheight(3)) |
| 333 | |
| 334 | wincmd j |
| 335 | set winfixheight& |
| 336 | |
| 337 | wincmd = |
| 338 | let [wh1, wh2, wh3] = [winheight(1), winheight(2), winheight(3)] |
| 339 | " Current window (2) should have the same height or 1 more |
| 340 | " than the other windows. |
| 341 | call assert_inrange(wh1, wh1 + 1, wh2) |
| 342 | call assert_inrange(wh3, wh3 + 1, wh2) |
| 343 | |
| 344 | bw Xa Xb Xc |
| 345 | endfunc |
| 346 | |
| 347 | func Test_window_width() |
| 348 | e Xa |
| 349 | vsplit Xb |
| 350 | |
| 351 | let [ww1, ww2] = [winwidth(1), winwidth(2)] |
| 352 | " Active window (1) should have the same width or 1 more |
| 353 | " than the other window. |
| 354 | call assert_inrange(ww2, ww2 + 1, ww1) |
| 355 | |
| 356 | wincmd < |
| 357 | call assert_equal(ww1 - 1, winwidth(1)) |
| 358 | call assert_equal(ww2 + 1, winwidth(2)) |
| 359 | |
| 360 | wincmd > |
| 361 | call assert_equal(ww1, winwidth(1)) |
| 362 | call assert_equal(ww2, winwidth(2)) |
| 363 | |
| 364 | 2wincmd | |
| 365 | call assert_equal(2, winwidth(1)) |
| 366 | call assert_equal(ww1 + ww2 - 2, winwidth(2)) |
| 367 | |
| 368 | wincmd = |
| 369 | call assert_equal(ww1, winwidth(1)) |
| 370 | call assert_equal(ww2, winwidth(2)) |
| 371 | |
| 372 | 2wincmd | |
| 373 | set winfixwidth |
| 374 | vsplit Xc |
| 375 | let [ww1, ww2, ww3] = [winwidth(1), winwidth(2), winwidth(3)] |
Bram Moolenaar | 38e3483 | 2017-03-19 20:22:36 +0100 | [diff] [blame] | 376 | call assert_equal(2, winwidth(2)) |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 377 | call assert_inrange(ww3, ww3 + 1, ww1) |
| 378 | 3wincmd > |
Bram Moolenaar | 38e3483 | 2017-03-19 20:22:36 +0100 | [diff] [blame] | 379 | call assert_equal(2, winwidth(2)) |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 380 | call assert_equal(ww1 + 3, winwidth(1)) |
| 381 | call assert_equal(ww3 - 3, winwidth(3)) |
| 382 | wincmd = |
Bram Moolenaar | 38e3483 | 2017-03-19 20:22:36 +0100 | [diff] [blame] | 383 | call assert_equal(2, winwidth(2)) |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 384 | call assert_equal(ww1, winwidth(1)) |
| 385 | call assert_equal(ww3, winwidth(3)) |
| 386 | |
| 387 | wincmd l |
| 388 | set winfixwidth& |
| 389 | |
| 390 | wincmd = |
| 391 | let [ww1, ww2, ww3] = [winwidth(1), winwidth(2), winwidth(3)] |
| 392 | " Current window (2) should have the same width or 1 more |
| 393 | " than the other windows. |
| 394 | call assert_inrange(ww1, ww1 + 1, ww2) |
| 395 | call assert_inrange(ww3, ww3 + 1, ww2) |
| 396 | |
| 397 | bw Xa Xb Xc |
| 398 | endfunc |
| 399 | |
Bram Moolenaar | 8eeeba8 | 2017-06-25 22:45:39 +0200 | [diff] [blame] | 400 | func Test_equalalways_on_close() |
| 401 | set equalalways |
| 402 | vsplit |
| 403 | windo split |
Bram Moolenaar | 1bbb619 | 2018-11-10 16:02:01 +0100 | [diff] [blame] | 404 | split |
Bram Moolenaar | 8eeeba8 | 2017-06-25 22:45:39 +0200 | [diff] [blame] | 405 | wincmd J |
| 406 | " now we have a frame top-left with two windows, a frame top-right with two |
| 407 | " windows and a frame at the bottom, full-width. |
| 408 | let height_1 = winheight(1) |
| 409 | let height_2 = winheight(2) |
| 410 | let height_3 = winheight(3) |
| 411 | let height_4 = winheight(4) |
| 412 | " closing the bottom window causes all windows to be resized. |
| 413 | close |
| 414 | call assert_notequal(height_1, winheight(1)) |
| 415 | call assert_notequal(height_2, winheight(2)) |
| 416 | call assert_notequal(height_3, winheight(3)) |
| 417 | call assert_notequal(height_4, winheight(4)) |
| 418 | call assert_equal(winheight(1), winheight(3)) |
| 419 | call assert_equal(winheight(2), winheight(4)) |
| 420 | |
| 421 | 1wincmd w |
| 422 | split |
| 423 | 4wincmd w |
| 424 | resize + 5 |
| 425 | " left column has three windows, equalized heights. |
| 426 | " right column has two windows, top one a bit higher |
| 427 | let height_1 = winheight(1) |
| 428 | let height_2 = winheight(2) |
| 429 | let height_4 = winheight(4) |
| 430 | let height_5 = winheight(5) |
| 431 | 3wincmd w |
| 432 | " closing window in left column equalizes heights in left column but not in |
| 433 | " the right column |
| 434 | close |
| 435 | call assert_notequal(height_1, winheight(1)) |
| 436 | call assert_notequal(height_2, winheight(2)) |
| 437 | call assert_equal(height_4, winheight(3)) |
| 438 | call assert_equal(height_5, winheight(4)) |
| 439 | |
| 440 | only |
| 441 | set equalalways& |
| 442 | endfunc |
| 443 | |
Bram Moolenaar | 22044dc | 2017-12-02 15:43:37 +0100 | [diff] [blame] | 444 | func Test_win_screenpos() |
Bram Moolenaar | 5a4c308 | 2019-12-01 15:23:11 +0100 | [diff] [blame] | 445 | CheckFeature quickfix |
| 446 | |
Bram Moolenaar | 22044dc | 2017-12-02 15:43:37 +0100 | [diff] [blame] | 447 | call assert_equal(1, winnr('$')) |
| 448 | split |
| 449 | vsplit |
| 450 | 10wincmd _ |
| 451 | 30wincmd | |
| 452 | call assert_equal([1, 1], win_screenpos(1)) |
| 453 | call assert_equal([1, 32], win_screenpos(2)) |
| 454 | call assert_equal([12, 1], win_screenpos(3)) |
| 455 | call assert_equal([0, 0], win_screenpos(4)) |
| 456 | only |
| 457 | endfunc |
| 458 | |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 459 | func Test_window_jump_tag() |
Bram Moolenaar | 5a4c308 | 2019-12-01 15:23:11 +0100 | [diff] [blame] | 460 | CheckFeature quickfix |
| 461 | |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 462 | help |
| 463 | /iccf |
| 464 | call assert_match('^|iccf|', getline('.')) |
| 465 | call assert_equal(2, winnr('$')) |
| 466 | 2wincmd } |
| 467 | call assert_equal(3, winnr('$')) |
| 468 | call assert_match('^|iccf|', getline('.')) |
| 469 | wincmd k |
| 470 | call assert_match('\*iccf\*', getline('.')) |
| 471 | call assert_equal(2, winheight(0)) |
| 472 | |
| 473 | wincmd z |
| 474 | set previewheight=4 |
| 475 | help |
| 476 | /bugs |
| 477 | wincmd } |
| 478 | wincmd k |
| 479 | call assert_match('\*bugs\*', getline('.')) |
| 480 | call assert_equal(4, winheight(0)) |
| 481 | set previewheight& |
| 482 | |
| 483 | %bw! |
| 484 | endfunc |
| 485 | |
| 486 | func Test_window_newtab() |
| 487 | e Xa |
| 488 | |
| 489 | call assert_equal(1, tabpagenr('$')) |
| 490 | call assert_equal("\nAlready only one window", execute('wincmd T')) |
| 491 | |
| 492 | split Xb |
| 493 | split Xc |
| 494 | |
| 495 | wincmd T |
| 496 | call assert_equal(2, tabpagenr('$')) |
| 497 | call assert_equal(['Xb', 'Xa'], map(tabpagebuflist(1), 'bufname(v:val)')) |
Bram Moolenaar | ce90e36 | 2019-09-08 18:58:44 +0200 | [diff] [blame] | 498 | call assert_equal(['Xc' ], map(2->tabpagebuflist(), 'bufname(v:val)')) |
Bram Moolenaar | 4520d44 | 2017-03-19 16:09:46 +0100 | [diff] [blame] | 499 | |
| 500 | %bw! |
| 501 | endfunc |
| 502 | |
Bram Moolenaar | f79225e | 2017-03-18 23:11:04 +0100 | [diff] [blame] | 503 | func Test_next_split_all() |
| 504 | " This was causing an illegal memory access. |
| 505 | n x |
| 506 | norm axxx |
| 507 | split |
| 508 | split |
| 509 | s/x |
| 510 | s/x |
| 511 | all |
| 512 | bwipe! |
| 513 | endfunc |
| 514 | |
Bram Moolenaar | 75373f3 | 2017-08-07 22:02:30 +0200 | [diff] [blame] | 515 | " Tests for adjusting window and contents |
| 516 | func GetScreenStr(row) |
| 517 | let str = "" |
| 518 | for c in range(1,3) |
| 519 | let str .= nr2char(screenchar(a:row, c)) |
| 520 | endfor |
| 521 | return str |
| 522 | endfunc |
| 523 | |
| 524 | func Test_window_contents() |
| 525 | enew! | only | new |
| 526 | call setline(1, range(1,256)) |
| 527 | |
| 528 | exe "norm! \<C-W>t\<C-W>=1Gzt\<C-W>w\<C-W>+" |
| 529 | redraw |
Bram Moolenaar | 72cf47a | 2018-05-10 18:23:29 +0200 | [diff] [blame] | 530 | let s3 = GetScreenStr(1) |
Bram Moolenaar | 75373f3 | 2017-08-07 22:02:30 +0200 | [diff] [blame] | 531 | wincmd p |
| 532 | call assert_equal(1, line("w0")) |
| 533 | call assert_equal('1 ', s3) |
| 534 | |
| 535 | exe "norm! \<C-W>t\<C-W>=50Gzt\<C-W>w\<C-W>+" |
| 536 | redraw |
Bram Moolenaar | 72cf47a | 2018-05-10 18:23:29 +0200 | [diff] [blame] | 537 | let s3 = GetScreenStr(1) |
Bram Moolenaar | 75373f3 | 2017-08-07 22:02:30 +0200 | [diff] [blame] | 538 | wincmd p |
| 539 | call assert_equal(50, line("w0")) |
| 540 | call assert_equal('50 ', s3) |
| 541 | |
| 542 | exe "norm! \<C-W>t\<C-W>=59Gzt\<C-W>w\<C-W>+" |
| 543 | redraw |
Bram Moolenaar | 72cf47a | 2018-05-10 18:23:29 +0200 | [diff] [blame] | 544 | let s3 = GetScreenStr(1) |
Bram Moolenaar | 75373f3 | 2017-08-07 22:02:30 +0200 | [diff] [blame] | 545 | wincmd p |
| 546 | call assert_equal(59, line("w0")) |
| 547 | call assert_equal('59 ', s3) |
| 548 | |
| 549 | bwipeout! |
| 550 | call test_garbagecollect_now() |
| 551 | endfunc |
| 552 | |
Bram Moolenaar | 2efb323 | 2017-12-19 12:27:23 +0100 | [diff] [blame] | 553 | func Test_window_colon_command() |
| 554 | " This was reading invalid memory. |
| 555 | exe "norm! v\<C-W>:\<C-U>echo v:version" |
| 556 | endfunc |
| 557 | |
Bram Moolenaar | 6f361c9 | 2018-01-31 19:06:50 +0100 | [diff] [blame] | 558 | func Test_access_freed_mem() |
Bram Moolenaar | 1417c76 | 2019-07-27 17:31:36 +0200 | [diff] [blame] | 559 | call assert_equal(&columns, winwidth(0)) |
Bram Moolenaar | 6f361c9 | 2018-01-31 19:06:50 +0100 | [diff] [blame] | 560 | " This was accessing freed memory |
| 561 | au * 0 vs xxx |
| 562 | arg 0 |
| 563 | argadd |
Bram Moolenaar | 1417c76 | 2019-07-27 17:31:36 +0200 | [diff] [blame] | 564 | call assert_fails("all", "E249:") |
Bram Moolenaar | 6f361c9 | 2018-01-31 19:06:50 +0100 | [diff] [blame] | 565 | au! |
| 566 | bwipe xxx |
Bram Moolenaar | 1417c76 | 2019-07-27 17:31:36 +0200 | [diff] [blame] | 567 | call assert_equal(&columns, winwidth(0)) |
Bram Moolenaar | 6f361c9 | 2018-01-31 19:06:50 +0100 | [diff] [blame] | 568 | endfunc |
| 569 | |
Bram Moolenaar | a27e1dc | 2019-10-07 22:27:36 +0200 | [diff] [blame] | 570 | func Test_insert_cleared_on_switch_to_term() |
| 571 | CheckFeature terminal |
| 572 | |
| 573 | set showmode |
| 574 | terminal |
| 575 | wincmd p |
| 576 | |
| 577 | call feedkeys("i\<C-O>", 'ntx') |
| 578 | redraw |
| 579 | |
| 580 | " The "-- (insert) --" indicator should be visible. |
| 581 | let chars = map(range(1, &columns), 'nr2char(screenchar(&lines, v:val))') |
| 582 | let str = trim(join(chars, '')) |
| 583 | call assert_equal('-- (insert) --', str) |
| 584 | |
| 585 | call feedkeys("\<C-W>p", 'ntx') |
| 586 | redraw |
| 587 | |
| 588 | " The "-- (insert) --" indicator should have been cleared. |
| 589 | let chars = map(range(1, &columns), 'nr2char(screenchar(&lines, v:val))') |
| 590 | let str = trim(join(chars, '')) |
| 591 | call assert_equal('', str) |
| 592 | |
| 593 | set showmode& |
| 594 | %bw! |
| 595 | endfunc |
| 596 | |
Bram Moolenaar | 5bab555 | 2018-04-13 20:41:29 +0200 | [diff] [blame] | 597 | func Test_visual_cleared_after_window_split() |
| 598 | new | only! |
| 599 | let smd_save = &showmode |
| 600 | set showmode |
| 601 | let ls_save = &laststatus |
| 602 | set laststatus=1 |
| 603 | call setline(1, ['a', 'b', 'c', 'd', '']) |
| 604 | norm! G |
| 605 | exe "norm! kkvk" |
| 606 | redraw |
| 607 | exe "norm! \<C-W>v" |
| 608 | redraw |
| 609 | " check if '-- VISUAL --' disappeared from command line |
| 610 | let columns = range(1, &columns) |
| 611 | let cmdlinechars = map(columns, 'nr2char(screenchar(&lines, v:val))') |
| 612 | let cmdline = join(cmdlinechars, '') |
| 613 | let cmdline_ltrim = substitute(cmdline, '^\s*', "", "") |
| 614 | let mode_shown = substitute(cmdline_ltrim, '\s*$', "", "") |
| 615 | call assert_equal('', mode_shown) |
| 616 | let &showmode = smd_save |
| 617 | let &laststatus = ls_save |
| 618 | bwipe! |
| 619 | endfunc |
| 620 | |
Bram Moolenaar | 72cf47a | 2018-05-10 18:23:29 +0200 | [diff] [blame] | 621 | func Test_winrestcmd() |
| 622 | 2split |
| 623 | 3vsplit |
| 624 | let a = winrestcmd() |
| 625 | call assert_equal(2, winheight(0)) |
| 626 | call assert_equal(3, winwidth(0)) |
| 627 | wincmd = |
| 628 | call assert_notequal(2, winheight(0)) |
| 629 | call assert_notequal(3, winwidth(0)) |
| 630 | exe a |
| 631 | call assert_equal(2, winheight(0)) |
| 632 | call assert_equal(3, winwidth(0)) |
| 633 | only |
| 634 | endfunc |
| 635 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 636 | func Fun_RenewFile() |
Bram Moolenaar | 026587b | 2019-08-17 15:08:00 +0200 | [diff] [blame] | 637 | " Need to wait a bit for the timestamp to be older. |
Bram Moolenaar | ce90e36 | 2019-09-08 18:58:44 +0200 | [diff] [blame] | 638 | let old_ftime = getftime("tmp.txt") |
| 639 | while getftime("tmp.txt") == old_ftime |
| 640 | sleep 100m |
| 641 | silent execute '!echo "1" > tmp.txt' |
| 642 | endwhile |
Bram Moolenaar | a42df59 | 2018-12-24 00:22:39 +0100 | [diff] [blame] | 643 | sp |
| 644 | wincmd p |
| 645 | edit! tmp.txt |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 646 | endfunc |
Bram Moolenaar | a42df59 | 2018-12-24 00:22:39 +0100 | [diff] [blame] | 647 | |
| 648 | func Test_window_prevwin() |
| 649 | " Can we make this work on MS-Windows? |
| 650 | if !has('unix') |
| 651 | return |
| 652 | endif |
| 653 | |
| 654 | set hidden autoread |
| 655 | call writefile(['2'], 'tmp.txt') |
| 656 | new tmp.txt |
| 657 | q |
Bram Moolenaar | a42df59 | 2018-12-24 00:22:39 +0100 | [diff] [blame] | 658 | call Fun_RenewFile() |
| 659 | call assert_equal(2, winnr()) |
| 660 | wincmd p |
| 661 | call assert_equal(1, winnr()) |
| 662 | wincmd p |
| 663 | q |
| 664 | call Fun_RenewFile() |
| 665 | call assert_equal(2, winnr()) |
| 666 | wincmd p |
| 667 | call assert_equal(1, winnr()) |
| 668 | wincmd p |
| 669 | " reset |
| 670 | q |
| 671 | call delete('tmp.txt') |
| 672 | set hidden&vim autoread&vim |
| 673 | delfunc Fun_RenewFile |
| 674 | endfunc |
| 675 | |
Bram Moolenaar | 8fcb60f | 2019-03-04 13:18:30 +0100 | [diff] [blame] | 676 | func Test_relative_cursor_position_in_one_line_window() |
| 677 | new |
| 678 | only |
| 679 | call setline(1, range(1, 10000)) |
| 680 | normal 50% |
| 681 | let lnum = getcurpos()[1] |
| 682 | split |
| 683 | split |
| 684 | " make third window take as many lines as possible, other windows will |
| 685 | " become one line |
| 686 | 3wincmd w |
| 687 | for i in range(1, &lines - 6) |
| 688 | wincmd + |
| 689 | redraw! |
| 690 | endfor |
| 691 | |
| 692 | " first and second window should show cursor line |
| 693 | let wininfo = getwininfo() |
| 694 | call assert_equal(lnum, wininfo[0].topline) |
| 695 | call assert_equal(lnum, wininfo[1].topline) |
| 696 | |
| 697 | only! |
| 698 | bwipe! |
| 699 | endfunc |
| 700 | |
| 701 | func Test_relative_cursor_position_after_move_and_resize() |
| 702 | let so_save = &so |
| 703 | set so=0 |
| 704 | enew |
| 705 | call setline(1, range(1, 10000)) |
| 706 | normal 50% |
| 707 | split |
| 708 | 1wincmd w |
| 709 | " Move cursor to first line in window |
| 710 | normal H |
| 711 | redraw! |
| 712 | " Reduce window height to two lines |
| 713 | let height = winheight(0) |
| 714 | while winheight(0) > 2 |
| 715 | wincmd - |
| 716 | redraw! |
| 717 | endwhile |
| 718 | " move cursor to second/last line in window |
| 719 | normal j |
| 720 | " restore previous height |
| 721 | while winheight(0) < height |
| 722 | wincmd + |
| 723 | redraw! |
| 724 | endwhile |
| 725 | " make window two lines again |
| 726 | while winheight(0) > 2 |
| 727 | wincmd - |
| 728 | redraw! |
| 729 | endwhile |
| 730 | |
| 731 | " cursor should be at bottom line |
| 732 | let info = getwininfo(win_getid())[0] |
| 733 | call assert_equal(info.topline + 1, getcurpos()[1]) |
| 734 | |
| 735 | only! |
| 736 | bwipe! |
| 737 | let &so = so_save |
| 738 | endfunc |
| 739 | |
| 740 | func Test_relative_cursor_position_after_resize() |
| 741 | let so_save = &so |
| 742 | set so=0 |
| 743 | enew |
| 744 | call setline(1, range(1, 10000)) |
| 745 | normal 50% |
| 746 | split |
| 747 | 1wincmd w |
| 748 | let winid1 = win_getid() |
| 749 | let info = getwininfo(winid1)[0] |
| 750 | " Move cursor to second line in window |
| 751 | exe "normal " . (info.topline + 1) . "G" |
| 752 | redraw! |
| 753 | let lnum = getcurpos()[1] |
| 754 | |
| 755 | " Make the window only two lines high, cursor should end up in top line |
| 756 | 2wincmd w |
| 757 | exe (info.height - 2) . "wincmd +" |
| 758 | redraw! |
| 759 | let info = getwininfo(winid1)[0] |
| 760 | call assert_equal(lnum, info.topline) |
| 761 | |
| 762 | only! |
| 763 | bwipe! |
| 764 | let &so = so_save |
| 765 | endfunc |
| 766 | |
| 767 | func Test_relative_cursor_second_line_after_resize() |
| 768 | let so_save = &so |
| 769 | set so=0 |
| 770 | enew |
| 771 | call setline(1, range(1, 10000)) |
| 772 | normal 50% |
| 773 | split |
| 774 | 1wincmd w |
| 775 | let winid1 = win_getid() |
| 776 | let info = getwininfo(winid1)[0] |
| 777 | |
| 778 | " Make the window only two lines high |
| 779 | 2wincmd _ |
| 780 | |
| 781 | " Move cursor to second line in window |
| 782 | normal H |
| 783 | normal j |
| 784 | |
| 785 | " Make window size bigger, then back to 2 lines |
| 786 | for i in range(1, 10) |
| 787 | wincmd + |
| 788 | redraw! |
| 789 | endfor |
| 790 | for i in range(1, 10) |
| 791 | wincmd - |
| 792 | redraw! |
| 793 | endfor |
| 794 | |
| 795 | " cursor should end up in bottom line |
| 796 | let info = getwininfo(winid1)[0] |
| 797 | call assert_equal(info.topline + 1, getcurpos()[1]) |
| 798 | |
| 799 | only! |
| 800 | bwipe! |
| 801 | let &so = so_save |
| 802 | endfunc |
| 803 | |
Bram Moolenaar | a9b2535 | 2019-05-12 14:25:30 +0200 | [diff] [blame] | 804 | func Test_split_noscroll() |
| 805 | let so_save = &so |
Bram Moolenaar | bd2d68c | 2019-05-18 15:36:11 +0200 | [diff] [blame] | 806 | enew |
| 807 | call setline(1, range(1, 8)) |
Bram Moolenaar | a9b2535 | 2019-05-12 14:25:30 +0200 | [diff] [blame] | 808 | normal 100% |
| 809 | split |
| 810 | |
| 811 | 1wincmd w |
| 812 | let winid1 = win_getid() |
| 813 | let info1 = getwininfo(winid1)[0] |
| 814 | |
| 815 | 2wincmd w |
| 816 | let winid2 = win_getid() |
| 817 | let info2 = getwininfo(winid2)[0] |
| 818 | |
| 819 | call assert_equal(1, info1.topline) |
| 820 | call assert_equal(1, info2.topline) |
| 821 | |
Bram Moolenaar | bd2d68c | 2019-05-18 15:36:11 +0200 | [diff] [blame] | 822 | " window that fits all lines by itself, but not when split: closing other |
| 823 | " window should restore fraction. |
Bram Moolenaar | a9b2535 | 2019-05-12 14:25:30 +0200 | [diff] [blame] | 824 | only! |
Bram Moolenaar | bd2d68c | 2019-05-18 15:36:11 +0200 | [diff] [blame] | 825 | call setline(1, range(1, &lines - 10)) |
| 826 | exe &lines / 4 |
| 827 | let winid1 = win_getid() |
| 828 | let info1 = getwininfo(winid1)[0] |
| 829 | call assert_equal(1, info1.topline) |
| 830 | new |
| 831 | redraw |
| 832 | close |
| 833 | let info1 = getwininfo(winid1)[0] |
| 834 | call assert_equal(1, info1.topline) |
| 835 | |
Bram Moolenaar | a9b2535 | 2019-05-12 14:25:30 +0200 | [diff] [blame] | 836 | bwipe! |
| 837 | let &so = so_save |
| 838 | endfunc |
| 839 | |
Bram Moolenaar | 46ad288 | 2019-04-08 20:01:47 +0200 | [diff] [blame] | 840 | " Tests for the winnr() function |
| 841 | func Test_winnr() |
| 842 | only | tabonly |
| 843 | call assert_equal(1, winnr('j')) |
| 844 | call assert_equal(1, winnr('k')) |
| 845 | call assert_equal(1, winnr('h')) |
| 846 | call assert_equal(1, winnr('l')) |
| 847 | |
| 848 | " create a set of horizontally and vertically split windows |
| 849 | leftabove new | wincmd p |
| 850 | leftabove new | wincmd p |
| 851 | rightbelow new | wincmd p |
| 852 | rightbelow new | wincmd p |
| 853 | leftabove vnew | wincmd p |
| 854 | leftabove vnew | wincmd p |
| 855 | rightbelow vnew | wincmd p |
| 856 | rightbelow vnew | wincmd p |
| 857 | |
| 858 | call assert_equal(8, winnr('j')) |
| 859 | call assert_equal(2, winnr('k')) |
| 860 | call assert_equal(4, winnr('h')) |
| 861 | call assert_equal(6, winnr('l')) |
| 862 | call assert_equal(9, winnr('2j')) |
| 863 | call assert_equal(1, winnr('2k')) |
| 864 | call assert_equal(3, winnr('2h')) |
| 865 | call assert_equal(7, winnr('2l')) |
| 866 | |
| 867 | " Error cases |
| 868 | call assert_fails("echo winnr('0.2k')", 'E15:') |
| 869 | call assert_equal(2, winnr('-2k')) |
| 870 | call assert_fails("echo winnr('-2xj')", 'E15:') |
| 871 | call assert_fails("echo winnr('j2j')", 'E15:') |
| 872 | call assert_fails("echo winnr('ll')", 'E15:') |
| 873 | call assert_fails("echo winnr('5')", 'E15:') |
| 874 | call assert_equal(4, winnr('0h')) |
| 875 | |
| 876 | tabnew |
| 877 | call assert_equal(8, tabpagewinnr(1, 'j')) |
Bram Moolenaar | ce90e36 | 2019-09-08 18:58:44 +0200 | [diff] [blame] | 878 | call assert_equal(2, 1->tabpagewinnr('k')) |
Bram Moolenaar | 46ad288 | 2019-04-08 20:01:47 +0200 | [diff] [blame] | 879 | call assert_equal(4, tabpagewinnr(1, 'h')) |
| 880 | call assert_equal(6, tabpagewinnr(1, 'l')) |
| 881 | |
| 882 | only | tabonly |
| 883 | endfunc |
| 884 | |
Bram Moolenaar | f92e58c | 2019-09-08 21:51:41 +0200 | [diff] [blame] | 885 | func Test_winrestview() |
| 886 | split runtest.vim |
| 887 | normal 50% |
| 888 | let view = winsaveview() |
| 889 | close |
| 890 | split runtest.vim |
| 891 | eval view->winrestview() |
| 892 | call assert_equal(view, winsaveview()) |
| 893 | |
| 894 | bwipe! |
| 895 | endfunc |
| 896 | |
Bram Moolenaar | d20dcb3 | 2019-09-10 21:22:58 +0200 | [diff] [blame] | 897 | func Test_win_splitmove() |
Bram Moolenaar | 5a4c308 | 2019-12-01 15:23:11 +0100 | [diff] [blame] | 898 | CheckFeature quickfix |
| 899 | |
Bram Moolenaar | d20dcb3 | 2019-09-10 21:22:58 +0200 | [diff] [blame] | 900 | edit a |
| 901 | leftabove split b |
| 902 | leftabove vsplit c |
| 903 | leftabove split d |
| 904 | call assert_equal(0, win_splitmove(winnr(), winnr('l'))) |
| 905 | call assert_equal(bufname(winbufnr(1)), 'c') |
| 906 | call assert_equal(bufname(winbufnr(2)), 'd') |
| 907 | call assert_equal(bufname(winbufnr(3)), 'b') |
| 908 | call assert_equal(bufname(winbufnr(4)), 'a') |
| 909 | call assert_equal(0, win_splitmove(winnr(), winnr('j'), {'vertical': 1})) |
| 910 | call assert_equal(0, win_splitmove(winnr(), winnr('j'), {'vertical': 1})) |
| 911 | call assert_equal(bufname(winbufnr(1)), 'c') |
| 912 | call assert_equal(bufname(winbufnr(2)), 'b') |
| 913 | call assert_equal(bufname(winbufnr(3)), 'd') |
| 914 | call assert_equal(bufname(winbufnr(4)), 'a') |
| 915 | call assert_equal(0, win_splitmove(winnr(), winnr('k'), {'vertical': 1})) |
| 916 | call assert_equal(bufname(winbufnr(1)), 'd') |
| 917 | call assert_equal(bufname(winbufnr(2)), 'c') |
| 918 | call assert_equal(bufname(winbufnr(3)), 'b') |
| 919 | call assert_equal(bufname(winbufnr(4)), 'a') |
| 920 | call assert_equal(0, win_splitmove(winnr(), winnr('j'), {'rightbelow': v:true})) |
| 921 | call assert_equal(bufname(winbufnr(1)), 'c') |
| 922 | call assert_equal(bufname(winbufnr(2)), 'b') |
| 923 | call assert_equal(bufname(winbufnr(3)), 'a') |
| 924 | call assert_equal(bufname(winbufnr(4)), 'd') |
| 925 | only | bd |
| 926 | |
| 927 | call assert_fails('call win_splitmove(winnr(), 123)', 'E957:') |
| 928 | call assert_fails('call win_splitmove(123, winnr())', 'E957:') |
| 929 | call assert_fails('call win_splitmove(winnr(), winnr())', 'E957:') |
Bram Moolenaar | 7b94e77 | 2020-01-06 21:03:24 +0100 | [diff] [blame^] | 930 | |
| 931 | tabnew |
| 932 | call assert_fails('call win_splitmove(1, win_getid(1, 1))', 'E957:') |
| 933 | tabclose |
Bram Moolenaar | d20dcb3 | 2019-09-10 21:22:58 +0200 | [diff] [blame] | 934 | endfunc |
| 935 | |
Bram Moolenaar | 9e4d821 | 2016-08-18 23:04:48 +0200 | [diff] [blame] | 936 | " vim: shiftwidth=2 sts=2 expandtab |