1" 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 37function 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 70func Test_window_quit() 71 e Xa 72 split Xb 73 call assert_equal(2, winnr('$')) 74 call assert_equal('Xb', bufname(winbufnr(1))) 75 call assert_equal('Xa', bufname(winbufnr(2))) 76 77 wincmd q 78 call assert_equal(1, winnr('$')) 79 call assert_equal('Xa', bufname(winbufnr(1))) 80 81 bw Xa Xb 82endfunc 83 84func Test_window_horizontal_split() 85 call assert_equal(1, winnr('$')) 86 3wincmd s 87 call assert_equal(2, winnr('$')) 88 call assert_equal(3, winheight(0)) 89 call assert_equal(winwidth(1), winwidth(2)) 90 91 call assert_fails('botright topleft wincmd s', 'E442:') 92 bw 93endfunc 94 95func Test_window_vertical_split() 96 call assert_equal(1, winnr('$')) 97 3wincmd v 98 call assert_equal(2, winnr('$')) 99 call assert_equal(3, winwidth(0)) 100 call assert_equal(winheight(1), winheight(2)) 101 102 call assert_fails('botright topleft wincmd v', 'E442:') 103 bw 104endfunc 105 106" Test the ":wincmd ^" and "<C-W>^" commands. 107func Test_window_split_edit_alternate() 108 109 " Test for failure when the alternate buffer/file no longer exists. 110 edit Xfoo | %bw 111 call assert_fails(':wincmd ^', 'E23') 112 113 " Test for the expected behavior when we have two named buffers. 114 edit Xfoo | edit Xbar 115 wincmd ^ 116 call assert_equal('Xfoo', bufname(winbufnr(1))) 117 call assert_equal('Xbar', bufname(winbufnr(2))) 118 only 119 120 " Test for the expected behavior when the alternate buffer is not named. 121 enew | let l:nr1 = bufnr('%') 122 edit Xfoo | let l:nr2 = bufnr('%') 123 wincmd ^ 124 call assert_equal(l:nr1, winbufnr(1)) 125 call assert_equal(l:nr2, winbufnr(2)) 126 only 127 128 " FIXME: this currently fails on AppVeyor, but passes locally 129 if !has('win32') 130 " Test the Normal mode command. 131 call feedkeys("\<C-W>\<C-^>", 'tx') 132 call assert_equal(l:nr2, winbufnr(1)) 133 call assert_equal(l:nr1, winbufnr(2)) 134 endif 135 136 %bw! 137endfunc 138 139" Test the ":[count]wincmd ^" and "[count]<C-W>^" commands. 140func Test_window_split_edit_bufnr() 141 142 %bwipeout 143 let l:nr = bufnr('%') + 1 144 call assert_fails(':execute "normal! ' . l:nr . '\<C-W>\<C-^>"', 'E92') 145 call assert_fails(':' . l:nr . 'wincmd ^', 'E16') 146 call assert_fails(':0wincmd ^', 'E16') 147 148 edit Xfoo | edit Xbar | edit Xbaz 149 let l:foo_nr = bufnr('Xfoo') 150 let l:bar_nr = bufnr('Xbar') 151 let l:baz_nr = bufnr('Xbaz') 152 153 " FIXME: this currently fails on AppVeyor, but passes locally 154 if !has('win32') 155 call feedkeys(l:foo_nr . "\<C-W>\<C-^>", 'tx') 156 call assert_equal('Xfoo', bufname(winbufnr(1))) 157 call assert_equal('Xbaz', bufname(winbufnr(2))) 158 only 159 160 call feedkeys(l:bar_nr . "\<C-W>\<C-^>", 'tx') 161 call assert_equal('Xbar', bufname(winbufnr(1))) 162 call assert_equal('Xfoo', bufname(winbufnr(2))) 163 only 164 165 execute l:baz_nr . 'wincmd ^' 166 call assert_equal('Xbaz', bufname(winbufnr(1))) 167 call assert_equal('Xbar', bufname(winbufnr(2))) 168 endif 169 170 %bw! 171endfunc 172 173func Test_window_preview() 174 " Open a preview window 175 pedit Xa 176 call assert_equal(2, winnr('$')) 177 call assert_equal(0, &previewwindow) 178 179 " Go to the preview window 180 wincmd P 181 call assert_equal(1, &previewwindow) 182 183 " Close preview window 184 wincmd z 185 call assert_equal(1, winnr('$')) 186 call assert_equal(0, &previewwindow) 187 188 call assert_fails('wincmd P', 'E441:') 189endfunc 190 191func Test_window_exchange() 192 e Xa 193 194 " Nothing happens with window exchange when there is 1 window 195 wincmd x 196 call assert_equal(1, winnr('$')) 197 198 split Xb 199 split Xc 200 201 call assert_equal('Xc', bufname(winbufnr(1))) 202 call assert_equal('Xb', bufname(winbufnr(2))) 203 call assert_equal('Xa', bufname(winbufnr(3))) 204 205 " Exchange current window 1 with window 3 206 3wincmd x 207 call assert_equal('Xa', bufname(winbufnr(1))) 208 call assert_equal('Xb', bufname(winbufnr(2))) 209 call assert_equal('Xc', bufname(winbufnr(3))) 210 211 " Exchange window with next when at the top window 212 wincmd x 213 call assert_equal('Xb', bufname(winbufnr(1))) 214 call assert_equal('Xa', bufname(winbufnr(2))) 215 call assert_equal('Xc', bufname(winbufnr(3))) 216 217 " Exchange window with next when at the middle window 218 wincmd j 219 wincmd x 220 call assert_equal('Xb', bufname(winbufnr(1))) 221 call assert_equal('Xc', bufname(winbufnr(2))) 222 call assert_equal('Xa', bufname(winbufnr(3))) 223 224 " Exchange window with next when at the bottom window. 225 " When there is no next window, it exchanges with the previous window. 226 wincmd j 227 wincmd x 228 call assert_equal('Xb', bufname(winbufnr(1))) 229 call assert_equal('Xa', bufname(winbufnr(2))) 230 call assert_equal('Xc', bufname(winbufnr(3))) 231 232 bw Xa Xb Xc 233endfunc 234 235func Test_window_rotate() 236 e Xa 237 split Xb 238 split Xc 239 call assert_equal('Xc', bufname(winbufnr(1))) 240 call assert_equal('Xb', bufname(winbufnr(2))) 241 call assert_equal('Xa', bufname(winbufnr(3))) 242 243 " Rotate downwards 244 wincmd r 245 call assert_equal('Xa', bufname(winbufnr(1))) 246 call assert_equal('Xc', bufname(winbufnr(2))) 247 call assert_equal('Xb', bufname(winbufnr(3))) 248 249 2wincmd r 250 call assert_equal('Xc', bufname(winbufnr(1))) 251 call assert_equal('Xb', bufname(winbufnr(2))) 252 call assert_equal('Xa', bufname(winbufnr(3))) 253 254 " Rotate upwards 255 wincmd R 256 call assert_equal('Xb', bufname(winbufnr(1))) 257 call assert_equal('Xa', bufname(winbufnr(2))) 258 call assert_equal('Xc', bufname(winbufnr(3))) 259 260 2wincmd R 261 call assert_equal('Xc', bufname(winbufnr(1))) 262 call assert_equal('Xb', bufname(winbufnr(2))) 263 call assert_equal('Xa', bufname(winbufnr(3))) 264 265 bot vsplit 266 call assert_fails('wincmd R', 'E443:') 267 268 bw Xa Xb Xc 269endfunc 270 271func Test_window_height() 272 e Xa 273 split Xb 274 275 let [wh1, wh2] = [winheight(1), winheight(2)] 276 " Active window (1) should have the same height or 1 more 277 " than the other window. 278 call assert_inrange(wh2, wh2 + 1, wh1) 279 280 wincmd - 281 call assert_equal(wh1 - 1, winheight(1)) 282 call assert_equal(wh2 + 1, winheight(2)) 283 284 wincmd + 285 call assert_equal(wh1, winheight(1)) 286 call assert_equal(wh2, winheight(2)) 287 288 2wincmd _ 289 call assert_equal(2, winheight(1)) 290 call assert_equal(wh1 + wh2 - 2, winheight(2)) 291 292 wincmd = 293 call assert_equal(wh1, winheight(1)) 294 call assert_equal(wh2, winheight(2)) 295 296 2wincmd _ 297 set winfixheight 298 split Xc 299 let [wh1, wh2, wh3] = [winheight(1), winheight(2), winheight(3)] 300 call assert_equal(2, winheight(2)) 301 call assert_inrange(wh3, wh3 + 1, wh1) 302 3wincmd + 303 call assert_equal(2, winheight(2)) 304 call assert_equal(wh1 + 3, winheight(1)) 305 call assert_equal(wh3 - 3, winheight(3)) 306 wincmd = 307 call assert_equal(2, winheight(2)) 308 call assert_equal(wh1, winheight(1)) 309 call assert_equal(wh3, winheight(3)) 310 311 wincmd j 312 set winfixheight& 313 314 wincmd = 315 let [wh1, wh2, wh3] = [winheight(1), winheight(2), winheight(3)] 316 " Current window (2) should have the same height or 1 more 317 " than the other windows. 318 call assert_inrange(wh1, wh1 + 1, wh2) 319 call assert_inrange(wh3, wh3 + 1, wh2) 320 321 bw Xa Xb Xc 322endfunc 323 324func Test_window_width() 325 e Xa 326 vsplit Xb 327 328 let [ww1, ww2] = [winwidth(1), winwidth(2)] 329 " Active window (1) should have the same width or 1 more 330 " than the other window. 331 call assert_inrange(ww2, ww2 + 1, ww1) 332 333 wincmd < 334 call assert_equal(ww1 - 1, winwidth(1)) 335 call assert_equal(ww2 + 1, winwidth(2)) 336 337 wincmd > 338 call assert_equal(ww1, winwidth(1)) 339 call assert_equal(ww2, winwidth(2)) 340 341 2wincmd | 342 call assert_equal(2, winwidth(1)) 343 call assert_equal(ww1 + ww2 - 2, winwidth(2)) 344 345 wincmd = 346 call assert_equal(ww1, winwidth(1)) 347 call assert_equal(ww2, winwidth(2)) 348 349 2wincmd | 350 set winfixwidth 351 vsplit Xc 352 let [ww1, ww2, ww3] = [winwidth(1), winwidth(2), winwidth(3)] 353 call assert_equal(2, winwidth(2)) 354 call assert_inrange(ww3, ww3 + 1, ww1) 355 3wincmd > 356 call assert_equal(2, winwidth(2)) 357 call assert_equal(ww1 + 3, winwidth(1)) 358 call assert_equal(ww3 - 3, winwidth(3)) 359 wincmd = 360 call assert_equal(2, winwidth(2)) 361 call assert_equal(ww1, winwidth(1)) 362 call assert_equal(ww3, winwidth(3)) 363 364 wincmd l 365 set winfixwidth& 366 367 wincmd = 368 let [ww1, ww2, ww3] = [winwidth(1), winwidth(2), winwidth(3)] 369 " Current window (2) should have the same width or 1 more 370 " than the other windows. 371 call assert_inrange(ww1, ww1 + 1, ww2) 372 call assert_inrange(ww3, ww3 + 1, ww2) 373 374 bw Xa Xb Xc 375endfunc 376 377func Test_equalalways_on_close() 378 set equalalways 379 vsplit 380 windo split 381 split 382 wincmd J 383 " now we have a frame top-left with two windows, a frame top-right with two 384 " windows and a frame at the bottom, full-width. 385 let height_1 = winheight(1) 386 let height_2 = winheight(2) 387 let height_3 = winheight(3) 388 let height_4 = winheight(4) 389 " closing the bottom window causes all windows to be resized. 390 close 391 call assert_notequal(height_1, winheight(1)) 392 call assert_notequal(height_2, winheight(2)) 393 call assert_notequal(height_3, winheight(3)) 394 call assert_notequal(height_4, winheight(4)) 395 call assert_equal(winheight(1), winheight(3)) 396 call assert_equal(winheight(2), winheight(4)) 397 398 1wincmd w 399 split 400 4wincmd w 401 resize + 5 402 " left column has three windows, equalized heights. 403 " right column has two windows, top one a bit higher 404 let height_1 = winheight(1) 405 let height_2 = winheight(2) 406 let height_4 = winheight(4) 407 let height_5 = winheight(5) 408 3wincmd w 409 " closing window in left column equalizes heights in left column but not in 410 " the right column 411 close 412 call assert_notequal(height_1, winheight(1)) 413 call assert_notequal(height_2, winheight(2)) 414 call assert_equal(height_4, winheight(3)) 415 call assert_equal(height_5, winheight(4)) 416 417 only 418 set equalalways& 419endfunc 420 421func Test_win_screenpos() 422 call assert_equal(1, winnr('$')) 423 split 424 vsplit 425 10wincmd _ 426 30wincmd | 427 call assert_equal([1, 1], win_screenpos(1)) 428 call assert_equal([1, 32], win_screenpos(2)) 429 call assert_equal([12, 1], win_screenpos(3)) 430 call assert_equal([0, 0], win_screenpos(4)) 431 only 432endfunc 433 434func Test_window_jump_tag() 435 help 436 /iccf 437 call assert_match('^|iccf|', getline('.')) 438 call assert_equal(2, winnr('$')) 439 2wincmd } 440 call assert_equal(3, winnr('$')) 441 call assert_match('^|iccf|', getline('.')) 442 wincmd k 443 call assert_match('\*iccf\*', getline('.')) 444 call assert_equal(2, winheight(0)) 445 446 wincmd z 447 set previewheight=4 448 help 449 /bugs 450 wincmd } 451 wincmd k 452 call assert_match('\*bugs\*', getline('.')) 453 call assert_equal(4, winheight(0)) 454 set previewheight& 455 456 %bw! 457endfunc 458 459func Test_window_newtab() 460 e Xa 461 462 call assert_equal(1, tabpagenr('$')) 463 call assert_equal("\nAlready only one window", execute('wincmd T')) 464 465 split Xb 466 split Xc 467 468 wincmd T 469 call assert_equal(2, tabpagenr('$')) 470 call assert_equal(['Xb', 'Xa'], map(tabpagebuflist(1), 'bufname(v:val)')) 471 call assert_equal(['Xc' ], map(tabpagebuflist(2), 'bufname(v:val)')) 472 473 %bw! 474endfunc 475 476func Test_next_split_all() 477 " This was causing an illegal memory access. 478 n x 479 norm axxx 480 split 481 split 482 s/x 483 s/x 484 all 485 bwipe! 486endfunc 487 488" Tests for adjusting window and contents 489func GetScreenStr(row) 490 let str = "" 491 for c in range(1,3) 492 let str .= nr2char(screenchar(a:row, c)) 493 endfor 494 return str 495endfunc 496 497func Test_window_contents() 498 enew! | only | new 499 call setline(1, range(1,256)) 500 501 exe "norm! \<C-W>t\<C-W>=1Gzt\<C-W>w\<C-W>+" 502 redraw 503 let s3 = GetScreenStr(1) 504 wincmd p 505 call assert_equal(1, line("w0")) 506 call assert_equal('1 ', s3) 507 508 exe "norm! \<C-W>t\<C-W>=50Gzt\<C-W>w\<C-W>+" 509 redraw 510 let s3 = GetScreenStr(1) 511 wincmd p 512 call assert_equal(50, line("w0")) 513 call assert_equal('50 ', s3) 514 515 exe "norm! \<C-W>t\<C-W>=59Gzt\<C-W>w\<C-W>+" 516 redraw 517 let s3 = GetScreenStr(1) 518 wincmd p 519 call assert_equal(59, line("w0")) 520 call assert_equal('59 ', s3) 521 522 bwipeout! 523 call test_garbagecollect_now() 524endfunc 525 526func Test_window_colon_command() 527 " This was reading invalid memory. 528 exe "norm! v\<C-W>:\<C-U>echo v:version" 529endfunc 530 531func Test_access_freed_mem() 532 " This was accessing freed memory 533 au * 0 vs xxx 534 arg 0 535 argadd 536 all 537 all 538 au! 539 bwipe xxx 540endfunc 541 542func Test_visual_cleared_after_window_split() 543 new | only! 544 let smd_save = &showmode 545 set showmode 546 let ls_save = &laststatus 547 set laststatus=1 548 call setline(1, ['a', 'b', 'c', 'd', '']) 549 norm! G 550 exe "norm! kkvk" 551 redraw 552 exe "norm! \<C-W>v" 553 redraw 554 " check if '-- VISUAL --' disappeared from command line 555 let columns = range(1, &columns) 556 let cmdlinechars = map(columns, 'nr2char(screenchar(&lines, v:val))') 557 let cmdline = join(cmdlinechars, '') 558 let cmdline_ltrim = substitute(cmdline, '^\s*', "", "") 559 let mode_shown = substitute(cmdline_ltrim, '\s*$', "", "") 560 call assert_equal('', mode_shown) 561 let &showmode = smd_save 562 let &laststatus = ls_save 563 bwipe! 564endfunc 565 566func Test_winrestcmd() 567 2split 568 3vsplit 569 let a = winrestcmd() 570 call assert_equal(2, winheight(0)) 571 call assert_equal(3, winwidth(0)) 572 wincmd = 573 call assert_notequal(2, winheight(0)) 574 call assert_notequal(3, winwidth(0)) 575 exe a 576 call assert_equal(2, winheight(0)) 577 call assert_equal(3, winwidth(0)) 578 only 579endfunc 580 581func Fun_RenewFile() 582 sleep 2 583 silent execute '!echo "1" > tmp.txt' 584 sp 585 wincmd p 586 edit! tmp.txt 587endfunc 588 589func Test_window_prevwin() 590 " Can we make this work on MS-Windows? 591 if !has('unix') 592 return 593 endif 594 595 set hidden autoread 596 call writefile(['2'], 'tmp.txt') 597 new tmp.txt 598 q 599 " Need to wait a bit for the timestamp to be older. 600 call Fun_RenewFile() 601 call assert_equal(2, winnr()) 602 wincmd p 603 call assert_equal(1, winnr()) 604 wincmd p 605 q 606 call Fun_RenewFile() 607 call assert_equal(2, winnr()) 608 wincmd p 609 call assert_equal(1, winnr()) 610 wincmd p 611 " reset 612 q 613 call delete('tmp.txt') 614 set hidden&vim autoread&vim 615 delfunc Fun_RenewFile 616endfunc 617 618func Test_relative_cursor_position_in_one_line_window() 619 new 620 only 621 call setline(1, range(1, 10000)) 622 normal 50% 623 let lnum = getcurpos()[1] 624 split 625 split 626 " make third window take as many lines as possible, other windows will 627 " become one line 628 3wincmd w 629 for i in range(1, &lines - 6) 630 wincmd + 631 redraw! 632 endfor 633 634 " first and second window should show cursor line 635 let wininfo = getwininfo() 636 call assert_equal(lnum, wininfo[0].topline) 637 call assert_equal(lnum, wininfo[1].topline) 638 639 only! 640 bwipe! 641endfunc 642 643func Test_relative_cursor_position_after_move_and_resize() 644 let so_save = &so 645 set so=0 646 enew 647 call setline(1, range(1, 10000)) 648 normal 50% 649 split 650 1wincmd w 651 " Move cursor to first line in window 652 normal H 653 redraw! 654 " Reduce window height to two lines 655 let height = winheight(0) 656 while winheight(0) > 2 657 wincmd - 658 redraw! 659 endwhile 660 " move cursor to second/last line in window 661 normal j 662 " restore previous height 663 while winheight(0) < height 664 wincmd + 665 redraw! 666 endwhile 667 " make window two lines again 668 while winheight(0) > 2 669 wincmd - 670 redraw! 671 endwhile 672 673 " cursor should be at bottom line 674 let info = getwininfo(win_getid())[0] 675 call assert_equal(info.topline + 1, getcurpos()[1]) 676 677 only! 678 bwipe! 679 let &so = so_save 680endfunc 681 682func Test_relative_cursor_position_after_resize() 683 let so_save = &so 684 set so=0 685 enew 686 call setline(1, range(1, 10000)) 687 normal 50% 688 split 689 1wincmd w 690 let winid1 = win_getid() 691 let info = getwininfo(winid1)[0] 692 " Move cursor to second line in window 693 exe "normal " . (info.topline + 1) . "G" 694 redraw! 695 let lnum = getcurpos()[1] 696 697 " Make the window only two lines high, cursor should end up in top line 698 2wincmd w 699 exe (info.height - 2) . "wincmd +" 700 redraw! 701 let info = getwininfo(winid1)[0] 702 call assert_equal(lnum, info.topline) 703 704 only! 705 bwipe! 706 let &so = so_save 707endfunc 708 709func Test_relative_cursor_second_line_after_resize() 710 let so_save = &so 711 set so=0 712 enew 713 call setline(1, range(1, 10000)) 714 normal 50% 715 split 716 1wincmd w 717 let winid1 = win_getid() 718 let info = getwininfo(winid1)[0] 719 720 " Make the window only two lines high 721 2wincmd _ 722 723 " Move cursor to second line in window 724 normal H 725 normal j 726 727 " Make window size bigger, then back to 2 lines 728 for i in range(1, 10) 729 wincmd + 730 redraw! 731 endfor 732 for i in range(1, 10) 733 wincmd - 734 redraw! 735 endfor 736 737 " cursor should end up in bottom line 738 let info = getwininfo(winid1)[0] 739 call assert_equal(info.topline + 1, getcurpos()[1]) 740 741 only! 742 bwipe! 743 let &so = so_save 744endfunc 745 746func Test_split_noscroll() 747 let so_save = &so 748 enew 749 call setline(1, range(1, 8)) 750 normal 100% 751 split 752 753 1wincmd w 754 let winid1 = win_getid() 755 let info1 = getwininfo(winid1)[0] 756 757 2wincmd w 758 let winid2 = win_getid() 759 let info2 = getwininfo(winid2)[0] 760 761 call assert_equal(1, info1.topline) 762 call assert_equal(1, info2.topline) 763 764 " window that fits all lines by itself, but not when split: closing other 765 " window should restore fraction. 766 only! 767 call setline(1, range(1, &lines - 10)) 768 exe &lines / 4 769 let winid1 = win_getid() 770 let info1 = getwininfo(winid1)[0] 771 call assert_equal(1, info1.topline) 772 new 773 redraw 774 close 775 let info1 = getwininfo(winid1)[0] 776 call assert_equal(1, info1.topline) 777 778 bwipe! 779 let &so = so_save 780endfunc 781 782" Tests for the winnr() function 783func Test_winnr() 784 only | tabonly 785 call assert_equal(1, winnr('j')) 786 call assert_equal(1, winnr('k')) 787 call assert_equal(1, winnr('h')) 788 call assert_equal(1, winnr('l')) 789 790 " create a set of horizontally and vertically split windows 791 leftabove new | wincmd p 792 leftabove new | wincmd p 793 rightbelow new | wincmd p 794 rightbelow new | wincmd p 795 leftabove vnew | wincmd p 796 leftabove vnew | wincmd p 797 rightbelow vnew | wincmd p 798 rightbelow vnew | wincmd p 799 800 call assert_equal(8, winnr('j')) 801 call assert_equal(2, winnr('k')) 802 call assert_equal(4, winnr('h')) 803 call assert_equal(6, winnr('l')) 804 call assert_equal(9, winnr('2j')) 805 call assert_equal(1, winnr('2k')) 806 call assert_equal(3, winnr('2h')) 807 call assert_equal(7, winnr('2l')) 808 809 " Error cases 810 call assert_fails("echo winnr('0.2k')", 'E15:') 811 call assert_equal(2, winnr('-2k')) 812 call assert_fails("echo winnr('-2xj')", 'E15:') 813 call assert_fails("echo winnr('j2j')", 'E15:') 814 call assert_fails("echo winnr('ll')", 'E15:') 815 call assert_fails("echo winnr('5')", 'E15:') 816 call assert_equal(4, winnr('0h')) 817 818 tabnew 819 call assert_equal(8, tabpagewinnr(1, 'j')) 820 call assert_equal(2, tabpagewinnr(1, 'k')) 821 call assert_equal(4, tabpagewinnr(1, 'h')) 822 call assert_equal(6, tabpagewinnr(1, 'l')) 823 824 only | tabonly 825endfunc 826 827" vim: shiftwidth=2 sts=2 expandtab 828