multigrid_spec.lua (124225B)
1 local t = require('test.testutil') 2 local n = require('test.functional.testnvim')() 3 local Screen = require('test.functional.ui.screen') 4 5 local clear = n.clear 6 local feed, command, insert = n.feed, n.command, n.insert 7 local eq = t.eq 8 local fn = n.fn 9 local api = n.api 10 local curwin = n.api.nvim_get_current_win 11 local poke_eventloop = n.poke_eventloop 12 13 describe('ext_multigrid', function() 14 local screen 15 16 before_each(function() 17 clear { args_rm = { '--headless' }, args = { '--cmd', 'set laststatus=2' } } 18 screen = Screen.new(53, 14, { ext_multigrid = true }) 19 screen:set_default_attr_ids({ 20 [1] = { bold = true, foreground = Screen.colors.Blue1 }, 21 [2] = { foreground = Screen.colors.Magenta }, 22 [3] = { foreground = Screen.colors.Brown, bold = true }, 23 [4] = { foreground = Screen.colors.SlateBlue }, 24 [5] = { bold = true, foreground = Screen.colors.SlateBlue }, 25 [6] = { foreground = Screen.colors.Cyan4 }, 26 [7] = { bold = true }, 27 [8] = { underline = true, bold = true, foreground = Screen.colors.SlateBlue }, 28 [9] = { foreground = Screen.colors.SlateBlue, underline = true }, 29 [10] = { foreground = Screen.colors.Red }, 30 [11] = { bold = true, reverse = true }, 31 [12] = { reverse = true }, 32 [13] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey }, 33 [14] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, 34 [15] = { bold = true, foreground = Screen.colors.SeaGreen4 }, 35 [16] = { background = Screen.colors.LightGrey, underline = true }, 36 [17] = { background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta }, 37 [18] = { bold = true, foreground = Screen.colors.Magenta }, 38 [19] = { foreground = Screen.colors.Brown }, 39 [20] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, 40 [21] = { background = Screen.colors.LightMagenta }, 41 [22] = { background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue }, 42 [23] = { background = Screen.colors.Grey90 }, 43 [24] = { background = Screen.colors.Grey }, 44 }) 45 end) 46 47 it('default initial screen', function() 48 screen:expect { 49 grid = [[ 50 ## grid 1 51 [2:-----------------------------------------------------]|*12 52 {11:[No Name] }| 53 [3:-----------------------------------------------------]| 54 ## grid 2 55 ^ | 56 {1:~ }|*11 57 ## grid 3 58 | 59 ]], 60 } 61 end) 62 63 it('positions windows correctly', function() 64 command('vsplit') 65 screen:expect { 66 grid = [[ 67 ## grid 1 68 [4:--------------------------]│[2:--------------------------]|*12 69 {11:[No Name] }{12:[No Name] }| 70 [3:-----------------------------------------------------]| 71 ## grid 2 72 | 73 {1:~ }|*11 74 ## grid 3 75 | 76 ## grid 4 77 ^ | 78 {1:~ }|*11 79 ]], 80 condition = function() 81 eq({ 82 [2] = { win = 1000, startrow = 0, startcol = 27, width = 26, height = 12 }, 83 [4] = { win = 1001, startrow = 0, startcol = 0, width = 26, height = 12 }, 84 }, screen.win_position) 85 end, 86 } 87 command('wincmd l') 88 command('split') 89 screen:expect { 90 grid = [[ 91 ## grid 1 92 [4:--------------------------]│[5:--------------------------]|*6 93 [4:--------------------------]│{11:[No Name] }| 94 [4:--------------------------]│[2:--------------------------]|*5 95 {12:[No Name] [No Name] }| 96 [3:-----------------------------------------------------]| 97 ## grid 2 98 | 99 {1:~ }|*4 100 ## grid 3 101 | 102 ## grid 4 103 | 104 {1:~ }|*11 105 ## grid 5 106 ^ | 107 {1:~ }|*5 108 ]], 109 condition = function() 110 eq({ 111 [2] = { win = 1000, startrow = 7, startcol = 27, width = 26, height = 5 }, 112 [4] = { win = 1001, startrow = 0, startcol = 0, width = 26, height = 12 }, 113 [5] = { win = 1002, startrow = 0, startcol = 27, width = 26, height = 6 }, 114 }, screen.win_position) 115 end, 116 } 117 command('wincmd h') 118 command('q') 119 screen:expect { 120 grid = [[ 121 ## grid 1 122 [5:-----------------------------------------------------]|*6 123 {11:[No Name] }| 124 [2:-----------------------------------------------------]|*5 125 {12:[No Name] }| 126 [3:-----------------------------------------------------]| 127 ## grid 2 128 | 129 {1:~ }|*4 130 ## grid 3 131 | 132 ## grid 5 133 ^ | 134 {1:~ }|*5 135 ]], 136 condition = function() 137 eq({ 138 [2] = { win = 1000, startrow = 7, startcol = 0, width = 53, height = 5 }, 139 [5] = { win = 1002, startrow = 0, startcol = 0, width = 53, height = 6 }, 140 }, screen.win_position) 141 end, 142 } 143 end) 144 145 describe('split', function() 146 describe('horizontally', function() 147 it('allocates grids', function() 148 command('sp') 149 screen:expect([[ 150 ## grid 1 151 [4:-----------------------------------------------------]|*6 152 {11:[No Name] }| 153 [2:-----------------------------------------------------]|*5 154 {12:[No Name] }| 155 [3:-----------------------------------------------------]| 156 ## grid 2 157 | 158 {1:~ }|*4 159 ## grid 3 160 | 161 ## grid 4 162 ^ | 163 {1:~ }|*5 164 ]]) 165 end) 166 167 it('resizes grids', function() 168 command('sp') 169 command('resize 8') 170 screen:expect([[ 171 ## grid 1 172 [4:-----------------------------------------------------]|*8 173 {11:[No Name] }| 174 [2:-----------------------------------------------------]|*3 175 {12:[No Name] }| 176 [3:-----------------------------------------------------]| 177 ## grid 2 178 | 179 {1:~ }|*2 180 ## grid 3 181 | 182 ## grid 4 183 ^ | 184 {1:~ }|*7 185 ]]) 186 end) 187 188 it('splits vertically', function() 189 command('sp') 190 command('vsp') 191 command('vsp') 192 screen:expect { 193 grid = [[ 194 ## grid 1 195 [6:--------------------]│[5:----------------]│[4:---------------]|*6 196 {11:[No Name] }{12:[No Name] [No Name] }| 197 [2:-----------------------------------------------------]|*5 198 {12:[No Name] }| 199 [3:-----------------------------------------------------]| 200 ## grid 2 201 | 202 {1:~ }|*4 203 ## grid 3 204 | 205 ## grid 4 206 | 207 {1:~ }|*5 208 ## grid 5 209 | 210 {1:~ }|*5 211 ## grid 6 212 ^ | 213 {1:~ }|*5 214 ]], 215 } 216 insert('hello') 217 screen:expect { 218 grid = [[ 219 ## grid 1 220 [6:--------------------]│[5:----------------]│[4:---------------]|*6 221 {11:[No Name] [+] }{12:[No Name] [+] [No Name] [+] }| 222 [2:-----------------------------------------------------]|*5 223 {12:[No Name] [+] }| 224 [3:-----------------------------------------------------]| 225 ## grid 2 226 hello | 227 {1:~ }|*4 228 ## grid 3 229 | 230 ## grid 4 231 hello | 232 {1:~ }|*5 233 ## grid 5 234 hello | 235 {1:~ }|*5 236 ## grid 6 237 hell^o | 238 {1:~ }|*5 239 ]], 240 } 241 end) 242 it('closes splits', function() 243 command('sp') 244 screen:expect { 245 grid = [[ 246 ## grid 1 247 [4:-----------------------------------------------------]|*6 248 {11:[No Name] }| 249 [2:-----------------------------------------------------]|*5 250 {12:[No Name] }| 251 [3:-----------------------------------------------------]| 252 ## grid 2 253 | 254 {1:~ }|*4 255 ## grid 3 256 | 257 ## grid 4 258 ^ | 259 {1:~ }|*5 260 ]], 261 } 262 command('q') 263 screen:expect { 264 grid = [[ 265 ## grid 1 266 [2:-----------------------------------------------------]|*12 267 {11:[No Name] }| 268 [3:-----------------------------------------------------]| 269 ## grid 2 270 ^ | 271 {1:~ }|*11 272 ## grid 3 273 | 274 ]], 275 } 276 end) 277 end) 278 279 describe('vertically', function() 280 it('allocates grids', function() 281 command('vsp') 282 screen:expect { 283 grid = [[ 284 ## grid 1 285 [4:--------------------------]│[2:--------------------------]|*12 286 {11:[No Name] }{12:[No Name] }| 287 [3:-----------------------------------------------------]| 288 ## grid 2 289 | 290 {1:~ }|*11 291 ## grid 3 292 | 293 ## grid 4 294 ^ | 295 {1:~ }|*11 296 ]], 297 } 298 end) 299 it('resizes grids', function() 300 command('vsp') 301 command('vertical resize 10') 302 screen:expect { 303 grid = [[ 304 ## grid 1 305 [4:----------]│[2:------------------------------------------]|*12 306 {11:[No Name] }{12:[No Name] }| 307 [3:-----------------------------------------------------]| 308 ## grid 2 309 | 310 {1:~ }|*11 311 ## grid 3 312 | 313 ## grid 4 314 ^ | 315 {1:~ }|*11 316 ]], 317 } 318 end) 319 it('splits horizontally', function() 320 command('vsp') 321 command('sp') 322 screen:expect { 323 grid = [[ 324 ## grid 1 325 [5:--------------------------]│[2:--------------------------]|*6 326 {11:[No Name] }│[2:--------------------------]| 327 [4:--------------------------]│[2:--------------------------]|*5 328 {12:[No Name] [No Name] }| 329 [3:-----------------------------------------------------]| 330 ## grid 2 331 | 332 {1:~ }|*11 333 ## grid 3 334 | 335 ## grid 4 336 | 337 {1:~ }|*4 338 ## grid 5 339 ^ | 340 {1:~ }|*5 341 ]], 342 } 343 insert('hello') 344 screen:expect { 345 grid = [[ 346 ## grid 1 347 [5:--------------------------]│[2:--------------------------]|*6 348 {11:[No Name] [+] }│[2:--------------------------]| 349 [4:--------------------------]│[2:--------------------------]|*5 350 {12:[No Name] [+] [No Name] [+] }| 351 [3:-----------------------------------------------------]| 352 ## grid 2 353 hello | 354 {1:~ }|*11 355 ## grid 3 356 | 357 ## grid 4 358 hello | 359 {1:~ }|*4 360 ## grid 5 361 hell^o | 362 {1:~ }|*5 363 ]], 364 } 365 end) 366 it('closes splits', function() 367 command('vsp') 368 screen:expect { 369 grid = [[ 370 ## grid 1 371 [4:--------------------------]│[2:--------------------------]|*12 372 {11:[No Name] }{12:[No Name] }| 373 [3:-----------------------------------------------------]| 374 ## grid 2 375 | 376 {1:~ }|*11 377 ## grid 3 378 | 379 ## grid 4 380 ^ | 381 {1:~ }|*11 382 ]], 383 } 384 command('q') 385 screen:expect { 386 grid = [[ 387 ## grid 1 388 [2:-----------------------------------------------------]|*12 389 {11:[No Name] }| 390 [3:-----------------------------------------------------]| 391 ## grid 2 392 ^ | 393 {1:~ }|*11 394 ## grid 3 395 | 396 ]], 397 } 398 end) 399 end) 400 end) 401 402 describe('on resize', function() 403 it('rebuilds all grids', function() 404 screen:try_resize(25, 6) 405 screen:expect { 406 grid = [[ 407 ## grid 1 408 [2:-------------------------]|*4 409 {11:[No Name] }| 410 [3:-------------------------]| 411 ## grid 2 412 ^ | 413 {1:~ }|*3 414 ## grid 3 415 | 416 ]], 417 } 418 end) 419 420 it('has minimum width/height values', function() 421 screen:try_resize(1, 1) 422 screen:expect { 423 grid = [[ 424 ## grid 1 425 [2:------------]| 426 {11:[No Name] }| 427 [3:------------]| 428 ## grid 2 429 ^ | 430 ## grid 3 431 | 432 ]], 433 } 434 435 feed('<esc>:ls') 436 screen:expect { 437 grid = [[ 438 ## grid 1 439 [2:------------]| 440 {11:[No Name] }| 441 [3:------------]| 442 ## grid 2 443 | 444 ## grid 3 445 :ls^ | 446 ]], 447 } 448 end) 449 end) 450 451 describe('grid of smaller inner size', function() 452 before_each(function() 453 screen:try_resize_grid(2, 20, 5) 454 end) 455 456 it('is rendered correctly', function() 457 screen:expect { 458 grid = [[ 459 ## grid 1 460 [2:-----------------------------------------------------]|*12 461 {11:[No Name] }| 462 [3:-----------------------------------------------------]| 463 ## grid 2 464 ^ | 465 {1:~ }|*4 466 ## grid 3 467 | 468 ]], 469 } 470 screen:try_resize_grid(2, 8, 5) 471 screen:expect { 472 grid = [[ 473 ## grid 1 474 [2:-----------------------------------------------------]|*12 475 {11:[No Name] }| 476 [3:-----------------------------------------------------]| 477 ## grid 2 478 ^ | 479 {1:~ }|*4 480 ## grid 3 481 | 482 ]], 483 } 484 end) 485 486 it("cursor draws correctly with double-width char and 'showbreak'", function() 487 insert(('a'):rep(19) .. '哦bbbb') 488 command('setlocal showbreak=++') 489 screen:expect { 490 grid = [[ 491 ## grid 1 492 [2:-----------------------------------------------------]|*12 493 {11:[No Name] [+] }| 494 [3:-----------------------------------------------------]| 495 ## grid 2 496 aaaaaaaaaaaaaaaaaaa{1:>}| 497 {1:++}哦bbb^b | 498 {1:~ }|*3 499 ## grid 3 500 | 501 ]], 502 } 503 end) 504 end) 505 506 describe('grid of bigger inner size', function() 507 before_each(function() 508 screen:try_resize_grid(2, 60, 20) 509 end) 510 511 it('is rendered correctly', function() 512 screen:expect { 513 grid = [[ 514 ## grid 1 515 [2:-----------------------------------------------------]|*12 516 {11:[No Name] }| 517 [3:-----------------------------------------------------]| 518 ## grid 2 519 ^ | 520 {1:~ }|*19 521 ## grid 3 522 | 523 ]], 524 } 525 screen:try_resize_grid(2, 80, 20) 526 screen:expect { 527 grid = [[ 528 ## grid 1 529 [2:-----------------------------------------------------]|*12 530 {11:[No Name] }| 531 [3:-----------------------------------------------------]| 532 ## grid 2 533 ^ | 534 {1:~ }|*19 535 ## grid 3 536 | 537 ]], 538 } 539 end) 540 541 it('winwidth() winheight() getwininfo() return inner width and height #19743', function() 542 eq(60, fn.winwidth(0)) 543 eq(20, fn.winheight(0)) 544 local win_info = fn.getwininfo(curwin())[1] 545 eq(60, win_info.width) 546 eq(20, win_info.height) 547 end) 548 549 it("'scroll' option works properly", function() 550 eq(10, api.nvim_get_option_value('scroll', { win = 0 })) 551 api.nvim_set_option_value('scroll', 15, { win = 0 }) 552 eq(15, api.nvim_get_option_value('scroll', { win = 0 })) 553 end) 554 555 it('gets written till grid width', function() 556 insert(('a'):rep(60) .. '\n') 557 screen:expect { 558 grid = [[ 559 ## grid 1 560 [2:-----------------------------------------------------]|*12 561 {11:[No Name] [+] }| 562 [3:-----------------------------------------------------]| 563 ## grid 2 564 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 565 ^ | 566 {1:~ }|*18 567 ## grid 3 568 | 569 ]], 570 } 571 end) 572 573 it('g$ works correctly with double-width chars and no wrapping', function() 574 command('set nowrap') 575 insert(('a'):rep(58) .. ('哦'):rep(3)) 576 feed('0') 577 screen:expect { 578 grid = [[ 579 ## grid 1 580 [2:-----------------------------------------------------]|*12 581 {11:[No Name] [+] }| 582 [3:-----------------------------------------------------]| 583 ## grid 2 584 ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa哦| 585 {1:~ }|*19 586 ## grid 3 587 | 588 ]], 589 } 590 feed('g$') 591 screen:expect { 592 grid = [[ 593 ## grid 1 594 [2:-----------------------------------------------------]|*12 595 {11:[No Name] [+] }| 596 [3:-----------------------------------------------------]| 597 ## grid 2 598 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^哦| 599 {1:~ }|*19 600 ## grid 3 601 | 602 ]], 603 } 604 end) 605 606 it('wraps with grid width', function() 607 insert(('b'):rep(160) .. '\n') 608 screen:expect { 609 grid = [[ 610 ## grid 1 611 [2:-----------------------------------------------------]|*12 612 {11:[No Name] [+] }| 613 [3:-----------------------------------------------------]| 614 ## grid 2 615 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*2 616 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | 617 ^ | 618 {1:~ }|*16 619 ## grid 3 620 | 621 ]], 622 } 623 feed('2gk') 624 command('setlocal cursorline cursorlineopt=screenline') 625 screen:expect { 626 grid = [[ 627 ## grid 1 628 [2:-----------------------------------------------------]|*12 629 {11:[No Name] [+] }| 630 [3:-----------------------------------------------------]| 631 ## grid 2 632 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| 633 {23:^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}| 634 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | 635 | 636 {1:~ }|*16 637 ## grid 3 638 | 639 ]], 640 } 641 command('setlocal breakindent breakindentopt=shift:8') 642 feed('g$') 643 screen:expect { 644 grid = [[ 645 ## grid 1 646 [2:-----------------------------------------------------]|*12 647 {11:[No Name] [+] }| 648 [3:-----------------------------------------------------]| 649 ## grid 2 650 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| 651 {23:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb^b}| 652 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | 653 | 654 {1:~ }|*16 655 ## grid 3 656 | 657 ]], 658 } 659 end) 660 661 it('displays messages with default grid width', function() 662 command('echomsg "this is a very very very very very very very very' .. ' long message"') 663 screen:expect { 664 grid = [[ 665 ## grid 1 666 [2:-----------------------------------------------------]|*12 667 {11:[No Name] }| 668 [3:-----------------------------------------------------]| 669 ## grid 2 670 ^ | 671 {1:~ }|*19 672 ## grid 3 673 this is a very very very...ry very very long message | 674 ]], 675 } 676 end) 677 678 it('creates folds with grid width', function() 679 insert('this is a fold\nthis is inside fold\nthis is outside fold') 680 feed('kzfgg') 681 screen:expect { 682 grid = [[ 683 ## grid 1 684 [2:-----------------------------------------------------]|*12 685 {11:[No Name] [+] }| 686 [3:-----------------------------------------------------]| 687 ## grid 2 688 {13:^+-- 2 lines: this is a fold································}| 689 this is outside fold | 690 {1:~ }|*18 691 ## grid 3 692 | 693 ]], 694 } 695 end) 696 697 it('anchored float window "bufpos"', function() 698 insert(('c'):rep(1111)) 699 screen:expect { 700 grid = [[ 701 ## grid 1 702 [2:-----------------------------------------------------]|*12 703 {11:[No Name] [+] }| 704 [3:-----------------------------------------------------]| 705 ## grid 2 706 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|*18 707 cccccccccccccccccccccccccccccc^c | 708 {1:~ }| 709 ## grid 3 710 | 711 ]], 712 } 713 local float_buf = api.nvim_create_buf(false, false) 714 api.nvim_open_win(float_buf, false, { 715 relative = 'win', 716 win = curwin(), 717 bufpos = { 0, 1018 }, 718 anchor = 'SE', 719 width = 5, 720 height = 5, 721 }) 722 screen:expect { 723 grid = [[ 724 ## grid 1 725 [2:-----------------------------------------------------]|*12 726 {11:[No Name] [+] }| 727 [3:-----------------------------------------------------]| 728 ## grid 2 729 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|*18 730 cccccccccccccccccccccccccccccc^c | 731 {1:~ }| 732 ## grid 3 733 | 734 ## grid 4 735 {21: }| 736 {22:~ }|*4 737 ]], 738 float_pos = { 739 [4] = { 1001, 'SE', 2, 16, 58, true, 50, 1, 8, 48 }, 740 }, 741 } 742 end) 743 744 it('completion popup position', function() 745 insert(('\n'):rep(14) .. ('foo bar '):rep(7)) 746 feed('A<C-X><C-N>') 747 screen:expect { 748 grid = [[ 749 ## grid 1 750 [2:-----------------------------------------------------]|*12 751 {11:[No Name] [+] }| 752 [3:-----------------------------------------------------]| 753 ## grid 2 754 |*14 755 foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo^ | 756 {1:~ }|*5 757 ## grid 3 758 {7:-- Keyword Local completion (^N^P) }{15:match 1 of 2} | 759 ## grid 4 760 {24: foo }| 761 {21: bar }| 762 ]], 763 float_pos = { 764 [4] = { -1, 'NW', 2, 15, 43, false, 100, 1, 15, 43 }, 765 }, 766 } 767 feed('<C-E><Esc>') 768 769 command('setlocal rightleft') 770 feed('o<C-X><C-N>') 771 screen:expect { 772 grid = [[ 773 ## grid 1 774 [2:-----------------------------------------------------]|*12 775 {11:[No Name] [+] }| 776 [3:-----------------------------------------------------]| 777 ## grid 2 778 |*14 779 rab oof rab oof rab oof rab oof rab oof rab oof rab oof| 780 ^ oof| 781 {1: ~}|*4 782 ## grid 3 783 {7:-- Keyword Local completion (^N^P) }{15:match 1 of 2} | 784 ## grid 4 785 {24: oof}| 786 {21: rab}| 787 ]], 788 float_pos = { 789 [4] = { -1, 'NW', 2, 16, 45, false, 100, 1, 16, 45 }, 790 }, 791 } 792 feed('<C-E><Esc>') 793 794 command('set wildoptions+=pum') 795 feed(':sign un<Tab>') 796 screen:expect { 797 grid = [[ 798 ## grid 1 799 [2:-----------------------------------------------------]|*12 800 {11:[No Name] [+] }| 801 [3:-----------------------------------------------------]| 802 ## grid 2 803 |*14 804 rab oof rab oof rab oof rab oof rab oof rab oof rab oof| 805 | 806 {1: ~}|*4 807 ## grid 3 808 :sign undefine^ | 809 ## grid 4 810 {24: undefine }| 811 {21: unplace }| 812 ]], 813 float_pos = { 814 [4] = { -1, 'SW', 1, 13, 5, false, 250, 2, 11, 5 }, 815 }, 816 } 817 end) 818 819 it('half-page scrolling stops at end of buffer', function() 820 command('set number') 821 insert(('foobar\n'):rep(100)) 822 feed('7<C-Y>') 823 screen:expect({ 824 grid = [[ 825 ## grid 1 826 [2:-----------------------------------------------------]|*12 827 {11:[No Name] [+] }| 828 [3:-----------------------------------------------------]| 829 ## grid 2 830 {19: 75 }foobar | 831 {19: 76 }foobar | 832 {19: 77 }foobar | 833 {19: 78 }foobar | 834 {19: 79 }foobar | 835 {19: 80 }foobar | 836 {19: 81 }foobar | 837 {19: 82 }foobar | 838 {19: 83 }foobar | 839 {19: 84 }foobar | 840 {19: 85 }foobar | 841 {19: 86 }foobar | 842 {19: 87 }foobar | 843 {19: 88 }foobar | 844 {19: 89 }foobar | 845 {19: 90 }foobar | 846 {19: 91 }foobar | 847 {19: 92 }foobar | 848 {19: 93 }foobar | 849 {19: 94 }^foobar | 850 ## grid 3 851 | 852 ]], 853 }) 854 feed('<C-D>') 855 screen:expect({ 856 grid = [[ 857 ## grid 1 858 [2:-----------------------------------------------------]|*12 859 {11:[No Name] [+] }| 860 [3:-----------------------------------------------------]| 861 ## grid 2 862 {19: 82 }foobar | 863 {19: 83 }foobar | 864 {19: 84 }foobar | 865 {19: 85 }foobar | 866 {19: 86 }foobar | 867 {19: 87 }foobar | 868 {19: 88 }foobar | 869 {19: 89 }foobar | 870 {19: 90 }foobar | 871 {19: 91 }foobar | 872 {19: 92 }foobar | 873 {19: 93 }foobar | 874 {19: 94 }foobar | 875 {19: 95 }foobar | 876 {19: 96 }foobar | 877 {19: 97 }foobar | 878 {19: 98 }foobar | 879 {19: 99 }foobar | 880 {19:100 }foobar | 881 {19:101 }^ | 882 ## grid 3 883 | 884 ]], 885 }) 886 end) 887 end) 888 889 it('multiline messages scroll over windows', function() 890 command('sp') 891 command('vsp') 892 screen:expect { 893 grid = [[ 894 ## grid 1 895 [5:--------------------------]│[4:--------------------------]|*6 896 {11:[No Name] }{12:[No Name] }| 897 [2:-----------------------------------------------------]|*5 898 {12:[No Name] }| 899 [3:-----------------------------------------------------]| 900 ## grid 2 901 | 902 {1:~ }|*4 903 ## grid 3 904 | 905 ## grid 4 906 | 907 {1:~ }|*5 908 ## grid 5 909 ^ | 910 {1:~ }|*5 911 ]], 912 } 913 914 feed(":echoerr 'very' | echoerr 'much' | echoerr 'fail'<cr>") 915 screen:expect { 916 grid = [[ 917 ## grid 1 918 [5:--------------------------]│[4:--------------------------]|*6 919 {11:[No Name] }{12:[No Name] }| 920 [2:-----------------------------------------------------]|*3 921 [3:-----------------------------------------------------]|*4 922 ## grid 2 923 | 924 {1:~ }|*4 925 ## grid 3 926 {14:very} | 927 {14:much} | 928 {14:fail} | 929 {15:Press ENTER or type command to continue}^ | 930 ## grid 4 931 | 932 {1:~ }|*5 933 ## grid 5 934 | 935 {1:~ }|*5 936 ]], 937 } 938 939 feed('<cr>') 940 screen:expect { 941 grid = [[ 942 ## grid 1 943 [5:--------------------------]│[4:--------------------------]|*6 944 {11:[No Name] }{12:[No Name] }| 945 [2:-----------------------------------------------------]|*5 946 {12:[No Name] }| 947 [3:-----------------------------------------------------]| 948 ## grid 2 949 | 950 {1:~ }|*4 951 ## grid 3 952 | 953 ## grid 4 954 | 955 {1:~ }|*5 956 ## grid 5 957 ^ | 958 {1:~ }|*5 959 ]], 960 } 961 962 command([[ 963 func! ErrMsg() 964 for i in range(11) 965 echoerr "error ".i 966 endfor 967 endfunc]]) 968 feed(':call ErrMsg()<cr>') 969 screen:expect { 970 grid = [[ 971 ## grid 1 972 [3:-----------------------------------------------------]|*14 973 ## grid 2 974 | 975 {1:~ }|*4 976 ## grid 3 977 {14:Error in function ErrMsg:} | 978 {19:line 2:} | 979 {14:error 0} | 980 {14:error 1} | 981 {14:error 2} | 982 {14:error 3} | 983 {14:error 4} | 984 {14:error 5} | 985 {14:error 6} | 986 {14:error 7} | 987 {14:error 8} | 988 {14:error 9} | 989 {14:error 10} | 990 {15:Press ENTER or type command to continue}^ | 991 ## grid 4 992 | 993 {1:~ }|*5 994 ## grid 5 995 | 996 {1:~ }|*5 997 ]], 998 } 999 1000 feed('<c-c>') 1001 screen:expect { 1002 grid = [[ 1003 ## grid 1 1004 [5:--------------------------]│[4:--------------------------]|*6 1005 {11:[No Name] }{12:[No Name] }| 1006 [2:-----------------------------------------------------]|*5 1007 {12:[No Name] }| 1008 [3:-----------------------------------------------------]| 1009 ## grid 2 1010 | 1011 {1:~ }|*4 1012 ## grid 3 1013 | 1014 ## grid 4 1015 | 1016 {1:~ }|*5 1017 ## grid 5 1018 ^ | 1019 {1:~ }|*5 1020 ]], 1021 } 1022 end) 1023 1024 it('handles switch tabs', function() 1025 command('vsp') 1026 screen:expect { 1027 grid = [[ 1028 ## grid 1 1029 [4:--------------------------]│[2:--------------------------]|*12 1030 {11:[No Name] }{12:[No Name] }| 1031 [3:-----------------------------------------------------]| 1032 ## grid 2 1033 | 1034 {1:~ }|*11 1035 ## grid 3 1036 | 1037 ## grid 4 1038 ^ | 1039 {1:~ }|*11 1040 ]], 1041 } 1042 1043 command('tabnew') 1044 -- note the old grids aren't resized yet 1045 screen:expect { 1046 grid = [[ 1047 ## grid 1 1048 {16: }{17:2}{16: [No Name] }{7: [No Name] }{12: }{16:X}| 1049 [5:-----------------------------------------------------]|*11 1050 {11:[No Name] }| 1051 [3:-----------------------------------------------------]| 1052 ## grid 2 (hidden) 1053 | 1054 {1:~ }|*11 1055 ## grid 3 1056 | 1057 ## grid 4 (hidden) 1058 | 1059 {1:~ }|*11 1060 ## grid 5 1061 ^ | 1062 {1:~ }|*10 1063 ]], 1064 } 1065 1066 command('sp') 1067 screen:expect { 1068 grid = [[ 1069 ## grid 1 1070 {16: }{17:2}{16: [No Name] }{7: }{18:2}{7: [No Name] }{12: }{16:X}| 1071 [6:-----------------------------------------------------]|*5 1072 {11:[No Name] }| 1073 [5:-----------------------------------------------------]|*5 1074 {12:[No Name] }| 1075 [3:-----------------------------------------------------]| 1076 ## grid 2 (hidden) 1077 | 1078 {1:~ }|*11 1079 ## grid 3 1080 | 1081 ## grid 4 (hidden) 1082 | 1083 {1:~ }|*11 1084 ## grid 5 1085 | 1086 {1:~ }|*4 1087 ## grid 6 1088 ^ | 1089 {1:~ }|*4 1090 ]], 1091 } 1092 1093 command('tabnext') 1094 screen:expect { 1095 grid = [[ 1096 ## grid 1 1097 {7: }{18:2}{7: [No Name] }{16: }{17:2}{16: [No Name] }{12: }{16:X}| 1098 [4:--------------------------]│[2:--------------------------]|*11 1099 {11:[No Name] }{12:[No Name] }| 1100 [3:-----------------------------------------------------]| 1101 ## grid 2 1102 | 1103 {1:~ }|*10 1104 ## grid 3 1105 | 1106 ## grid 4 1107 ^ | 1108 {1:~ }|*10 1109 ## grid 5 (hidden) 1110 | 1111 {1:~ }|*4 1112 ## grid 6 (hidden) 1113 | 1114 {1:~ }|*4 1115 ]], 1116 } 1117 1118 command('tabnext') 1119 screen:expect { 1120 grid = [[ 1121 ## grid 1 1122 {16: }{17:2}{16: [No Name] }{7: }{18:2}{7: [No Name] }{12: }{16:X}| 1123 [6:-----------------------------------------------------]|*5 1124 {11:[No Name] }| 1125 [5:-----------------------------------------------------]|*5 1126 {12:[No Name] }| 1127 [3:-----------------------------------------------------]| 1128 ## grid 2 (hidden) 1129 | 1130 {1:~ }|*10 1131 ## grid 3 1132 | 1133 ## grid 4 (hidden) 1134 | 1135 {1:~ }|*10 1136 ## grid 5 1137 | 1138 {1:~ }|*4 1139 ## grid 6 1140 ^ | 1141 {1:~ }|*4 1142 ]], 1143 } 1144 1145 command('tabnext') 1146 command('$tabnew') 1147 screen:expect { 1148 grid = [[ 1149 ## grid 1 1150 {16: }{17:2}{16: [No Name] }{17:2}{16: [No Name] }{7: [No Name] }{12: }{16:X}| 1151 [7:-----------------------------------------------------]|*11 1152 {11:[No Name] }| 1153 [3:-----------------------------------------------------]| 1154 ## grid 2 (hidden) 1155 | 1156 {1:~ }|*10 1157 ## grid 3 1158 | 1159 ## grid 4 (hidden) 1160 | 1161 {1:~ }|*10 1162 ## grid 5 (hidden) 1163 | 1164 {1:~ }|*4 1165 ## grid 6 (hidden) 1166 | 1167 {1:~ }|*4 1168 ## grid 7 1169 ^ | 1170 {1:~ }|*10 1171 ]], 1172 } 1173 1174 command('tabclose') 1175 command('tabclose') 1176 screen:expect { 1177 grid = [[ 1178 ## grid 1 1179 [4:--------------------------]│[2:--------------------------]|*12 1180 {11:[No Name] }{12:[No Name] }| 1181 [3:-----------------------------------------------------]| 1182 ## grid 2 1183 | 1184 {1:~ }|*11 1185 ## grid 3 1186 | 1187 ## grid 4 1188 ^ | 1189 {1:~ }|*11 1190 ]], 1191 } 1192 end) 1193 1194 it('supports mouse', function() 1195 command('autocmd! nvim.popupmenu') -- Delete the default MenuPopup event handler. 1196 insert('some text\nto be clicked') 1197 screen:expect { 1198 grid = [[ 1199 ## grid 1 1200 [2:-----------------------------------------------------]|*12 1201 {11:[No Name] [+] }| 1202 [3:-----------------------------------------------------]| 1203 ## grid 2 1204 some text | 1205 to be clicke^d | 1206 {1:~ }|*10 1207 ## grid 3 1208 | 1209 ]], 1210 } 1211 1212 api.nvim_input_mouse('left', 'press', '', 2, 0, 5) 1213 screen:expect { 1214 grid = [[ 1215 ## grid 1 1216 [2:-----------------------------------------------------]|*12 1217 {11:[No Name] [+] }| 1218 [3:-----------------------------------------------------]| 1219 ## grid 2 1220 some ^text | 1221 to be clicked | 1222 {1:~ }|*10 1223 ## grid 3 1224 | 1225 ]], 1226 } 1227 1228 feed(':new<cr>') 1229 insert('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmo') 1230 1231 screen:expect { 1232 grid = [[ 1233 ## grid 1 1234 [4:-----------------------------------------------------]|*6 1235 {11:[No Name] [+] }| 1236 [2:-----------------------------------------------------]|*5 1237 {12:[No Name] [+] }| 1238 [3:-----------------------------------------------------]| 1239 ## grid 2 1240 some text | 1241 to be clicked | 1242 {1:~ }|*3 1243 ## grid 3 1244 | 1245 ## grid 4 1246 Lorem ipsum dolor sit amet, consectetur adipiscing el| 1247 it, sed do eiusm^o | 1248 {1:~ }|*4 1249 ]], 1250 } 1251 1252 api.nvim_input_mouse('left', 'press', '', 2, 1, 6) 1253 screen:expect { 1254 grid = [[ 1255 ## grid 1 1256 [4:-----------------------------------------------------]|*6 1257 {12:[No Name] [+] }| 1258 [2:-----------------------------------------------------]|*5 1259 {11:[No Name] [+] }| 1260 [3:-----------------------------------------------------]| 1261 ## grid 2 1262 some text | 1263 to be ^clicked | 1264 {1:~ }|*3 1265 ## grid 3 1266 | 1267 ## grid 4 1268 Lorem ipsum dolor sit amet, consectetur adipiscing el| 1269 it, sed do eiusmo | 1270 {1:~ }|*4 1271 ]], 1272 } 1273 1274 api.nvim_input_mouse('left', 'press', '', 4, 1, 4) 1275 screen:expect { 1276 grid = [[ 1277 ## grid 1 1278 [4:-----------------------------------------------------]|*6 1279 {11:[No Name] [+] }| 1280 [2:-----------------------------------------------------]|*5 1281 {12:[No Name] [+] }| 1282 [3:-----------------------------------------------------]| 1283 ## grid 2 1284 some text | 1285 to be clicked | 1286 {1:~ }|*3 1287 ## grid 3 1288 | 1289 ## grid 4 1290 Lorem ipsum dolor sit amet, consectetur adipiscing el| 1291 it, ^sed do eiusmo | 1292 {1:~ }|*4 1293 ]], 1294 } 1295 1296 screen:try_resize_grid(4, 80, 2) 1297 screen:expect { 1298 grid = [[ 1299 ## grid 1 1300 [4:-----------------------------------------------------]|*6 1301 {11:[No Name] [+] }| 1302 [2:-----------------------------------------------------]|*5 1303 {12:[No Name] [+] }| 1304 [3:-----------------------------------------------------]| 1305 ## grid 2 1306 some text | 1307 to be clicked | 1308 {1:~ }|*3 1309 ## grid 3 1310 | 1311 ## grid 4 1312 Lorem ipsum dolor sit amet, consectetur adipiscing elit, ^sed do eiusmo | 1313 {1:~ }| 1314 ]], 1315 } 1316 1317 api.nvim_input_mouse('left', 'press', '', 4, 0, 64) 1318 screen:expect { 1319 grid = [[ 1320 ## grid 1 1321 [4:-----------------------------------------------------]|*6 1322 {11:[No Name] [+] }| 1323 [2:-----------------------------------------------------]|*5 1324 {12:[No Name] [+] }| 1325 [3:-----------------------------------------------------]| 1326 ## grid 2 1327 some text | 1328 to be clicked | 1329 {1:~ }|*3 1330 ## grid 3 1331 | 1332 ## grid 4 1333 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ^eiusmo | 1334 {1:~ }| 1335 ]], 1336 } 1337 1338 -- XXX: mouse_check_grid() doesn't work properly when clicking on grid 1 1339 api.nvim_input_mouse('left', 'press', '', 1, 6, 20) 1340 -- TODO(bfredl): "batching" input_mouse is formally not supported yet. 1341 -- Normally it should work fine in async context when nvim is not blocked, 1342 -- but add a poke_eventloop be sure. 1343 poke_eventloop() 1344 api.nvim_input_mouse('left', 'drag', '', 1, 4, 20) 1345 screen:expect { 1346 grid = [[ 1347 ## grid 1 1348 [4:-----------------------------------------------------]|*4 1349 {11:[No Name] [+] }| 1350 [2:-----------------------------------------------------]|*7 1351 {12:[No Name] [+] }| 1352 [3:-----------------------------------------------------]| 1353 ## grid 2 1354 some text | 1355 to be clicked | 1356 {1:~ }|*5 1357 ## grid 3 1358 | 1359 ## grid 4 1360 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ^eiusmo | 1361 {1:~ }| 1362 ]], 1363 } 1364 1365 feed('<c-w><c-w><c-w>v') 1366 screen:expect { 1367 grid = [[ 1368 ## grid 1 1369 [4:-----------------------------------------------------]|*4 1370 {12:[No Name] [+] }| 1371 [5:--------------------------]│[2:--------------------------]|*7 1372 {11:[No Name] [+] }{12:[No Name] [+] }| 1373 [3:-----------------------------------------------------]| 1374 ## grid 2 1375 some text | 1376 to be clicked | 1377 {1:~ }|*5 1378 ## grid 3 1379 | 1380 ## grid 4 1381 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmo | 1382 {1:~ }| 1383 ## grid 5 1384 some text | 1385 to be ^clicked | 1386 {1:~ }|*5 1387 ]], 1388 } 1389 1390 api.nvim_input_mouse('left', 'press', '', 1, 8, 26) 1391 poke_eventloop() 1392 api.nvim_input_mouse('left', 'drag', '', 1, 6, 30) 1393 screen:expect { 1394 grid = [[ 1395 ## grid 1 1396 [4:-----------------------------------------------------]|*4 1397 {12:[No Name] [+] }| 1398 [5:------------------------------]│[2:----------------------]|*7 1399 {11:[No Name] [+] }{12:[No Name] [+] }| 1400 [3:-----------------------------------------------------]| 1401 ## grid 2 1402 some text | 1403 to be clicked | 1404 {1:~ }|*5 1405 ## grid 3 1406 | 1407 ## grid 4 1408 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmo | 1409 {1:~ }| 1410 ## grid 5 1411 some text | 1412 to be ^clicked | 1413 {1:~ }|*5 1414 ]], 1415 } 1416 1417 command('aunmenu PopUp | vmenu PopUp.Copy y') 1418 1419 fn.setreg('"', '') 1420 api.nvim_input_mouse('left', 'press', '2', 2, 1, 6) 1421 screen:expect { 1422 grid = [[ 1423 ## grid 1 1424 [4:-----------------------------------------------------]|*4 1425 {12:[No Name] [+] }| 1426 [5:------------------------------]│[2:----------------------]|*7 1427 {12:[No Name] [+] }{11:[No Name] [+] }| 1428 [3:-----------------------------------------------------]| 1429 ## grid 2 1430 some text | 1431 to be {20:clicke}^d | 1432 {1:~ }|*5 1433 ## grid 3 1434 {7:-- VISUAL --} | 1435 ## grid 4 1436 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmo | 1437 {1:~ }| 1438 ## grid 5 1439 some text | 1440 to be {20:clicked} | 1441 {1:~ }|*5 1442 ]], 1443 } 1444 api.nvim_input_mouse('right', 'press', '', 2, 1, 6) 1445 api.nvim_input_mouse('right', 'release', '', 2, 1, 6) 1446 screen:expect { 1447 grid = [[ 1448 ## grid 1 1449 [4:-----------------------------------------------------]|*4 1450 {12:[No Name] [+] }| 1451 [5:------------------------------]│[2:----------------------]|*7 1452 {12:[No Name] [+] }{11:[No Name] [+] }| 1453 [3:-----------------------------------------------------]| 1454 ## grid 2 1455 some text | 1456 to be {20:clicke}^d | 1457 {1:~ }|*5 1458 ## grid 3 1459 {7:-- VISUAL --} | 1460 ## grid 4 1461 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmo | 1462 {1:~ }| 1463 ## grid 5 1464 some text | 1465 to be {20:clicked} | 1466 {1:~ }|*5 1467 ## grid 6 1468 {21: Copy }| 1469 ]], 1470 float_pos = { 1471 [6] = { -1, 'NW', 2, 2, 5, false, 250, 2, 7, 36 }, 1472 }, 1473 } 1474 feed('<Down><CR>') 1475 screen:expect { 1476 grid = [[ 1477 ## grid 1 1478 [4:-----------------------------------------------------]|*4 1479 {12:[No Name] [+] }| 1480 [5:------------------------------]│[2:----------------------]|*7 1481 {12:[No Name] [+] }{11:[No Name] [+] }| 1482 [3:-----------------------------------------------------]| 1483 ## grid 2 1484 some text | 1485 to be ^clicked | 1486 {1:~ }|*5 1487 ## grid 3 1488 | 1489 ## grid 4 1490 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmo | 1491 {1:~ }| 1492 ## grid 5 1493 some text | 1494 to be clicked | 1495 {1:~ }|*5 1496 ]], 1497 } 1498 eq('clicked', fn.getreg('"')) 1499 1500 fn.setreg('"', '') 1501 api.nvim_input_mouse('left', 'press', '2', 4, 0, 64) 1502 screen:expect { 1503 grid = [[ 1504 ## grid 1 1505 [4:-----------------------------------------------------]|*4 1506 {11:[No Name] [+] }| 1507 [5:------------------------------]│[2:----------------------]|*7 1508 {12:[No Name] [+] [No Name] [+] }| 1509 [3:-----------------------------------------------------]| 1510 ## grid 2 1511 some text | 1512 to be clicked | 1513 {1:~ }|*5 1514 ## grid 3 1515 {7:-- VISUAL --} | 1516 ## grid 4 1517 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do {20:eiusm}^o | 1518 {1:~ }| 1519 ## grid 5 1520 some text | 1521 to be clicked | 1522 {1:~ }|*5 1523 ]], 1524 } 1525 api.nvim_input_mouse('right', 'press', '', 4, 0, 64) 1526 api.nvim_input_mouse('right', 'release', '', 4, 0, 64) 1527 screen:expect { 1528 grid = [[ 1529 ## grid 1 1530 [4:-----------------------------------------------------]|*4 1531 {11:[No Name] [+] }| 1532 [5:------------------------------]│[2:----------------------]|*7 1533 {12:[No Name] [+] [No Name] [+] }| 1534 [3:-----------------------------------------------------]| 1535 ## grid 2 1536 some text | 1537 to be clicked | 1538 {1:~ }|*5 1539 ## grid 3 1540 {7:-- VISUAL --} | 1541 ## grid 4 1542 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do {20:eiusm}^o | 1543 {1:~ }| 1544 ## grid 5 1545 some text | 1546 to be clicked | 1547 {1:~ }|*5 1548 ## grid 6 1549 {21: Copy }| 1550 ]], 1551 float_pos = { 1552 [6] = { -1, 'NW', 4, 1, 63, false, 250, 2, 1, 63 }, 1553 }, 1554 } 1555 feed('<Down><CR>') 1556 screen:expect { 1557 grid = [[ 1558 ## grid 1 1559 [4:-----------------------------------------------------]|*4 1560 {11:[No Name] [+] }| 1561 [5:------------------------------]│[2:----------------------]|*7 1562 {12:[No Name] [+] [No Name] [+] }| 1563 [3:-----------------------------------------------------]| 1564 ## grid 2 1565 some text | 1566 to be clicked | 1567 {1:~ }|*5 1568 ## grid 3 1569 | 1570 ## grid 4 1571 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ^eiusmo | 1572 {1:~ }| 1573 ## grid 5 1574 some text | 1575 to be clicked | 1576 {1:~ }|*5 1577 ]], 1578 } 1579 eq('eiusmo', fn.getreg('"')) 1580 1581 command('wincmd J') 1582 screen:try_resize_grid(4, 7, 10) 1583 screen:expect { 1584 grid = [[ 1585 ## grid 1 1586 [5:------------------------------]│[2:----------------------]|*5 1587 {12:[No Name] [+] [No Name] [+] }| 1588 [4:-----------------------------------------------------]|*6 1589 {11:[No Name] [+] }| 1590 [3:-----------------------------------------------------]| 1591 ## grid 2 1592 some text | 1593 to be clicked | 1594 {1:~ }|*3 1595 ## grid 3 1596 | 1597 ## grid 4 1598 Lorem i| 1599 psum do| 1600 lor sit| 1601 amet, | 1602 consect| 1603 etur ad| 1604 ipiscin| 1605 g elit,| 1606 sed do| 1607 ^eiusmo| 1608 ## grid 5 1609 some text | 1610 to be clicked | 1611 {1:~ }|*3 1612 ]], 1613 } 1614 1615 fn.setreg('"', '') 1616 api.nvim_input_mouse('left', 'press', '2', 4, 9, 1) 1617 screen:expect { 1618 grid = [[ 1619 ## grid 1 1620 [5:------------------------------]│[2:----------------------]|*5 1621 {12:[No Name] [+] [No Name] [+] }| 1622 [4:-----------------------------------------------------]|*6 1623 {11:[No Name] [+] }| 1624 [3:-----------------------------------------------------]| 1625 ## grid 2 1626 some text | 1627 to be clicked | 1628 {1:~ }|*3 1629 ## grid 3 1630 {7:-- VISUAL --} | 1631 ## grid 4 1632 Lorem i| 1633 psum do| 1634 lor sit| 1635 amet, | 1636 consect| 1637 etur ad| 1638 ipiscin| 1639 g elit,| 1640 sed do| 1641 {20:eiusm}^o| 1642 ## grid 5 1643 some text | 1644 to be clicked | 1645 {1:~ }|*3 1646 ]], 1647 } 1648 api.nvim_input_mouse('right', 'press', '', 4, 9, 1) 1649 api.nvim_input_mouse('right', 'release', '', 4, 9, 1) 1650 screen:expect { 1651 grid = [[ 1652 ## grid 1 1653 [5:------------------------------]│[2:----------------------]|*5 1654 {12:[No Name] [+] [No Name] [+] }| 1655 [4:-----------------------------------------------------]|*6 1656 {11:[No Name] [+] }| 1657 [3:-----------------------------------------------------]| 1658 ## grid 2 1659 some text | 1660 to be clicked | 1661 {1:~ }|*3 1662 ## grid 3 1663 {7:-- VISUAL --} | 1664 ## grid 4 1665 Lorem i| 1666 psum do| 1667 lor sit| 1668 amet, | 1669 consect| 1670 etur ad| 1671 ipiscin| 1672 g elit,| 1673 sed do| 1674 {20:eiusm}^o| 1675 ## grid 5 1676 some text | 1677 to be clicked | 1678 {1:~ }|*3 1679 ## grid 6 1680 {21: Copy }| 1681 ]], 1682 float_pos = { 1683 [6] = { -1, 'SW', 4, 9, 0, false, 250, 2, 14, 0 }, 1684 }, 1685 } 1686 feed('<Down><CR>') 1687 screen:expect { 1688 grid = [[ 1689 ## grid 1 1690 [5:------------------------------]│[2:----------------------]|*5 1691 {12:[No Name] [+] [No Name] [+] }| 1692 [4:-----------------------------------------------------]|*6 1693 {11:[No Name] [+] }| 1694 [3:-----------------------------------------------------]| 1695 ## grid 2 1696 some text | 1697 to be clicked | 1698 {1:~ }|*3 1699 ## grid 3 1700 | 1701 ## grid 4 1702 Lorem i| 1703 psum do| 1704 lor sit| 1705 amet, | 1706 consect| 1707 etur ad| 1708 ipiscin| 1709 g elit,| 1710 sed do| 1711 ^eiusmo| 1712 ## grid 5 1713 some text | 1714 to be clicked | 1715 {1:~ }|*3 1716 ]], 1717 } 1718 eq('eiusmo', fn.getreg('"')) 1719 1720 screen:try_resize_grid(4, 7, 11) 1721 screen:expect { 1722 grid = [[ 1723 ## grid 1 1724 [5:------------------------------]│[2:----------------------]|*5 1725 {12:[No Name] [+] [No Name] [+] }| 1726 [4:-----------------------------------------------------]|*6 1727 {11:[No Name] [+] }| 1728 [3:-----------------------------------------------------]| 1729 ## grid 2 1730 some text | 1731 to be clicked | 1732 {1:~ }|*3 1733 ## grid 3 1734 | 1735 ## grid 4 1736 Lorem i| 1737 psum do| 1738 lor sit| 1739 amet, | 1740 consect| 1741 etur ad| 1742 ipiscin| 1743 g elit,| 1744 sed do| 1745 ^eiusmo| 1746 {1:~ }| 1747 ## grid 5 1748 some text | 1749 to be clicked | 1750 {1:~ }|*3 1751 ]], 1752 } 1753 1754 fn.setreg('"', '') 1755 api.nvim_input_mouse('left', 'press', '2', 4, 9, 1) 1756 screen:expect { 1757 grid = [[ 1758 ## grid 1 1759 [5:------------------------------]│[2:----------------------]|*5 1760 {12:[No Name] [+] [No Name] [+] }| 1761 [4:-----------------------------------------------------]|*6 1762 {11:[No Name] [+] }| 1763 [3:-----------------------------------------------------]| 1764 ## grid 2 1765 some text | 1766 to be clicked | 1767 {1:~ }|*3 1768 ## grid 3 1769 {7:-- VISUAL --} | 1770 ## grid 4 1771 Lorem i| 1772 psum do| 1773 lor sit| 1774 amet, | 1775 consect| 1776 etur ad| 1777 ipiscin| 1778 g elit,| 1779 sed do| 1780 {20:eiusm}^o| 1781 {1:~ }| 1782 ## grid 5 1783 some text | 1784 to be clicked | 1785 {1:~ }|*3 1786 ]], 1787 } 1788 api.nvim_input_mouse('right', 'press', '', 4, 9, 1) 1789 api.nvim_input_mouse('right', 'release', '', 4, 9, 1) 1790 screen:expect { 1791 grid = [[ 1792 ## grid 1 1793 [5:------------------------------]│[2:----------------------]|*5 1794 {12:[No Name] [+] [No Name] [+] }| 1795 [4:-----------------------------------------------------]|*6 1796 {11:[No Name] [+] }| 1797 [3:-----------------------------------------------------]| 1798 ## grid 2 1799 some text | 1800 to be clicked | 1801 {1:~ }|*3 1802 ## grid 3 1803 {7:-- VISUAL --} | 1804 ## grid 4 1805 Lorem i| 1806 psum do| 1807 lor sit| 1808 amet, | 1809 consect| 1810 etur ad| 1811 ipiscin| 1812 g elit,| 1813 sed do| 1814 {20:eiusm}^o| 1815 {1:~ }| 1816 ## grid 5 1817 some text | 1818 to be clicked | 1819 {1:~ }|*3 1820 ## grid 6 1821 {21: Copy }| 1822 ]], 1823 float_pos = { 1824 [6] = { -1, 'NW', 4, 10, 0, false, 250, 2, 16, 0 }, 1825 }, 1826 } 1827 feed('<Down><CR>') 1828 screen:expect { 1829 grid = [[ 1830 ## grid 1 1831 [5:------------------------------]│[2:----------------------]|*5 1832 {12:[No Name] [+] [No Name] [+] }| 1833 [4:-----------------------------------------------------]|*6 1834 {11:[No Name] [+] }| 1835 [3:-----------------------------------------------------]| 1836 ## grid 2 1837 some text | 1838 to be clicked | 1839 {1:~ }|*3 1840 ## grid 3 1841 | 1842 ## grid 4 1843 Lorem i| 1844 psum do| 1845 lor sit| 1846 amet, | 1847 consect| 1848 etur ad| 1849 ipiscin| 1850 g elit,| 1851 sed do| 1852 ^eiusmo| 1853 {1:~ }| 1854 ## grid 5 1855 some text | 1856 to be clicked | 1857 {1:~ }|*3 1858 ]], 1859 } 1860 eq('eiusmo', fn.getreg('"')) 1861 end) 1862 1863 it('supports mouse drag with mouse=a', function() 1864 command('set mouse=a') 1865 command('vsplit') 1866 command('wincmd l') 1867 command('split') 1868 command('enew') 1869 feed('ifoo\nbar<esc>') 1870 1871 api.nvim_input_mouse('left', 'press', '', 5, 0, 0) 1872 poke_eventloop() 1873 api.nvim_input_mouse('left', 'drag', '', 5, 1, 2) 1874 1875 screen:expect { 1876 grid = [[ 1877 ## grid 1 1878 [4:--------------------------]│[5:--------------------------]|*6 1879 [4:--------------------------]│{11:[No Name] [+] }| 1880 [4:--------------------------]│[2:--------------------------]|*5 1881 {12:[No Name] [No Name] }| 1882 [3:-----------------------------------------------------]| 1883 ## grid 2 1884 | 1885 {1:~ }|*4 1886 ## grid 3 1887 {7:-- VISUAL --} | 1888 ## grid 4 1889 | 1890 {1:~ }|*11 1891 ## grid 5 1892 {20:foo} | 1893 {20:ba}^r | 1894 {1:~ }|*4 1895 ]], 1896 } 1897 end) 1898 1899 it('has viewport information', function() 1900 screen:try_resize(48, 8) 1901 screen:expect { 1902 grid = [[ 1903 ## grid 1 1904 [2:------------------------------------------------]|*6 1905 {11:[No Name] }| 1906 [3:------------------------------------------------]| 1907 ## grid 2 1908 ^ | 1909 {1:~ }|*5 1910 ## grid 3 1911 | 1912 ]], 1913 win_viewport = { 1914 [2] = { win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 }, 1915 }, 1916 } 1917 insert([[ 1918 Lorem ipsum dolor sit amet, consectetur 1919 adipisicing elit, sed do eiusmod tempor 1920 incididunt ut labore et dolore magna aliqua. 1921 Ut enim ad minim veniam, quis nostrud 1922 exercitation ullamco laboris nisi ut aliquip ex 1923 ea commodo consequat. Duis aute irure dolor in 1924 reprehenderit in voluptate velit esse cillum 1925 dolore eu fugiat nulla pariatur. Excepteur sint 1926 occaecat cupidatat non proident, sunt in culpa 1927 qui officia deserunt mollit anim id est 1928 laborum.]]) 1929 1930 screen:expect { 1931 grid = [[ 1932 ## grid 1 1933 [2:------------------------------------------------]|*6 1934 {11:[No Name] [+] }| 1935 [3:------------------------------------------------]| 1936 ## grid 2 1937 ea commodo consequat. Duis aute irure dolor in | 1938 reprehenderit in voluptate velit esse cillum | 1939 dolore eu fugiat nulla pariatur. Excepteur sint | 1940 occaecat cupidatat non proident, sunt in culpa | 1941 qui officia deserunt mollit anim id est | 1942 laborum^. | 1943 ## grid 3 1944 | 1945 ]], 1946 win_viewport = { 1947 [2] = { win = 1000, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11, sum_scroll_delta = 5 }, 1948 }, 1949 } 1950 1951 feed('<c-u>') 1952 screen:expect { 1953 grid = [[ 1954 ## grid 1 1955 [2:------------------------------------------------]|*6 1956 {11:[No Name] [+] }| 1957 [3:------------------------------------------------]| 1958 ## grid 2 1959 incididunt ut labore et dolore magna aliqua. | 1960 Ut enim ad minim veniam, quis nostrud | 1961 exercitation ullamco laboris nisi ut aliquip ex | 1962 ea commodo consequat. Duis aute irure dolor in | 1963 reprehenderit in voluptate velit esse cillum | 1964 ^dolore eu fugiat nulla pariatur. Excepteur sint | 1965 ## grid 3 1966 | 1967 ]], 1968 win_viewport = { 1969 [2] = { win = 1000, topline = 2, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 2 }, 1970 }, 1971 } 1972 1973 command('split') 1974 screen:expect { 1975 grid = [[ 1976 ## grid 1 1977 [4:------------------------------------------------]|*3 1978 {11:[No Name] [+] }| 1979 [2:------------------------------------------------]|*2 1980 {12:[No Name] [+] }| 1981 [3:------------------------------------------------]| 1982 ## grid 2 1983 reprehenderit in voluptate velit esse cillum | 1984 dolore eu fugiat nulla pariatur. Excepteur sint | 1985 ## grid 3 1986 | 1987 ## grid 4 1988 ea commodo consequat. Duis aute irure dolor in | 1989 reprehenderit in voluptate velit esse cillum | 1990 ^dolore eu fugiat nulla pariatur. Excepteur sint | 1991 ]], 1992 win_viewport = { 1993 [2] = { win = 1000, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6 }, 1994 [4] = { win = 1001, topline = 5, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 5 }, 1995 }, 1996 } 1997 1998 feed('b') 1999 screen:expect { 2000 grid = [[ 2001 ## grid 1 2002 [4:------------------------------------------------]|*3 2003 {11:[No Name] [+] }| 2004 [2:------------------------------------------------]|*2 2005 {12:[No Name] [+] }| 2006 [3:------------------------------------------------]| 2007 ## grid 2 2008 reprehenderit in voluptate velit esse cillum | 2009 dolore eu fugiat nulla pariatur. Excepteur sint | 2010 ## grid 3 2011 | 2012 ## grid 4 2013 ea commodo consequat. Duis aute irure dolor in | 2014 reprehenderit in voluptate velit esse ^cillum | 2015 dolore eu fugiat nulla pariatur. Excepteur sint | 2016 ]], 2017 win_viewport = { 2018 [2] = { win = 1000, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6 }, 2019 [4] = { win = 1001, topline = 5, botline = 9, curline = 6, curcol = 38, linecount = 11, sum_scroll_delta = 5 }, 2020 }, 2021 } 2022 2023 feed('2k') 2024 screen:expect { 2025 grid = [[ 2026 ## grid 1 2027 [4:------------------------------------------------]|*3 2028 {11:[No Name] [+] }| 2029 [2:------------------------------------------------]|*2 2030 {12:[No Name] [+] }| 2031 [3:------------------------------------------------]| 2032 ## grid 2 2033 reprehenderit in voluptate velit esse cillum | 2034 dolore eu fugiat nulla pariatur. Excepteur sint | 2035 ## grid 3 2036 | 2037 ## grid 4 2038 exercitation ullamco laboris nisi ut a^liquip ex | 2039 ea commodo consequat. Duis aute irure dolor in | 2040 reprehenderit in voluptate velit esse cillum | 2041 ]], 2042 win_viewport = { 2043 [2] = { win = 1000, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6 }, 2044 [4] = { win = 1001, topline = 4, botline = 8, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4 }, 2045 }, 2046 } 2047 2048 -- handles non-current window 2049 api.nvim_win_set_cursor(1000, { 1, 10 }) 2050 screen:expect { 2051 grid = [[ 2052 ## grid 1 2053 [4:------------------------------------------------]|*3 2054 {11:[No Name] [+] }| 2055 [2:------------------------------------------------]|*2 2056 {12:[No Name] [+] }| 2057 [3:------------------------------------------------]| 2058 ## grid 2 2059 Lorem ipsum dolor sit amet, consectetur | 2060 adipisicing elit, sed do eiusmod tempor | 2061 ## grid 3 2062 | 2063 ## grid 4 2064 exercitation ullamco laboris nisi ut a^liquip ex | 2065 ea commodo consequat. Duis aute irure dolor in | 2066 reprehenderit in voluptate velit esse cillum | 2067 ]], 2068 win_viewport = { 2069 [2] = { win = 1000, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2070 [4] = { win = 1001, topline = 4, botline = 8, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4 }, 2071 }, 2072 } 2073 2074 -- sum_scroll_delta works with folds 2075 feed('zfj') 2076 screen:expect { 2077 grid = [[ 2078 ## grid 1 2079 [4:------------------------------------------------]|*3 2080 {11:[No Name] [+] }| 2081 [2:------------------------------------------------]|*2 2082 {12:[No Name] [+] }| 2083 [3:------------------------------------------------]| 2084 ## grid 2 2085 Lorem ipsum dolor sit amet, consectetur | 2086 adipisicing elit, sed do eiusmod tempor | 2087 ## grid 3 2088 | 2089 ## grid 4 2090 {13:^+-- 2 lines: exercitation ullamco laboris nisi }| 2091 reprehenderit in voluptate velit esse cillum | 2092 dolore eu fugiat nulla pariatur. Excepteur sint | 2093 ]], 2094 win_viewport = { 2095 [2] = { win = 1000, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2096 [4] = { win = 1001, topline = 4, botline = 9, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4 }, 2097 }, 2098 } 2099 2100 feed('<c-e>') 2101 screen:expect { 2102 grid = [[ 2103 ## grid 1 2104 [4:------------------------------------------------]|*3 2105 {11:[No Name] [+] }| 2106 [2:------------------------------------------------]|*2 2107 {12:[No Name] [+] }| 2108 [3:------------------------------------------------]| 2109 ## grid 2 2110 Lorem ipsum dolor sit amet, consectetur | 2111 adipisicing elit, sed do eiusmod tempor | 2112 ## grid 3 2113 | 2114 ## grid 4 2115 ^reprehenderit in voluptate velit esse cillum | 2116 dolore eu fugiat nulla pariatur. Excepteur sint | 2117 occaecat cupidatat non proident, sunt in culpa | 2118 ]], 2119 win_viewport = { 2120 [2] = { win = 1000, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2121 [4] = { win = 1001, topline = 6, botline = 10, curline = 6, curcol = 0, linecount = 11, sum_scroll_delta = 5 }, 2122 }, 2123 } 2124 2125 command('close | 21vsplit | setlocal number smoothscroll') 2126 screen:expect { 2127 grid = [[ 2128 ## grid 1 2129 [5:---------------------]│[2:--------------------------]|*6 2130 {11:[No Name] [+] }{12:[No Name] [+] }| 2131 [3:------------------------------------------------]| 2132 ## grid 2 2133 Lorem ipsum dolor sit amet| 2134 , consectetur | 2135 adipisicing elit, sed do e| 2136 iusmod tempor | 2137 incididunt ut labore et do| 2138 lore magna aliqua. | 2139 ## grid 3 2140 | 2141 ## grid 5 2142 {19: 1 }Lorem ipsu^m dolor| 2143 {19: } sit amet, consec| 2144 {19: }tetur | 2145 {19: 2 }adipisicing elit,| 2146 {19: } sed do eiusmod t| 2147 {19: }empor | 2148 ]], 2149 win_viewport = { 2150 [2] = { win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2151 [5] = { win = 1002, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2152 }, 2153 } 2154 2155 feed('5<C-E>') 2156 screen:expect { 2157 grid = [[ 2158 ## grid 1 2159 [5:---------------------]│[2:--------------------------]|*6 2160 {11:[No Name] [+] }{12:[No Name] [+] }| 2161 [3:------------------------------------------------]| 2162 ## grid 2 2163 Lorem ipsum dolor sit amet| 2164 , consectetur | 2165 adipisicing elit, sed do e| 2166 iusmod tempor | 2167 incididunt ut labore et do| 2168 lore magna aliqua. | 2169 ## grid 3 2170 | 2171 ## grid 5 2172 {1:<<<}{19: }empo^r | 2173 {19: 3 }incididunt ut lab| 2174 {19: }ore et dolore mag| 2175 {19: }na aliqua. | 2176 {19: 4 }Ut enim ad minim | 2177 {19: }veniam, quis n{1:@@@}| 2178 ]], 2179 win_viewport = { 2180 [2] = { win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2181 [5] = { win = 1002, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 5 }, 2182 }, 2183 } 2184 2185 feed('<C-Y>') 2186 screen:expect { 2187 grid = [[ 2188 ## grid 1 2189 [5:---------------------]│[2:--------------------------]|*6 2190 {11:[No Name] [+] }{12:[No Name] [+] }| 2191 [3:------------------------------------------------]| 2192 ## grid 2 2193 Lorem ipsum dolor sit amet| 2194 , consectetur | 2195 adipisicing elit, sed do e| 2196 iusmod tempor | 2197 incididunt ut labore et do| 2198 lore magna aliqua. | 2199 ## grid 3 2200 | 2201 ## grid 5 2202 {1:<<<}{19: } sed do eiusmod t| 2203 {19: }empo^r | 2204 {19: 3 }incididunt ut lab| 2205 {19: }ore et dolore mag| 2206 {19: }na aliqua. | 2207 {19: 4 }Ut enim ad min{1:@@@}| 2208 ]], 2209 win_viewport = { 2210 [2] = { win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2211 [5] = { win = 1002, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 4 }, 2212 }, 2213 } 2214 2215 command('set cpoptions+=n') 2216 screen:expect { 2217 grid = [[ 2218 ## grid 1 2219 [5:---------------------]│[2:--------------------------]|*6 2220 {11:[No Name] [+] }{12:[No Name] [+] }| 2221 [3:------------------------------------------------]| 2222 ## grid 2 2223 Lorem ipsum dolor sit amet| 2224 , consectetur | 2225 adipisicing elit, sed do e| 2226 iusmod tempor | 2227 incididunt ut labore et do| 2228 lore magna aliqua. | 2229 ## grid 3 2230 | 2231 ## grid 5 2232 {1:<<<}d do eiusmod tempo| 2233 ^r | 2234 {19: 3 }incididunt ut lab| 2235 ore et dolore magna a| 2236 liqua. | 2237 {19: 4 }Ut enim ad min{1:@@@}| 2238 ]], 2239 win_viewport = { 2240 [2] = { win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2241 [5] = { win = 1002, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 4 }, 2242 }, 2243 } 2244 2245 feed('4<C-E>') 2246 screen:expect { 2247 grid = [[ 2248 ## grid 1 2249 [5:---------------------]│[2:--------------------------]|*6 2250 {11:[No Name] [+] }{12:[No Name] [+] }| 2251 [3:------------------------------------------------]| 2252 ## grid 2 2253 Lorem ipsum dolor sit amet| 2254 , consectetur | 2255 adipisicing elit, sed do e| 2256 iusmod tempor | 2257 incididunt ut labore et do| 2258 lore magna aliqua. | 2259 ## grid 3 2260 | 2261 ## grid 5 2262 {1:<<<}ua^. | 2263 {19: 4 }Ut enim ad minim | 2264 veniam, quis nostrud | 2265 {19: 5 }exercitation ulla| 2266 mco laboris nisi ut a| 2267 liquip ex | 2268 ]], 2269 win_viewport = { 2270 [2] = { win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2271 [5] = { win = 1002, topline = 2, botline = 6, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 8 }, 2272 }, 2273 } 2274 2275 feed('2<C-Y>') 2276 screen:expect { 2277 grid = [[ 2278 ## grid 1 2279 [5:---------------------]│[2:--------------------------]|*6 2280 {11:[No Name] [+] }{12:[No Name] [+] }| 2281 [3:------------------------------------------------]| 2282 ## grid 2 2283 Lorem ipsum dolor sit amet| 2284 , consectetur | 2285 adipisicing elit, sed do e| 2286 iusmod tempor | 2287 incididunt ut labore et do| 2288 lore magna aliqua. | 2289 ## grid 3 2290 | 2291 ## grid 5 2292 {19: 3 }incididunt ut lab| 2293 ore et dolore magna a| 2294 liqua^. | 2295 {19: 4 }Ut enim ad minim | 2296 veniam, quis nostrud | 2297 {19: 5 }exercitation u{1:@@@}| 2298 ]], 2299 win_viewport = { 2300 [2] = { win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2301 [5] = { win = 1002, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 6 }, 2302 }, 2303 } 2304 2305 command('setlocal numberwidth=12') 2306 screen:expect { 2307 grid = [[ 2308 ## grid 1 2309 [5:---------------------]│[2:--------------------------]|*6 2310 {11:[No Name] [+] }{12:[No Name] [+] }| 2311 [3:------------------------------------------------]| 2312 ## grid 2 2313 Lorem ipsum dolor sit amet| 2314 , consectetur | 2315 adipisicing elit, sed do e| 2316 iusmod tempor | 2317 incididunt ut labore et do| 2318 lore magna aliqua. | 2319 ## grid 3 2320 | 2321 ## grid 5 2322 {19: 3 }incididun| 2323 t ut labore et dolore| 2324 magna aliqua^. | 2325 {19: 4 }Ut enim a| 2326 d minim veniam, quis | 2327 nostrud | 2328 ]], 2329 win_viewport = { 2330 [2] = { win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2331 [5] = { win = 1002, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 6 }, 2332 }, 2333 } 2334 2335 feed('2<C-E>') 2336 screen:expect { 2337 grid = [[ 2338 ## grid 1 2339 [5:---------------------]│[2:--------------------------]|*6 2340 {11:[No Name] [+] }{12:[No Name] [+] }| 2341 [3:------------------------------------------------]| 2342 ## grid 2 2343 Lorem ipsum dolor sit amet| 2344 , consectetur | 2345 adipisicing elit, sed do e| 2346 iusmod tempor | 2347 incididunt ut labore et do| 2348 lore magna aliqua. | 2349 ## grid 3 2350 | 2351 ## grid 5 2352 {1:<<<}gna aliqua^. | 2353 {19: 4 }Ut enim a| 2354 d minim veniam, quis | 2355 nostrud | 2356 {19: 5 }exercitat| 2357 ion ullamco labori{1:@@@}| 2358 ]], 2359 win_viewport = { 2360 [2] = { win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2361 [5] = { win = 1002, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 8 }, 2362 }, 2363 } 2364 2365 feed('<C-E>') 2366 screen:expect { 2367 grid = [[ 2368 ## grid 1 2369 [5:---------------------]│[2:--------------------------]|*6 2370 {11:[No Name] [+] }{12:[No Name] [+] }| 2371 [3:------------------------------------------------]| 2372 ## grid 2 2373 Lorem ipsum dolor sit amet| 2374 , consectetur | 2375 adipisicing elit, sed do e| 2376 iusmod tempor | 2377 incididunt ut labore et do| 2378 lore magna aliqua. | 2379 ## grid 3 2380 | 2381 ## grid 5 2382 {19: 4 }Ut enim a| 2383 d minim veniam, quis | 2384 nostru^d | 2385 {19: 5 }exercitat| 2386 ion ullamco laboris n| 2387 isi ut aliquip ex | 2388 ]], 2389 win_viewport = { 2390 [2] = { win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0 }, 2391 [5] = { win = 1002, topline = 3, botline = 6, curline = 3, curcol = 36, linecount = 11, sum_scroll_delta = 9 }, 2392 }, 2393 } 2394 end) 2395 2396 it('scroll_delta is approximated reasonably when scrolling many lines #24234', function() 2397 command('setlocal number nowrap') 2398 command('edit test/functional/fixtures/bigfile.txt') 2399 screen:expect { 2400 grid = [[ 2401 ## grid 1 2402 [2:-----------------------------------------------------]|*12 2403 {11:test/functional/fixtures/bigfile.txt }| 2404 [3:-----------------------------------------------------]| 2405 ## grid 2 2406 {19: 1 }^0000;<control>;Cc;0;BN;;;;;N;NULL;;;; | 2407 {19: 2 }0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;| 2408 {19: 3 }0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;; | 2409 {19: 4 }0003;<control>;Cc;0;BN;;;;;N;END OF TEXT;;;; | 2410 {19: 5 }0004;<control>;Cc;0;BN;;;;;N;END OF TRANSMISSIO| 2411 {19: 6 }0005;<control>;Cc;0;BN;;;;;N;ENQUIRY;;;; | 2412 {19: 7 }0006;<control>;Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; | 2413 {19: 8 }0007;<control>;Cc;0;BN;;;;;N;BELL;;;; | 2414 {19: 9 }0008;<control>;Cc;0;BN;;;;;N;BACKSPACE;;;; | 2415 {19: 10 }0009;<control>;Cc;0;S;;;;;N;CHARACTER TABULATIO| 2416 {19: 11 }000A;<control>;Cc;0;B;;;;;N;LINE FEED (LF);;;; | 2417 {19: 12 }000B;<control>;Cc;0;S;;;;;N;LINE TABULATION;;;;| 2418 ## grid 3 2419 | 2420 ]], 2421 win_viewport = { 2422 [2] = { 2423 win = 1000, 2424 topline = 0, 2425 botline = 13, 2426 curline = 0, 2427 curcol = 0, 2428 linecount = 30592, 2429 sum_scroll_delta = 0, 2430 }, 2431 }, 2432 } 2433 feed('G') 2434 screen:expect { 2435 grid = [[ 2436 ## grid 1 2437 [2:-----------------------------------------------------]|*12 2438 {11:test/functional/fixtures/bigfile.txt }| 2439 [3:-----------------------------------------------------]| 2440 ## grid 2 2441 {19:30581 }E01E8;VARIATION SELECTOR-249;Mn;0;NSM;;;;;N;;;;| 2442 {19:30582 }E01E9;VARIATION SELECTOR-250;Mn;0;NSM;;;;;N;;;;| 2443 {19:30583 }E01EA;VARIATION SELECTOR-251;Mn;0;NSM;;;;;N;;;;| 2444 {19:30584 }E01EB;VARIATION SELECTOR-252;Mn;0;NSM;;;;;N;;;;| 2445 {19:30585 }E01EC;VARIATION SELECTOR-253;Mn;0;NSM;;;;;N;;;;| 2446 {19:30586 }E01ED;VARIATION SELECTOR-254;Mn;0;NSM;;;;;N;;;;| 2447 {19:30587 }E01EE;VARIATION SELECTOR-255;Mn;0;NSM;;;;;N;;;;| 2448 {19:30588 }E01EF;VARIATION SELECTOR-256;Mn;0;NSM;;;;;N;;;;| 2449 {19:30589 }F0000;<Plane 15 Private Use, First>;Co;0;L;;;;;| 2450 {19:30590 }FFFFD;<Plane 15 Private Use, Last>;Co;0;L;;;;;N| 2451 {19:30591 }100000;<Plane 16 Private Use, First>;Co;0;L;;;;| 2452 {19:30592 }^10FFFD;<Plane 16 Private Use, Last>;Co;0;L;;;;;| 2453 ## grid 3 2454 | 2455 ]], 2456 win_viewport = { 2457 [2] = { 2458 win = 1000, 2459 topline = 30580, 2460 botline = 30592, 2461 curline = 30591, 2462 curcol = 0, 2463 linecount = 30592, 2464 sum_scroll_delta = 30580, 2465 }, 2466 }, 2467 } 2468 feed('gg') 2469 screen:expect { 2470 grid = [[ 2471 ## grid 1 2472 [2:-----------------------------------------------------]|*12 2473 {11:test/functional/fixtures/bigfile.txt }| 2474 [3:-----------------------------------------------------]| 2475 ## grid 2 2476 {19: 1 }^0000;<control>;Cc;0;BN;;;;;N;NULL;;;; | 2477 {19: 2 }0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;| 2478 {19: 3 }0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;; | 2479 {19: 4 }0003;<control>;Cc;0;BN;;;;;N;END OF TEXT;;;; | 2480 {19: 5 }0004;<control>;Cc;0;BN;;;;;N;END OF TRANSMISSIO| 2481 {19: 6 }0005;<control>;Cc;0;BN;;;;;N;ENQUIRY;;;; | 2482 {19: 7 }0006;<control>;Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; | 2483 {19: 8 }0007;<control>;Cc;0;BN;;;;;N;BELL;;;; | 2484 {19: 9 }0008;<control>;Cc;0;BN;;;;;N;BACKSPACE;;;; | 2485 {19: 10 }0009;<control>;Cc;0;S;;;;;N;CHARACTER TABULATIO| 2486 {19: 11 }000A;<control>;Cc;0;B;;;;;N;LINE FEED (LF);;;; | 2487 {19: 12 }000B;<control>;Cc;0;S;;;;;N;LINE TABULATION;;;;| 2488 ## grid 3 2489 | 2490 ]], 2491 win_viewport = { 2492 [2] = { 2493 win = 1000, 2494 topline = 0, 2495 botline = 13, 2496 curline = 0, 2497 curcol = 0, 2498 linecount = 30592, 2499 sum_scroll_delta = 0, 2500 }, 2501 }, 2502 } 2503 command('setlocal wrap') 2504 screen:expect { 2505 grid = [[ 2506 ## grid 1 2507 [2:-----------------------------------------------------]|*12 2508 {11:test/functional/fixtures/bigfile.txt }| 2509 [3:-----------------------------------------------------]| 2510 ## grid 2 2511 {19: 1 }^0000;<control>;Cc;0;BN;;;;;N;NULL;;;; | 2512 {19: 2 }0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;| 2513 {19: };; | 2514 {19: 3 }0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;; | 2515 {19: 4 }0003;<control>;Cc;0;BN;;;;;N;END OF TEXT;;;; | 2516 {19: 5 }0004;<control>;Cc;0;BN;;;;;N;END OF TRANSMISSIO| 2517 {19: }N;;;; | 2518 {19: 6 }0005;<control>;Cc;0;BN;;;;;N;ENQUIRY;;;; | 2519 {19: 7 }0006;<control>;Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; | 2520 {19: 8 }0007;<control>;Cc;0;BN;;;;;N;BELL;;;; | 2521 {19: 9 }0008;<control>;Cc;0;BN;;;;;N;BACKSPACE;;;; | 2522 {19: 10 }0009;<control>;Cc;0;S;;;;;N;CHARACTER TABULA{1:@@@}| 2523 ## grid 3 2524 | 2525 ]], 2526 win_viewport = { 2527 [2] = { 2528 win = 1000, 2529 topline = 0, 2530 botline = 10, 2531 curline = 0, 2532 curcol = 0, 2533 linecount = 30592, 2534 sum_scroll_delta = 0, 2535 }, 2536 }, 2537 } 2538 feed('G') 2539 screen:expect { 2540 grid = [[ 2541 ## grid 1 2542 [2:-----------------------------------------------------]|*12 2543 {11:test/functional/fixtures/bigfile.txt }| 2544 [3:-----------------------------------------------------]| 2545 ## grid 2 2546 {19:30587 }E01EE;VARIATION SELECTOR-255;Mn;0;NSM;;;;;N;;;;| 2547 {19: }; | 2548 {19:30588 }E01EF;VARIATION SELECTOR-256;Mn;0;NSM;;;;;N;;;;| 2549 {19: }; | 2550 {19:30589 }F0000;<Plane 15 Private Use, First>;Co;0;L;;;;;| 2551 {19: }N;;;;; | 2552 {19:30590 }FFFFD;<Plane 15 Private Use, Last>;Co;0;L;;;;;N| 2553 {19: };;;;; | 2554 {19:30591 }100000;<Plane 16 Private Use, First>;Co;0;L;;;;| 2555 {19: };N;;;;; | 2556 {19:30592 }^10FFFD;<Plane 16 Private Use, Last>;Co;0;L;;;;;| 2557 {19: }N;;;;; | 2558 ## grid 3 2559 | 2560 ]], 2561 win_viewport = { 2562 [2] = { 2563 win = 1000, 2564 topline = 30586, 2565 botline = 30592, 2566 curline = 30591, 2567 curcol = 0, 2568 linecount = 30592, 2569 sum_scroll_delta = 30588, 2570 }, 2571 }, 2572 } 2573 feed('gg') 2574 screen:expect { 2575 grid = [[ 2576 ## grid 1 2577 [2:-----------------------------------------------------]|*12 2578 {11:test/functional/fixtures/bigfile.txt }| 2579 [3:-----------------------------------------------------]| 2580 ## grid 2 2581 {19: 1 }^0000;<control>;Cc;0;BN;;;;;N;NULL;;;; | 2582 {19: 2 }0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;| 2583 {19: };; | 2584 {19: 3 }0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;; | 2585 {19: 4 }0003;<control>;Cc;0;BN;;;;;N;END OF TEXT;;;; | 2586 {19: 5 }0004;<control>;Cc;0;BN;;;;;N;END OF TRANSMISSIO| 2587 {19: }N;;;; | 2588 {19: 6 }0005;<control>;Cc;0;BN;;;;;N;ENQUIRY;;;; | 2589 {19: 7 }0006;<control>;Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; | 2590 {19: 8 }0007;<control>;Cc;0;BN;;;;;N;BELL;;;; | 2591 {19: 9 }0008;<control>;Cc;0;BN;;;;;N;BACKSPACE;;;; | 2592 {19: 10 }0009;<control>;Cc;0;S;;;;;N;CHARACTER TABULA{1:@@@}| 2593 ## grid 3 2594 | 2595 ]], 2596 win_viewport = { 2597 [2] = { 2598 win = 1000, 2599 topline = 0, 2600 botline = 10, 2601 curline = 0, 2602 curcol = 0, 2603 linecount = 30592, 2604 sum_scroll_delta = 0, 2605 }, 2606 }, 2607 } 2608 end) 2609 2610 it('does not crash when dragging mouse across grid boundary', function() 2611 screen:try_resize(48, 8) 2612 screen:expect { 2613 grid = [[ 2614 ## grid 1 2615 [2:------------------------------------------------]|*6 2616 {11:[No Name] }| 2617 [3:------------------------------------------------]| 2618 ## grid 2 2619 ^ | 2620 {1:~ }|*5 2621 ## grid 3 2622 | 2623 ]], 2624 win_viewport = { 2625 [2] = { win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 }, 2626 }, 2627 } 2628 insert([[ 2629 Lorem ipsum dolor sit amet, consectetur 2630 adipisicing elit, sed do eiusmod tempor 2631 incididunt ut labore et dolore magna aliqua. 2632 Ut enim ad minim veniam, quis nostrud 2633 exercitation ullamco laboris nisi ut aliquip ex 2634 ea commodo consequat. Duis aute irure dolor in 2635 reprehenderit in voluptate velit esse cillum 2636 dolore eu fugiat nulla pariatur. Excepteur sint 2637 occaecat cupidatat non proident, sunt in culpa 2638 qui officia deserunt mollit anim id est 2639 laborum.]]) 2640 2641 screen:expect { 2642 grid = [[ 2643 ## grid 1 2644 [2:------------------------------------------------]|*6 2645 {11:[No Name] [+] }| 2646 [3:------------------------------------------------]| 2647 ## grid 2 2648 ea commodo consequat. Duis aute irure dolor in | 2649 reprehenderit in voluptate velit esse cillum | 2650 dolore eu fugiat nulla pariatur. Excepteur sint | 2651 occaecat cupidatat non proident, sunt in culpa | 2652 qui officia deserunt mollit anim id est | 2653 laborum^. | 2654 ## grid 3 2655 | 2656 ]], 2657 win_viewport = { 2658 [2] = { win = 1000, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11, sum_scroll_delta = 5 }, 2659 }, 2660 } 2661 2662 api.nvim_input_mouse('left', 'press', '', 1, 5, 1) 2663 poke_eventloop() 2664 api.nvim_input_mouse('left', 'drag', '', 1, 6, 1) 2665 2666 screen:expect { 2667 grid = [[ 2668 ## grid 1 2669 [2:------------------------------------------------]|*6 2670 {11:[No Name] [+] }| 2671 [3:------------------------------------------------]| 2672 ## grid 2 2673 reprehenderit in voluptate velit esse cillum | 2674 dolore eu fugiat nulla pariatur. Excepteur sint | 2675 occaecat cupidatat non proident, sunt in culpa | 2676 qui officia deserunt mollit anim id est | 2677 l^aborum. | 2678 {1:~ }| 2679 ## grid 3 2680 {7:-- VISUAL --} | 2681 ]], 2682 win_viewport = { 2683 [2] = { win = 1000, topline = 6, botline = 12, curline = 10, curcol = 1, linecount = 11, sum_scroll_delta = 6 }, 2684 }, 2685 } 2686 end) 2687 2688 it('with winbar', function() 2689 command('split') 2690 local win_pos = { 2691 [2] = { 2692 height = 5, 2693 startcol = 0, 2694 startrow = 7, 2695 width = 53, 2696 win = 1000, 2697 }, 2698 [4] = { 2699 height = 6, 2700 startcol = 0, 2701 startrow = 0, 2702 width = 53, 2703 win = 1001, 2704 }, 2705 } 2706 screen:expect { 2707 grid = [[ 2708 ## grid 1 2709 [4:-----------------------------------------------------]|*6 2710 {11:[No Name] }| 2711 [2:-----------------------------------------------------]|*5 2712 {12:[No Name] }| 2713 [3:-----------------------------------------------------]| 2714 ## grid 2 2715 | 2716 {1:~ }|*4 2717 ## grid 3 2718 | 2719 ## grid 4 2720 ^ | 2721 {1:~ }|*5 2722 ]], 2723 win_viewport = { 2724 [2] = { win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 }, 2725 [4] = { win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 }, 2726 }, 2727 win_viewport_margins = { 2728 [2] = { win = 1000, top = 0, bottom = 0, left = 0, right = 0 }, 2729 [4] = { win = 1001, top = 0, bottom = 0, left = 0, right = 0 }, 2730 }, 2731 win_pos = win_pos, 2732 } 2733 2734 command('setlocal winbar=very%=bar') 2735 screen:expect { 2736 grid = [[ 2737 ## grid 1 2738 [4:-----------------------------------------------------]|*6 2739 {11:[No Name] }| 2740 [2:-----------------------------------------------------]|*5 2741 {12:[No Name] }| 2742 [3:-----------------------------------------------------]| 2743 ## grid 2 2744 | 2745 {1:~ }|*4 2746 ## grid 3 2747 | 2748 ## grid 4 2749 {7:very bar}| 2750 ^ | 2751 {1:~ }|*4 2752 ]], 2753 win_viewport = { 2754 [2] = { win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 }, 2755 [4] = { win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 }, 2756 }, 2757 win_viewport_margins = { 2758 [2] = { win = 1000, top = 0, bottom = 0, left = 0, right = 0 }, 2759 [4] = { win = 1001, top = 1, bottom = 0, left = 0, right = 0 }, 2760 }, 2761 win_pos = win_pos, 2762 } 2763 2764 command('setlocal winbar=') 2765 screen:expect { 2766 grid = [[ 2767 ## grid 1 2768 [4:-----------------------------------------------------]|*6 2769 {11:[No Name] }| 2770 [2:-----------------------------------------------------]|*5 2771 {12:[No Name] }| 2772 [3:-----------------------------------------------------]| 2773 ## grid 2 2774 | 2775 {1:~ }|*4 2776 ## grid 3 2777 | 2778 ## grid 4 2779 ^ | 2780 {1:~ }|*5 2781 ]], 2782 win_viewport = { 2783 [2] = { win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 }, 2784 [4] = { win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 }, 2785 }, 2786 win_viewport_margins = { 2787 [2] = { win = 1000, top = 0, bottom = 0, left = 0, right = 0 }, 2788 [4] = { win = 1001, top = 0, bottom = 0, left = 0, right = 0 }, 2789 }, 2790 win_pos = win_pos, 2791 } 2792 end) 2793 2794 it('with winbar dragging statusline with mouse works correctly', function() 2795 api.nvim_set_option_value('winbar', 'Set Up The Bars', {}) 2796 command('split') 2797 screen:expect([[ 2798 ## grid 1 2799 [4:-----------------------------------------------------]|*6 2800 {11:[No Name] }| 2801 [2:-----------------------------------------------------]|*5 2802 {12:[No Name] }| 2803 [3:-----------------------------------------------------]| 2804 ## grid 2 2805 {7:Set Up The Bars }| 2806 | 2807 {1:~ }|*3 2808 ## grid 3 2809 | 2810 ## grid 4 2811 {7:Set Up The Bars }| 2812 ^ | 2813 {1:~ }|*4 2814 ]]) 2815 2816 api.nvim_input_mouse('left', 'press', '', 1, 6, 20) 2817 poke_eventloop() 2818 api.nvim_input_mouse('left', 'drag', '', 1, 7, 20) 2819 screen:expect([[ 2820 ## grid 1 2821 [4:-----------------------------------------------------]|*7 2822 {11:[No Name] }| 2823 [2:-----------------------------------------------------]|*4 2824 {12:[No Name] }| 2825 [3:-----------------------------------------------------]| 2826 ## grid 2 2827 {7:Set Up The Bars }| 2828 | 2829 {1:~ }|*2 2830 ## grid 3 2831 | 2832 ## grid 4 2833 {7:Set Up The Bars }| 2834 ^ | 2835 {1:~ }|*5 2836 ]]) 2837 2838 api.nvim_input_mouse('left', 'drag', '', 1, 4, 20) 2839 screen:expect([[ 2840 ## grid 1 2841 [4:-----------------------------------------------------]|*4 2842 {11:[No Name] }| 2843 [2:-----------------------------------------------------]|*7 2844 {12:[No Name] }| 2845 [3:-----------------------------------------------------]| 2846 ## grid 2 2847 {7:Set Up The Bars }| 2848 | 2849 {1:~ }|*5 2850 ## grid 3 2851 | 2852 ## grid 4 2853 {7:Set Up The Bars }| 2854 ^ | 2855 {1:~ }|*2 2856 ]]) 2857 2858 api.nvim_input_mouse('left', 'press', '', 1, 12, 10) 2859 poke_eventloop() 2860 api.nvim_input_mouse('left', 'drag', '', 1, 10, 10) 2861 screen:expect([[ 2862 ## grid 1 2863 [4:-----------------------------------------------------]|*4 2864 {11:[No Name] }| 2865 [2:-----------------------------------------------------]|*5 2866 {12:[No Name] }| 2867 [3:-----------------------------------------------------]|*3 2868 ## grid 2 2869 {7:Set Up The Bars }| 2870 | 2871 {1:~ }|*3 2872 ## grid 3 2873 |*3 2874 ## grid 4 2875 {7:Set Up The Bars }| 2876 ^ | 2877 {1:~ }|*2 2878 ]]) 2879 eq(3, api.nvim_get_option_value('cmdheight', {})) 2880 2881 api.nvim_input_mouse('left', 'drag', '', 1, 12, 10) 2882 screen:expect([[ 2883 ## grid 1 2884 [4:-----------------------------------------------------]|*4 2885 {11:[No Name] }| 2886 [2:-----------------------------------------------------]|*7 2887 {12:[No Name] }| 2888 [3:-----------------------------------------------------]| 2889 ## grid 2 2890 {7:Set Up The Bars }| 2891 | 2892 {1:~ }|*5 2893 ## grid 3 2894 | 2895 ## grid 4 2896 {7:Set Up The Bars }| 2897 ^ | 2898 {1:~ }|*2 2899 ]]) 2900 eq(1, api.nvim_get_option_value('cmdheight', {})) 2901 end) 2902 2903 describe('centered cursorline', function() 2904 before_each(function() 2905 -- Force a centered cursorline, this caused some redrawing problems described in #30576. 2906 -- Most importantly, win_viewport was not received in time, and sum_scroll_delta did not refresh. 2907 command('set cursorline scrolloff=9999') 2908 end) 2909 it('insert line scrolls correctly', function() 2910 for i = 1, 11 do 2911 insert('line' .. i .. '\n') 2912 end 2913 screen:expect({ 2914 grid = [[ 2915 ## grid 1 2916 [2:-----------------------------------------------------]|*12 2917 {11:[No Name] [+] }| 2918 [3:-----------------------------------------------------]| 2919 ## grid 2 2920 line1 | 2921 line2 | 2922 line3 | 2923 line4 | 2924 line5 | 2925 line6 | 2926 line7 | 2927 line8 | 2928 line9 | 2929 line10 | 2930 line11 | 2931 {23:^ }| 2932 ## grid 3 2933 | 2934 ]], 2935 win_viewport = { 2936 [2] = { 2937 win = 1000, 2938 topline = 0, 2939 botline = 12, 2940 curline = 11, 2941 curcol = 0, 2942 linecount = 12, 2943 sum_scroll_delta = 0, 2944 }, 2945 }, 2946 win_viewport_margins = { 2947 [2] = { 2948 bottom = 0, 2949 left = 0, 2950 right = 0, 2951 top = 0, 2952 win = 1000, 2953 }, 2954 }, 2955 }) 2956 insert('line12\n') 2957 screen:expect({ 2958 grid = [[ 2959 ## grid 1 2960 [2:-----------------------------------------------------]|*12 2961 {11:[No Name] [+] }| 2962 [3:-----------------------------------------------------]| 2963 ## grid 2 2964 line2 | 2965 line3 | 2966 line4 | 2967 line5 | 2968 line6 | 2969 line7 | 2970 line8 | 2971 line9 | 2972 line10 | 2973 line11 | 2974 line12 | 2975 {23:^ }| 2976 ## grid 3 2977 | 2978 ]], 2979 win_viewport = { 2980 [2] = { 2981 win = 1000, 2982 topline = 1, 2983 botline = 13, 2984 curline = 12, 2985 curcol = 0, 2986 linecount = 13, 2987 sum_scroll_delta = 1, 2988 }, 2989 }, 2990 win_viewport_margins = { 2991 [2] = { 2992 bottom = 0, 2993 left = 0, 2994 right = 0, 2995 top = 0, 2996 win = 1000, 2997 }, 2998 }, 2999 }) 3000 end) 3001 3002 it('got to top scrolls correctly', function() 3003 for i = 1, 20 do 3004 insert('line' .. i .. '\n') 3005 end 3006 screen:expect({ 3007 grid = [[ 3008 ## grid 1 3009 [2:-----------------------------------------------------]|*12 3010 {11:[No Name] [+] }| 3011 [3:-----------------------------------------------------]| 3012 ## grid 2 3013 line10 | 3014 line11 | 3015 line12 | 3016 line13 | 3017 line14 | 3018 line15 | 3019 line16 | 3020 line17 | 3021 line18 | 3022 line19 | 3023 line20 | 3024 {23:^ }| 3025 ## grid 3 3026 | 3027 ]], 3028 win_viewport = { 3029 [2] = { 3030 win = 1000, 3031 topline = 9, 3032 botline = 21, 3033 curline = 20, 3034 curcol = 0, 3035 linecount = 21, 3036 sum_scroll_delta = 9, 3037 }, 3038 }, 3039 win_viewport_margins = { 3040 [2] = { 3041 bottom = 0, 3042 left = 0, 3043 right = 0, 3044 top = 0, 3045 win = 1000, 3046 }, 3047 }, 3048 }) 3049 feed('gg') 3050 screen:expect({ 3051 grid = [[ 3052 ## grid 1 3053 [2:-----------------------------------------------------]|*12 3054 {11:[No Name] [+] }| 3055 [3:-----------------------------------------------------]| 3056 ## grid 2 3057 {23:^line1 }| 3058 line2 | 3059 line3 | 3060 line4 | 3061 line5 | 3062 line6 | 3063 line7 | 3064 line8 | 3065 line9 | 3066 line10 | 3067 line11 | 3068 line12 | 3069 ## grid 3 3070 | 3071 ]], 3072 win_viewport = { 3073 [2] = { win = 1000, topline = 0, botline = 13, curline = 0, curcol = 0, linecount = 21, sum_scroll_delta = 0 }, 3074 }, 3075 win_viewport_margins = { 3076 [2] = { 3077 bottom = 0, 3078 left = 0, 3079 right = 0, 3080 top = 0, 3081 win = 1000, 3082 }, 3083 }, 3084 }) 3085 end) 3086 3087 it('scrolls in the middle', function() 3088 for i = 1, 20 do 3089 insert('line' .. i .. '\n') 3090 end 3091 screen:expect({ 3092 grid = [[ 3093 ## grid 1 3094 [2:-----------------------------------------------------]|*12 3095 {11:[No Name] [+] }| 3096 [3:-----------------------------------------------------]| 3097 ## grid 2 3098 line10 | 3099 line11 | 3100 line12 | 3101 line13 | 3102 line14 | 3103 line15 | 3104 line16 | 3105 line17 | 3106 line18 | 3107 line19 | 3108 line20 | 3109 {23:^ }| 3110 ## grid 3 3111 | 3112 ]], 3113 win_viewport = { 3114 [2] = { 3115 win = 1000, 3116 topline = 9, 3117 botline = 21, 3118 curline = 20, 3119 curcol = 0, 3120 linecount = 21, 3121 sum_scroll_delta = 9, 3122 }, 3123 }, 3124 win_viewport_margins = { 3125 [2] = { 3126 bottom = 0, 3127 left = 0, 3128 right = 0, 3129 top = 0, 3130 win = 1000, 3131 }, 3132 }, 3133 }) 3134 feed('M') 3135 screen:expect({ 3136 grid = [[ 3137 ## grid 1 3138 [2:-----------------------------------------------------]|*12 3139 {11:[No Name] [+] }| 3140 [3:-----------------------------------------------------]| 3141 ## grid 2 3142 line10 | 3143 line11 | 3144 line12 | 3145 line13 | 3146 line14 | 3147 {23:^line15 }| 3148 line16 | 3149 line17 | 3150 line18 | 3151 line19 | 3152 line20 | 3153 | 3154 ## grid 3 3155 | 3156 ]], 3157 win_viewport = { 3158 [2] = { 3159 win = 1000, 3160 topline = 9, 3161 botline = 21, 3162 curline = 14, 3163 curcol = 0, 3164 linecount = 21, 3165 sum_scroll_delta = 9, 3166 }, 3167 }, 3168 win_viewport_margins = { 3169 [2] = { 3170 bottom = 0, 3171 left = 0, 3172 right = 0, 3173 top = 0, 3174 win = 1000, 3175 }, 3176 }, 3177 }) 3178 feed('k') 3179 screen:expect({ 3180 grid = [[ 3181 ## grid 1 3182 [2:-----------------------------------------------------]|*12 3183 {11:[No Name] [+] }| 3184 [3:-----------------------------------------------------]| 3185 ## grid 2 3186 line9 | 3187 line10 | 3188 line11 | 3189 line12 | 3190 line13 | 3191 {23:^line14 }| 3192 line15 | 3193 line16 | 3194 line17 | 3195 line18 | 3196 line19 | 3197 line20 | 3198 ## grid 3 3199 | 3200 ]], 3201 win_viewport = { 3202 [2] = { 3203 win = 1000, 3204 topline = 8, 3205 botline = 21, 3206 curline = 13, 3207 curcol = 0, 3208 linecount = 21, 3209 sum_scroll_delta = 8, 3210 }, 3211 }, 3212 win_viewport_margins = { 3213 [2] = { 3214 bottom = 0, 3215 left = 0, 3216 right = 0, 3217 top = 0, 3218 win = 1000, 3219 }, 3220 }, 3221 }) 3222 end) 3223 end) 3224 3225 it('message grid is shown at the correct position remote re-attach', function() 3226 feed(':test') 3227 local expected = { 3228 grid = [[ 3229 ## grid 1 3230 [2:-----------------------------------------------------]|*12 3231 {11:[No Name] }| 3232 [3:-----------------------------------------------------]| 3233 ## grid 2 3234 | 3235 {1:~ }|*11 3236 ## grid 3 3237 :test^ | 3238 ]], 3239 win_pos = { 3240 [2] = { 3241 height = 12, 3242 startcol = 0, 3243 startrow = 0, 3244 width = 53, 3245 win = 1000, 3246 }, 3247 }, 3248 win_viewport = { 3249 [2] = { win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 }, 3250 }, 3251 win_viewport_margins = { 3252 [2] = { 3253 bottom = 0, 3254 left = 0, 3255 right = 0, 3256 top = 0, 3257 win = 1000, 3258 }, 3259 }, 3260 reset = true, 3261 } 3262 screen:expect(expected) 3263 feed('<cr>') 3264 screen:detach() 3265 screen:attach() 3266 feed(':test') 3267 screen:expect(expected) 3268 end) 3269 end) 3270 3271 it('headless attach with showcmd', function() 3272 clear { args = { '--headless' } } 3273 local screen = Screen.new(80, 24, { ext_multigrid = true }) 3274 command('set showcmd') 3275 feed('1234') 3276 screen:expect({ 3277 grid = [[ 3278 ## grid 1 3279 [2:--------------------------------------------------------------------------------]|*23 3280 [3:--------------------------------------------------------------------------------]| 3281 ## grid 2 3282 ^ | 3283 {1:~ }|*22 3284 ## grid 3 3285 1234 | 3286 ]], 3287 win_viewport = { 3288 [2] = { win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 }, 3289 }, 3290 }) 3291 end)