fold_spec.lua (116232B)
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, feed, eq = n.clear, n.feed, t.eq 6 local command = n.command 7 local feed_command = n.feed_command 8 local insert = n.insert 9 local fn = n.fn 10 local api = n.api 11 local exec = n.exec 12 local assert_alive = n.assert_alive 13 14 local content1 = [[ 15 This is a 16 valid English 17 sentence composed by 18 an exhausted developer 19 in his cave. 20 ]] 21 22 describe('folded lines', function() 23 before_each(function() 24 clear() 25 command('hi VertSplit gui=reverse') 26 end) 27 28 local function with_ext_multigrid(multigrid) 29 local screen 30 before_each(function() 31 screen = Screen.new(45, 8, { rgb = true, ext_multigrid = multigrid }) 32 screen:add_extra_attr_ids({ 33 [100] = { foreground = Screen.colors.Red }, 34 [101] = { foreground = Screen.colors.Red, background = Screen.colors.LightGrey }, 35 [102] = { underline = true }, 36 [103] = { foreground = Screen.colors.Blue4, background = Screen.colors.Red }, 37 [104] = { 38 bold = true, 39 background = Screen.colors.LightGray, 40 foreground = Screen.colors.Blue1, 41 }, 42 [105] = { background = Screen.colors.Yellow1, foreground = Screen.colors.Blue4 }, 43 [106] = { bold = true, background = Screen.colors.Red, foreground = Screen.colors.Blue1 }, 44 [107] = { background = Screen.colors.LightGrey, foreground = Screen.colors.WebGreen }, 45 [108] = { foreground = Screen.colors.Green, background = Screen.colors.Red }, 46 [109] = { foreground = Screen.colors.Blue, bold = true, background = Screen.colors.Yellow1 }, 47 }) 48 end) 49 50 it('with more than one signcolumn', function() 51 command('set signcolumn=yes:9') 52 feed('i<cr><esc>') 53 feed('vkzf') 54 if multigrid then 55 screen:expect([[ 56 ## grid 1 57 [2:---------------------------------------------]|*7 58 [3:---------------------------------------------]| 59 ## grid 2 60 {7: }{13:^+-- 2 lines: ·············}| 61 {1:~ }|*6 62 ## grid 3 63 | 64 ]]) 65 else 66 screen:expect([[ 67 {7: }{13:^+-- 2 lines: ·············}| 68 {1:~ }|*6 69 | 70 ]]) 71 end 72 end) 73 74 local function test_folded_cursorline(foldtext) 75 if not foldtext then 76 command('set foldtext=') 77 end 78 command('set number cursorline foldcolumn=2') 79 command('hi link CursorLineFold Search') 80 insert(content1) 81 feed('ggzf3jj') 82 83 if multigrid then 84 if foldtext then 85 screen:expect([[ 86 ## grid 1 87 [2:---------------------------------------------]|*7 88 [3:---------------------------------------------]| 89 ## grid 2 90 {7:+ }{8: 1 }{13:+-- 4 lines: This is a················}| 91 {10: }{15: 5 }{100:^in his cave. }| 92 {7: }{8: 6 } | 93 {1:~ }|*4 94 ## grid 3 95 | 96 ]]) 97 else 98 screen:expect([[ 99 ## grid 1 100 [2:---------------------------------------------]|*7 101 [3:---------------------------------------------]| 102 ## grid 2 103 {7:+ }{8: 1 }{13:This is a······························}| 104 {10: }{15: 5 }{100:^in his cave. }| 105 {7: }{8: 6 } | 106 {1:~ }|*4 107 ## grid 3 108 | 109 ]]) 110 end 111 else 112 if foldtext then 113 screen:expect([[ 114 {7:+ }{8: 1 }{13:+-- 4 lines: This is a················}| 115 {10: }{15: 5 }{100:^in his cave. }| 116 {7: }{8: 6 } | 117 {1:~ }|*4 118 | 119 ]]) 120 else 121 screen:expect([[ 122 {7:+ }{8: 1 }{13:This is a······························}| 123 {10: }{15: 5 }{100:^in his cave. }| 124 {7: }{8: 6 } | 125 {1:~ }|*4 126 | 127 ]]) 128 end 129 end 130 131 feed('k') 132 133 if multigrid then 134 if foldtext then 135 screen:expect([[ 136 ## grid 1 137 [2:---------------------------------------------]|*7 138 [3:---------------------------------------------]| 139 ## grid 2 140 {10:+ }{15: 1 }{101:^+-- 4 lines: This is a················}| 141 {7: }{8: 5 }in his cave. | 142 {7: }{8: 6 } | 143 {1:~ }|*4 144 ## grid 3 145 | 146 ]]) 147 else 148 screen:expect([[ 149 ## grid 1 150 [2:---------------------------------------------]|*7 151 [3:---------------------------------------------]| 152 ## grid 2 153 {10:+ }{15: 1 }{101:^This is a······························}| 154 {7: }{8: 5 }in his cave. | 155 {7: }{8: 6 } | 156 {1:~ }|*4 157 ## grid 3 158 | 159 ]]) 160 end 161 else 162 if foldtext then 163 screen:expect([[ 164 {10:+ }{15: 1 }{101:^+-- 4 lines: This is a················}| 165 {7: }{8: 5 }in his cave. | 166 {7: }{8: 6 } | 167 {1:~ }|*4 168 | 169 ]]) 170 else 171 screen:expect([[ 172 {10:+ }{15: 1 }{101:^This is a······························}| 173 {7: }{8: 5 }in his cave. | 174 {7: }{8: 6 } | 175 {1:~ }|*4 176 | 177 ]]) 178 end 179 end 180 181 -- CursorLine is applied correctly with screenrow motions #22232 182 feed('jgk') 183 screen:expect_unchanged() 184 -- CursorLine is applied correctly when closing a fold when cursor is not at fold start 185 feed('zo4Gzc') 186 screen:expect_unchanged() 187 command('set cursorlineopt=line') 188 189 if multigrid then 190 if foldtext then 191 screen:expect([[ 192 ## grid 1 193 [2:---------------------------------------------]|*7 194 [3:---------------------------------------------]| 195 ## grid 2 196 {7:+ }{8: 1 }{101:^+-- 4 lines: This is a················}| 197 {7: }{8: 5 }in his cave. | 198 {7: }{8: 6 } | 199 {1:~ }|*4 200 ## grid 3 201 | 202 ]]) 203 else 204 screen:expect([[ 205 ## grid 1 206 [2:---------------------------------------------]|*7 207 [3:---------------------------------------------]| 208 ## grid 2 209 {7:+ }{8: 1 }{101:^This is a······························}| 210 {7: }{8: 5 }in his cave. | 211 {7: }{8: 6 } | 212 {1:~ }|*4 213 ## grid 3 214 | 215 ]]) 216 end 217 else 218 if foldtext then 219 screen:expect([[ 220 {7:+ }{8: 1 }{101:^+-- 4 lines: This is a················}| 221 {7: }{8: 5 }in his cave. | 222 {7: }{8: 6 } | 223 {1:~ }|*4 224 | 225 ]]) 226 else 227 screen:expect([[ 228 {7:+ }{8: 1 }{101:^This is a······························}| 229 {7: }{8: 5 }in his cave. | 230 {7: }{8: 6 } | 231 {1:~ }|*4 232 | 233 ]]) 234 end 235 end 236 237 command('set relativenumber cursorlineopt=number') 238 239 if multigrid then 240 if foldtext then 241 screen:expect([[ 242 ## grid 1 243 [2:---------------------------------------------]|*7 244 [3:---------------------------------------------]| 245 ## grid 2 246 {10:+ }{15:1 }{13:^+-- 4 lines: This is a················}| 247 {7: }{8: 1 }in his cave. | 248 {7: }{8: 2 } | 249 {1:~ }|*4 250 ## grid 3 251 | 252 ]]) 253 else 254 screen:expect([[ 255 ## grid 1 256 [2:---------------------------------------------]|*7 257 [3:---------------------------------------------]| 258 ## grid 2 259 {10:+ }{15:1 }{13:^This is a······························}| 260 {7: }{8: 1 }in his cave. | 261 {7: }{8: 2 } | 262 {1:~ }|*4 263 ## grid 3 264 | 265 ]]) 266 end 267 else 268 if foldtext then 269 screen:expect([[ 270 {10:+ }{15:1 }{13:^+-- 4 lines: This is a················}| 271 {7: }{8: 1 }in his cave. | 272 {7: }{8: 2 } | 273 {1:~ }|*4 274 | 275 ]]) 276 else 277 screen:expect([[ 278 {10:+ }{15:1 }{13:^This is a······························}| 279 {7: }{8: 1 }in his cave. | 280 {7: }{8: 2 } | 281 {1:~ }|*4 282 | 283 ]]) 284 end 285 end 286 end 287 288 describe("when 'cursorline' is set", function() 289 local function cursorline_tests(foldtext) 290 local sfx = not foldtext and ' (transparent foldtext)' or '' 291 it('with high-priority CursorLine' .. sfx, function() 292 command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') 293 test_folded_cursorline(foldtext) 294 end) 295 296 it('with low-priority CursorLine' .. sfx, function() 297 command('hi! CursorLine guibg=NONE guifg=NONE gui=underline') 298 screen:add_extra_attr_ids({ 299 [100] = { underline = true }, 300 [101] = { 301 background = Screen.colors.LightGray, 302 underline = true, 303 foreground = Screen.colors.Blue4, 304 }, 305 }) 306 test_folded_cursorline(foldtext) 307 end) 308 end 309 310 cursorline_tests(true) 311 cursorline_tests(false) 312 end) 313 314 it('with spell', function() 315 command('set spell') 316 insert(content1) 317 318 feed('gg') 319 feed('zf3j') 320 if not multigrid then 321 screen:expect([[ 322 {13:^+-- 4 lines: This is a······················}| 323 in his cave. | 324 | 325 {1:~ }|*4 326 | 327 ]]) 328 end 329 end) 330 331 it('with matches', function() 332 insert(content1) 333 command('highlight MyWord gui=bold guibg=red guifg=white') 334 command("call matchadd('MyWord', '\\V' . 'test', -1)") 335 feed('gg') 336 feed('zf3j') 337 if not multigrid then 338 screen:expect([[ 339 {13:^+-- 4 lines: This is a······················}| 340 in his cave. | 341 | 342 {1:~ }|*4 343 | 344 ]]) 345 end 346 end) 347 348 it('with multibyte fillchars', function() 349 insert([[ 350 aa 351 bb 352 cc 353 dd 354 ee 355 ff]]) 356 command('set fillchars+=foldopen:▾,foldsep:│,foldclose:▸') 357 feed_command('1') 358 command('set foldcolumn=2') 359 feed('zf4j') 360 feed('zf2j') 361 feed('zO') 362 if multigrid then 363 screen:expect([[ 364 ## grid 1 365 [2:---------------------------------------------]|*7 366 [3:---------------------------------------------]| 367 ## grid 2 368 {7:▾▾}^aa | 369 {7:││}bb | 370 {7:││}cc | 371 {7:││}dd | 372 {7:││}ee | 373 {7:│ }ff | 374 {1:~ }| 375 ## grid 3 376 :1 | 377 ]]) 378 else 379 screen:expect([[ 380 {7:▾▾}^aa | 381 {7:││}bb | 382 {7:││}cc | 383 {7:││}dd | 384 {7:││}ee | 385 {7:│ }ff | 386 {1:~ }| 387 :1 | 388 ]]) 389 end 390 391 feed_command('set rightleft') 392 if multigrid then 393 screen:expect([[ 394 ## grid 1 395 [2:---------------------------------------------]|*7 396 [3:---------------------------------------------]| 397 ## grid 2 398 a^a{7:▾▾}| 399 bb{7:││}| 400 cc{7:││}| 401 dd{7:││}| 402 ee{7:││}| 403 ff{7: │}| 404 {1: ~}| 405 ## grid 3 406 :set rightleft | 407 ]]) 408 else 409 screen:expect([[ 410 a^a{7:▾▾}| 411 bb{7:││}| 412 cc{7:││}| 413 dd{7:││}| 414 ee{7:││}| 415 ff{7: │}| 416 {1: ~}| 417 :set rightleft | 418 ]]) 419 end 420 421 feed_command('set norightleft') 422 if multigrid then 423 api.nvim_input_mouse('left', 'press', '', 2, 0, 1) 424 screen:expect([[ 425 ## grid 1 426 [2:---------------------------------------------]|*7 427 [3:---------------------------------------------]| 428 ## grid 2 429 {7:▾▸}{13:^+--- 5 lines: aa··························}| 430 {7:│ }ff | 431 {1:~ }|*5 432 ## grid 3 433 :set norightleft | 434 ]]) 435 else 436 api.nvim_input_mouse('left', 'press', '', 0, 0, 1) 437 screen:expect([[ 438 {7:▾▸}{13:^+--- 5 lines: aa··························}| 439 {7:│ }ff | 440 {1:~ }|*5 441 :set norightleft | 442 ]]) 443 end 444 445 if multigrid then 446 api.nvim_input_mouse('left', 'press', '', 2, 0, 0) 447 screen:expect([[ 448 ## grid 1 449 [2:---------------------------------------------]|*7 450 [3:---------------------------------------------]| 451 ## grid 2 452 {7:▸ }{13:^+-- 6 lines: aa···························}| 453 {1:~ }|*6 454 ## grid 3 455 :set norightleft | 456 ]]) 457 else 458 api.nvim_input_mouse('left', 'press', '', 0, 0, 0) 459 screen:expect([[ 460 {7:▸ }{13:^+-- 6 lines: aa···························}| 461 {1:~ }|*6 462 :set norightleft | 463 ]]) 464 end 465 466 -- Add a winbar to avoid double-clicks 467 command('setlocal winbar=!!!!!!') 468 if multigrid then 469 api.nvim_input_mouse('left', 'press', '', 2, 1, 0) 470 screen:expect([[ 471 ## grid 1 472 [2:---------------------------------------------]|*7 473 [3:---------------------------------------------]| 474 ## grid 2 475 {5:!!!!!! }| 476 {7:▾▸}{13:^+--- 5 lines: aa··························}| 477 {7:│ }ff | 478 {1:~ }|*4 479 ## grid 3 480 :set norightleft | 481 ]]) 482 else 483 api.nvim_input_mouse('left', 'press', '', 0, 1, 0) 484 screen:expect([[ 485 {5:!!!!!! }| 486 {7:▾▸}{13:^+--- 5 lines: aa··························}| 487 {7:│ }ff | 488 {1:~ }|*4 489 :set norightleft | 490 ]]) 491 end 492 493 if multigrid then 494 api.nvim_input_mouse('left', 'press', '', 2, 1, 1) 495 screen:expect([[ 496 ## grid 1 497 [2:---------------------------------------------]|*7 498 [3:---------------------------------------------]| 499 ## grid 2 500 {5:!!!!!! }| 501 {7:▾▾}^aa | 502 {7:││}bb | 503 {7:││}cc | 504 {7:││}dd | 505 {7:││}ee | 506 {7:│ }ff | 507 ## grid 3 508 :set norightleft | 509 ]]) 510 else 511 api.nvim_input_mouse('left', 'press', '', 0, 1, 1) 512 screen:expect([[ 513 {5:!!!!!! }| 514 {7:▾▾}^aa | 515 {7:││}bb | 516 {7:││}cc | 517 {7:││}dd | 518 {7:││}ee | 519 {7:│ }ff | 520 :set norightleft | 521 ]]) 522 end 523 end) 524 525 it('with split', function() 526 insert([[ 527 aa 528 bb 529 cc 530 dd 531 ee 532 ff]]) 533 feed_command('2') 534 command('set foldcolumn=1') 535 feed('zf3j') 536 feed_command('1') 537 feed('zf2j') 538 feed('zO') 539 feed_command('rightbelow new') 540 insert([[ 541 aa 542 bb 543 cc 544 dd 545 ee 546 ff]]) 547 feed_command('2') 548 command('set foldcolumn=1') 549 feed('zf3j') 550 feed_command('1') 551 feed('zf2j') 552 if multigrid then 553 api.nvim_input_mouse('left', 'press', '', 4, 0, 0) 554 screen:expect([[ 555 ## grid 1 556 [2:---------------------------------------------]|*2 557 {2:[No Name] [+] }| 558 [4:---------------------------------------------]|*3 559 {3:[No Name] [+] }| 560 [3:---------------------------------------------]| 561 ## grid 2 562 {7:-}aa | 563 {7:-}bb | 564 ## grid 3 565 :1 | 566 ## grid 4 567 {7:-}^aa | 568 {7:+}{13:+--- 4 lines: bb···························}| 569 {7:│}ff | 570 ]]) 571 else 572 api.nvim_input_mouse('left', 'press', '', 0, 3, 0) 573 screen:expect([[ 574 {7:-}aa | 575 {7:-}bb | 576 {2:[No Name] [+] }| 577 {7:-}^aa | 578 {7:+}{13:+--- 4 lines: bb···························}| 579 {7:│}ff | 580 {3:[No Name] [+] }| 581 :1 | 582 ]]) 583 end 584 585 if multigrid then 586 api.nvim_input_mouse('left', 'press', '', 4, 1, 0) 587 screen:expect([[ 588 ## grid 1 589 [2:---------------------------------------------]|*2 590 {2:[No Name] [+] }| 591 [4:---------------------------------------------]|*3 592 {3:[No Name] [+] }| 593 [3:---------------------------------------------]| 594 ## grid 2 595 {7:-}aa | 596 {7:-}bb | 597 ## grid 3 598 :1 | 599 ## grid 4 600 {7:-}^aa | 601 {7:-}bb | 602 {7:2}cc | 603 ]]) 604 else 605 api.nvim_input_mouse('left', 'press', '', 0, 4, 0) 606 screen:expect([[ 607 {7:-}aa | 608 {7:-}bb | 609 {2:[No Name] [+] }| 610 {7:-}^aa | 611 {7:-}bb | 612 {7:2}cc | 613 {3:[No Name] [+] }| 614 :1 | 615 ]]) 616 end 617 618 if multigrid then 619 api.nvim_input_mouse('left', 'press', '', 2, 1, 0) 620 screen:expect([[ 621 ## grid 1 622 [2:---------------------------------------------]|*2 623 {3:[No Name] [+] }| 624 [4:---------------------------------------------]|*3 625 {2:[No Name] [+] }| 626 [3:---------------------------------------------]| 627 ## grid 2 628 {7:-}aa | 629 {7:+}{13:^+--- 4 lines: bb···························}| 630 ## grid 3 631 :1 | 632 ## grid 4 633 {7:-}aa | 634 {7:-}bb | 635 {7:2}cc | 636 ]]) 637 else 638 api.nvim_input_mouse('left', 'press', '', 0, 1, 0) 639 screen:expect([[ 640 {7:-}aa | 641 {7:+}{13:^+--- 4 lines: bb···························}| 642 {3:[No Name] [+] }| 643 {7:-}aa | 644 {7:-}bb | 645 {7:2}cc | 646 {2:[No Name] [+] }| 647 :1 | 648 ]]) 649 end 650 651 if multigrid then 652 api.nvim_input_mouse('left', 'press', '', 2, 0, 0) 653 screen:expect([[ 654 ## grid 1 655 [2:---------------------------------------------]|*2 656 {3:[No Name] [+] }| 657 [4:---------------------------------------------]|*3 658 {2:[No Name] [+] }| 659 [3:---------------------------------------------]| 660 ## grid 2 661 {7:+}{13:^+-- 6 lines: aa····························}| 662 {1:~ }| 663 ## grid 3 664 :1 | 665 ## grid 4 666 {7:-}aa | 667 {7:-}bb | 668 {7:2}cc | 669 ]]) 670 else 671 api.nvim_input_mouse('left', 'press', '', 0, 0, 0) 672 screen:expect([[ 673 {7:+}{13:^+-- 6 lines: aa····························}| 674 {1:~ }| 675 {3:[No Name] [+] }| 676 {7:-}aa | 677 {7:-}bb | 678 {7:2}cc | 679 {2:[No Name] [+] }| 680 :1 | 681 ]]) 682 end 683 end) 684 685 it('with vsplit', function() 686 insert([[ 687 aa 688 bb 689 cc 690 dd 691 ee 692 ff]]) 693 feed_command('2') 694 command('set foldcolumn=1') 695 feed('zf3j') 696 feed_command('1') 697 feed('zf2j') 698 feed('zO') 699 feed_command('rightbelow vnew') 700 insert([[ 701 aa 702 bb 703 cc 704 dd 705 ee 706 ff]]) 707 feed_command('2') 708 command('set foldcolumn=1') 709 feed('zf3j') 710 feed_command('1') 711 feed('zf2j') 712 if multigrid then 713 api.nvim_input_mouse('left', 'press', '', 4, 0, 0) 714 screen:expect([[ 715 ## grid 1 716 [2:----------------------]{2:│}[4:----------------------]|*6 717 {2:[No Name] [+] }{3:[No Name] [+] }| 718 [3:---------------------------------------------]| 719 ## grid 2 720 {7:-}aa | 721 {7:-}bb | 722 {7:2}cc | 723 {7:2}dd | 724 {7:2}ee | 725 {7:│}ff | 726 ## grid 3 727 :1 | 728 ## grid 4 729 {7:-}^aa | 730 {7:+}{13:+--- 4 lines: bb····}| 731 {7:│}ff | 732 {1:~ }|*3 733 ]]) 734 else 735 api.nvim_input_mouse('left', 'press', '', 0, 0, 23) 736 screen:expect([[ 737 {7:-}aa {2:│}{7:-}^aa | 738 {7:-}bb {2:│}{7:+}{13:+--- 4 lines: bb····}| 739 {7:2}cc {2:│}{7:│}ff | 740 {7:2}dd {2:│}{1:~ }| 741 {7:2}ee {2:│}{1:~ }| 742 {7:│}ff {2:│}{1:~ }| 743 {2:[No Name] [+] }{3:[No Name] [+] }| 744 :1 | 745 ]]) 746 end 747 748 if multigrid then 749 api.nvim_input_mouse('left', 'press', '', 4, 1, 0) 750 screen:expect([[ 751 ## grid 1 752 [2:----------------------]{2:│}[4:----------------------]|*6 753 {2:[No Name] [+] }{3:[No Name] [+] }| 754 [3:---------------------------------------------]| 755 ## grid 2 756 {7:-}aa | 757 {7:-}bb | 758 {7:2}cc | 759 {7:2}dd | 760 {7:2}ee | 761 {7:│}ff | 762 ## grid 3 763 :1 | 764 ## grid 4 765 {7:-}^aa | 766 {7:-}bb | 767 {7:2}cc | 768 {7:2}dd | 769 {7:2}ee | 770 {7:│}ff | 771 ]]) 772 else 773 api.nvim_input_mouse('left', 'press', '', 0, 1, 23) 774 screen:expect([[ 775 {7:-}aa {2:│}{7:-}^aa | 776 {7:-}bb {2:│}{7:-}bb | 777 {7:2}cc {2:│}{7:2}cc | 778 {7:2}dd {2:│}{7:2}dd | 779 {7:2}ee {2:│}{7:2}ee | 780 {7:│}ff {2:│}{7:│}ff | 781 {2:[No Name] [+] }{3:[No Name] [+] }| 782 :1 | 783 ]]) 784 end 785 786 if multigrid then 787 api.nvim_input_mouse('left', 'press', '', 2, 1, 0) 788 screen:expect([[ 789 ## grid 1 790 [2:----------------------]{2:│}[4:----------------------]|*6 791 {3:[No Name] [+] }{2:[No Name] [+] }| 792 [3:---------------------------------------------]| 793 ## grid 2 794 {7:-}aa | 795 {7:+}{13:^+--- 4 lines: bb····}| 796 {7:│}ff | 797 {1:~ }|*3 798 ## grid 3 799 :1 | 800 ## grid 4 801 {7:-}aa | 802 {7:-}bb | 803 {7:2}cc | 804 {7:2}dd | 805 {7:2}ee | 806 {7:│}ff | 807 ]]) 808 else 809 api.nvim_input_mouse('left', 'press', '', 0, 1, 0) 810 screen:expect([[ 811 {7:-}aa {2:│}{7:-}aa | 812 {7:+}{13:^+--- 4 lines: bb····}{2:│}{7:-}bb | 813 {7:│}ff {2:│}{7:2}cc | 814 {1:~ }{2:│}{7:2}dd | 815 {1:~ }{2:│}{7:2}ee | 816 {1:~ }{2:│}{7:│}ff | 817 {3:[No Name] [+] }{2:[No Name] [+] }| 818 :1 | 819 ]]) 820 end 821 822 if multigrid then 823 api.nvim_input_mouse('left', 'press', '', 2, 0, 0) 824 screen:expect([[ 825 ## grid 1 826 [2:----------------------]{2:│}[4:----------------------]|*6 827 {3:[No Name] [+] }{2:[No Name] [+] }| 828 [3:---------------------------------------------]| 829 ## grid 2 830 {7:+}{13:^+-- 6 lines: aa·····}| 831 {1:~ }|*5 832 ## grid 3 833 :1 | 834 ## grid 4 835 {7:-}aa | 836 {7:-}bb | 837 {7:2}cc | 838 {7:2}dd | 839 {7:2}ee | 840 {7:│}ff | 841 ]]) 842 else 843 api.nvim_input_mouse('left', 'press', '', 0, 0, 0) 844 screen:expect([[ 845 {7:+}{13:^+-- 6 lines: aa·····}{2:│}{7:-}aa | 846 {1:~ }{2:│}{7:-}bb | 847 {1:~ }{2:│}{7:2}cc | 848 {1:~ }{2:│}{7:2}dd | 849 {1:~ }{2:│}{7:2}ee | 850 {1:~ }{2:│}{7:│}ff | 851 {3:[No Name] [+] }{2:[No Name] [+] }| 852 :1 | 853 ]]) 854 end 855 end) 856 857 it('with tabpages', function() 858 insert([[ 859 aa 860 bb 861 cc 862 dd 863 ee 864 ff]]) 865 feed_command('2') 866 command('set foldcolumn=2') 867 feed('zf3j') 868 feed_command('1') 869 feed('zf2j') 870 feed('zO') 871 feed_command('tab split') 872 if multigrid then 873 api.nvim_input_mouse('left', 'press', '', 4, 1, 1) 874 screen:expect([[ 875 ## grid 1 876 {24: + [No Name] }{5: + [No Name] }{2: }{24:X}| 877 [4:---------------------------------------------]|*6 878 [3:---------------------------------------------]| 879 ## grid 2 (hidden) 880 {7:- }aa | 881 {7:│-}bb | 882 {7:││}cc | 883 {7:││}dd | 884 {7:││}ee | 885 {7:│ }ff | 886 {1:~ }| 887 ## grid 3 888 :tab split | 889 ## grid 4 890 {7:- }^aa | 891 {7:│+}{13:+--- 4 lines: bb··························}| 892 {7:│ }ff | 893 {1:~ }|*3 894 ]]) 895 else 896 api.nvim_input_mouse('left', 'press', '', 0, 2, 1) 897 screen:expect([[ 898 {24: + [No Name] }{5: + [No Name] }{2: }{24:X}| 899 {7:- }^aa | 900 {7:│+}{13:+--- 4 lines: bb··························}| 901 {7:│ }ff | 902 {1:~ }|*3 903 :tab split | 904 ]]) 905 end 906 907 if multigrid then 908 api.nvim_input_mouse('left', 'press', '', 4, 0, 0) 909 screen:expect([[ 910 ## grid 1 911 {24: + [No Name] }{5: + [No Name] }{2: }{24:X}| 912 [4:---------------------------------------------]|*6 913 [3:---------------------------------------------]| 914 ## grid 2 (hidden) 915 {7:- }aa | 916 {7:│-}bb | 917 {7:││}cc | 918 {7:││}dd | 919 {7:││}ee | 920 {7:│ }ff | 921 {1:~ }| 922 ## grid 3 923 :tab split | 924 ## grid 4 925 {7:+ }{13:^+-- 6 lines: aa···························}| 926 {1:~ }|*5 927 ]]) 928 else 929 api.nvim_input_mouse('left', 'press', '', 0, 1, 0) 930 screen:expect([[ 931 {24: + [No Name] }{5: + [No Name] }{2: }{24:X}| 932 {7:+ }{13:^+-- 6 lines: aa···························}| 933 {1:~ }|*5 934 :tab split | 935 ]]) 936 end 937 938 feed_command('tabnext') 939 if multigrid then 940 api.nvim_input_mouse('left', 'press', '', 2, 1, 1) 941 screen:expect([[ 942 ## grid 1 943 {5: + [No Name] }{24: + [No Name] }{2: }{24:X}| 944 [2:---------------------------------------------]|*6 945 [3:---------------------------------------------]| 946 ## grid 2 947 {7:- }^aa | 948 {7:│+}{13:+--- 4 lines: bb··························}| 949 {7:│ }ff | 950 {1:~ }|*3 951 ## grid 3 952 :tabnext | 953 ## grid 4 (hidden) 954 {7:+ }{13:+-- 6 lines: aa···························}| 955 {1:~ }|*5 956 ]]) 957 else 958 api.nvim_input_mouse('left', 'press', '', 0, 2, 1) 959 screen:expect([[ 960 {5: + [No Name] }{24: + [No Name] }{2: }{24:X}| 961 {7:- }^aa | 962 {7:│+}{13:+--- 4 lines: bb··························}| 963 {7:│ }ff | 964 {1:~ }|*3 965 :tabnext | 966 ]]) 967 end 968 969 if multigrid then 970 api.nvim_input_mouse('left', 'press', '', 2, 0, 0) 971 screen:expect([[ 972 ## grid 1 973 {5: + [No Name] }{24: + [No Name] }{2: }{24:X}| 974 [2:---------------------------------------------]|*6 975 [3:---------------------------------------------]| 976 ## grid 2 977 {7:+ }{13:^+-- 6 lines: aa···························}| 978 {1:~ }|*5 979 ## grid 3 980 :tabnext | 981 ## grid 4 (hidden) 982 {7:+ }{13:+-- 6 lines: aa···························}| 983 {1:~ }|*5 984 ]]) 985 else 986 api.nvim_input_mouse('left', 'press', '', 0, 1, 0) 987 screen:expect([[ 988 {5: + [No Name] }{24: + [No Name] }{2: }{24:X}| 989 {7:+ }{13:^+-- 6 lines: aa···························}| 990 {1:~ }|*5 991 :tabnext | 992 ]]) 993 end 994 end) 995 996 it('with multibyte text', function() 997 eq(true, api.nvim_get_option_value('arabicshape', {})) 998 insert([[ 999 å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة 1000 möre text]]) 1001 if multigrid then 1002 screen:expect([[ 1003 ## grid 1 1004 [2:---------------------------------------------]|*7 1005 [3:---------------------------------------------]| 1006 ## grid 2 1007 å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ | 1008 möre tex^t | 1009 {1:~ }|*5 1010 ## grid 3 1011 | 1012 ]]) 1013 else 1014 screen:expect([[ 1015 å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ | 1016 möre tex^t | 1017 {1:~ }|*5 1018 | 1019 ]]) 1020 end 1021 1022 feed('vkzf') 1023 if multigrid then 1024 screen:expect([[ 1025 ## grid 1 1026 [2:---------------------------------------------]|*7 1027 [3:---------------------------------------------]| 1028 ## grid 2 1029 {13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| 1030 {1:~ }|*6 1031 ## grid 3 1032 | 1033 ]]) 1034 else 1035 screen:expect([[ 1036 {13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| 1037 {1:~ }|*6 1038 | 1039 ]]) 1040 end 1041 1042 feed_command('set noarabicshape') 1043 if multigrid then 1044 screen:expect([[ 1045 ## grid 1 1046 [2:---------------------------------------------]|*7 1047 [3:---------------------------------------------]| 1048 ## grid 2 1049 {13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة·················}| 1050 {1:~ }|*6 1051 ## grid 3 1052 :set noarabicshape | 1053 ]]) 1054 else 1055 screen:expect([[ 1056 {13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة·················}| 1057 {1:~ }|*6 1058 :set noarabicshape | 1059 ]]) 1060 end 1061 1062 feed_command('set number foldcolumn=2') 1063 if multigrid then 1064 screen:expect([[ 1065 ## grid 1 1066 [2:---------------------------------------------]|*7 1067 [3:---------------------------------------------]| 1068 ## grid 2 1069 {7:+ }{8: 1 }{13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة···········}| 1070 {1:~ }|*6 1071 ## grid 3 1072 :set number foldcolumn=2 | 1073 ]]) 1074 else 1075 screen:expect([[ 1076 {7:+ }{8: 1 }{13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة···········}| 1077 {1:~ }|*6 1078 :set number foldcolumn=2 | 1079 ]]) 1080 end 1081 1082 feed_command('set rightleft') 1083 if multigrid then 1084 screen:expect([[ 1085 ## grid 1 1086 [2:---------------------------------------------]|*7 1087 [3:---------------------------------------------]| 1088 ## grid 2 1089 {13:···········ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}{8: 1 }{7: +}| 1090 {1: ~}|*6 1091 ## grid 3 1092 :set rightleft | 1093 ]]) 1094 else 1095 screen:expect([[ 1096 {13:···········ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}{8: 1 }{7: +}| 1097 {1: ~}|*6 1098 :set rightleft | 1099 ]]) 1100 end 1101 1102 feed_command('set nonumber foldcolumn=0') 1103 if multigrid then 1104 screen:expect([[ 1105 ## grid 1 1106 [2:---------------------------------------------]|*7 1107 [3:---------------------------------------------]| 1108 ## grid 2 1109 {13:·················ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| 1110 {1: ~}|*6 1111 ## grid 3 1112 :set nonumber foldcolumn=0 | 1113 ]]) 1114 else 1115 screen:expect([[ 1116 {13:·················ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| 1117 {1: ~}|*6 1118 :set nonumber foldcolumn=0 | 1119 ]]) 1120 end 1121 1122 feed_command('set arabicshape') 1123 if multigrid then 1124 screen:expect([[ 1125 ## grid 1 1126 [2:---------------------------------------------]|*7 1127 [3:---------------------------------------------]| 1128 ## grid 2 1129 {13:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| 1130 {1: ~}|*6 1131 ## grid 3 1132 :set arabicshape | 1133 ]]) 1134 else 1135 screen:expect([[ 1136 {13:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| 1137 {1: ~}|*6 1138 :set arabicshape | 1139 ]]) 1140 end 1141 1142 feed('zo') 1143 if multigrid then 1144 screen:expect([[ 1145 ## grid 1 1146 [2:---------------------------------------------]|*7 1147 [3:---------------------------------------------]| 1148 ## grid 2 1149 ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| 1150 txet eröm| 1151 {1: ~}|*5 1152 ## grid 3 1153 :set arabicshape | 1154 ]]) 1155 else 1156 screen:expect([[ 1157 ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| 1158 txet eröm| 1159 {1: ~}|*5 1160 :set arabicshape | 1161 ]]) 1162 end 1163 1164 feed_command('set noarabicshape') 1165 if multigrid then 1166 screen:expect([[ 1167 ## grid 1 1168 [2:---------------------------------------------]|*7 1169 [3:---------------------------------------------]| 1170 ## grid 2 1171 ةيَّبِرَعَ^لا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| 1172 txet eröm| 1173 {1: ~}|*5 1174 ## grid 3 1175 :set noarabicshape | 1176 ]]) 1177 else 1178 screen:expect([[ 1179 ةيَّبِرَعَ^لا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| 1180 txet eröm| 1181 {1: ~}|*5 1182 :set noarabicshape | 1183 ]]) 1184 end 1185 end) 1186 1187 it('in cmdline window', function() 1188 feed_command('set foldmethod=manual foldcolumn=1') 1189 feed_command('let x = 1') 1190 feed_command('/alpha') 1191 feed_command('/omega') 1192 1193 feed('<cr>q:') 1194 if multigrid then 1195 screen:expect([[ 1196 ## grid 1 1197 [2:---------------------------------------------]| 1198 {2:[No Name] }| 1199 [4:---------------------------------------------]|*4 1200 {3:[Command Line] }| 1201 [3:---------------------------------------------]| 1202 ## grid 2 1203 {7: } | 1204 ## grid 3 1205 : | 1206 ## grid 4 1207 {1::}{7: }set foldmethod=manual foldcolumn=1 | 1208 {1::}{7: }let x = 1 | 1209 {1::}{7: }^ | 1210 {1:~ }| 1211 ]]) 1212 else 1213 screen:expect([[ 1214 {7: } | 1215 {2:[No Name] }| 1216 {1::}{7: }set foldmethod=manual foldcolumn=1 | 1217 {1::}{7: }let x = 1 | 1218 {1::}{7: }^ | 1219 {1:~ }| 1220 {3:[Command Line] }| 1221 : | 1222 ]]) 1223 end 1224 1225 feed('kzfk') 1226 if multigrid then 1227 screen:expect([[ 1228 ## grid 1 1229 [2:---------------------------------------------]| 1230 {2:[No Name] }| 1231 [4:---------------------------------------------]|*4 1232 {3:[Command Line] }| 1233 [3:---------------------------------------------]| 1234 ## grid 2 1235 {7: } | 1236 ## grid 3 1237 : | 1238 ## grid 4 1239 {1::}{7:+}{13:^+-- 2 lines: set foldmethod=manual foldcol}| 1240 {1::}{7: } | 1241 {1:~ }|*2 1242 ]]) 1243 else 1244 screen:expect([[ 1245 {7: } | 1246 {2:[No Name] }| 1247 {1::}{7:+}{13:^+-- 2 lines: set foldmethod=manual foldcol}| 1248 {1::}{7: } | 1249 {1:~ }|*2 1250 {3:[Command Line] }| 1251 : | 1252 ]]) 1253 end 1254 1255 feed('<cr>') 1256 if multigrid then 1257 screen:expect([[ 1258 ## grid 1 1259 [2:---------------------------------------------]|*7 1260 [3:---------------------------------------------]| 1261 ## grid 2 1262 {7: }^ | 1263 {1:~ }|*6 1264 ## grid 3 1265 : | 1266 ]]) 1267 else 1268 screen:expect([[ 1269 {7: }^ | 1270 {1:~ }|*6 1271 : | 1272 ]]) 1273 end 1274 1275 feed('/<c-f>') 1276 if multigrid then 1277 screen:expect([[ 1278 ## grid 1 1279 [2:---------------------------------------------]| 1280 {2:[No Name] }| 1281 [5:---------------------------------------------]|*4 1282 {3:[Command Line] }| 1283 [3:---------------------------------------------]| 1284 ## grid 2 1285 {7: } | 1286 ## grid 3 1287 / | 1288 ## grid 5 1289 {1:/}{7: }alpha | 1290 {1:/}{7: }{10:omega} | 1291 {1:/}{7: }^ | 1292 {1:~ }| 1293 ]]) 1294 else 1295 screen:expect([[ 1296 {7: } | 1297 {2:[No Name] }| 1298 {1:/}{7: }alpha | 1299 {1:/}{7: }{10:omega} | 1300 {1:/}{7: }^ | 1301 {1:~ }| 1302 {3:[Command Line] }| 1303 / | 1304 ]]) 1305 end 1306 1307 feed('ggzfG') 1308 if multigrid then 1309 screen:expect([[ 1310 ## grid 1 1311 [2:---------------------------------------------]| 1312 {2:[No Name] }| 1313 [5:---------------------------------------------]|*4 1314 {3:[Command Line] }| 1315 [3:---------------------------------------------]| 1316 ## grid 2 1317 {7: } | 1318 ## grid 3 1319 / | 1320 ## grid 5 1321 {1:/}{7:+}{13:^+-- 3 lines: alpha························}| 1322 {1:~ }|*3 1323 ]]) 1324 else 1325 screen:expect([[ 1326 {7: } | 1327 {2:[No Name] }| 1328 {1:/}{7:+}{13:^+-- 3 lines: alpha························}| 1329 {1:~ }|*3 1330 {3:[Command Line] }| 1331 / | 1332 ]]) 1333 end 1334 end) 1335 1336 it('foldcolumn autoresize', function() 1337 fn.setline(1, 'line 1') 1338 fn.setline(2, 'line 2') 1339 fn.setline(3, 'line 3') 1340 fn.setline(4, 'line 4') 1341 1342 feed('zfj') 1343 command('set foldcolumn=0') 1344 if multigrid then 1345 screen:expect([[ 1346 ## grid 1 1347 [2:---------------------------------------------]|*7 1348 [3:---------------------------------------------]| 1349 ## grid 2 1350 {13:^+-- 2 lines: line 1·························}| 1351 line 3 | 1352 line 4 | 1353 {1:~ }|*4 1354 ## grid 3 1355 | 1356 ]]) 1357 else 1358 screen:expect([[ 1359 {13:^+-- 2 lines: line 1·························}| 1360 line 3 | 1361 line 4 | 1362 {1:~ }|*4 1363 | 1364 ]]) 1365 end 1366 -- should adapt to the current nesting of folds (e.g., 1) 1367 command('set foldcolumn=auto:1') 1368 if multigrid then 1369 screen:expect([[ 1370 ## grid 1 1371 [2:---------------------------------------------]|*7 1372 [3:---------------------------------------------]| 1373 ## grid 2 1374 {7:+}{13:^+-- 2 lines: line 1························}| 1375 {7: }line 3 | 1376 {7: }line 4 | 1377 {1:~ }|*4 1378 ## grid 3 1379 | 1380 ]]) 1381 else 1382 screen:expect([[ 1383 {7:+}{13:^+-- 2 lines: line 1························}| 1384 {7: }line 3 | 1385 {7: }line 4 | 1386 {1:~ }|*4 1387 | 1388 ]]) 1389 end 1390 command('set foldcolumn=auto') 1391 if multigrid then 1392 screen:expect { 1393 grid = [[ 1394 ## grid 1 1395 [2:---------------------------------------------]|*7 1396 [3:---------------------------------------------]| 1397 ## grid 2 1398 {7:+}{13:^+-- 2 lines: line 1························}| 1399 {7: }line 3 | 1400 {7: }line 4 | 1401 {1:~ }|*4 1402 ## grid 3 1403 | 1404 ]], 1405 unchanged = true, 1406 } 1407 else 1408 screen:expect { 1409 grid = [[ 1410 {7:+}{13:^+-- 2 lines: line 1························}| 1411 {7: }line 3 | 1412 {7: }line 4 | 1413 {1:~ }|*4 1414 | 1415 ]], 1416 unchanged = true, 1417 } 1418 end 1419 -- fdc should not change with a new fold as the maximum is 1 1420 feed('zf3j') 1421 1422 if multigrid then 1423 screen:expect([[ 1424 ## grid 1 1425 [2:---------------------------------------------]|*7 1426 [3:---------------------------------------------]| 1427 ## grid 2 1428 {7:+}{13:^+-- 4 lines: line 1························}| 1429 {1:~ }|*6 1430 ## grid 3 1431 | 1432 ]]) 1433 else 1434 screen:expect([[ 1435 {7:+}{13:^+-- 4 lines: line 1························}| 1436 {1:~ }|*6 1437 | 1438 ]]) 1439 end 1440 1441 command('set foldcolumn=auto:1') 1442 if multigrid then 1443 screen:expect_unchanged() 1444 end 1445 1446 -- relax the maximum fdc thus fdc should expand to 1447 -- accommodate the current number of folds 1448 command('set foldcolumn=auto:4') 1449 if multigrid then 1450 screen:expect([[ 1451 ## grid 1 1452 [2:---------------------------------------------]|*7 1453 [3:---------------------------------------------]| 1454 ## grid 2 1455 {7:+ }{13:^+-- 4 lines: line 1·······················}| 1456 {1:~ }|*6 1457 ## grid 3 1458 | 1459 ]]) 1460 else 1461 screen:expect([[ 1462 {7:+ }{13:^+-- 4 lines: line 1·······················}| 1463 {1:~ }|*6 1464 | 1465 ]]) 1466 end 1467 end) 1468 1469 it('no crash when foldtext is longer than columns #12988', function() 1470 exec([[ 1471 function! MyFoldText() abort 1472 return repeat('-', &columns + 100) 1473 endfunction 1474 ]]) 1475 command('set foldtext=MyFoldText()') 1476 feed('i<cr><esc>') 1477 feed('vkzf') 1478 if multigrid then 1479 screen:expect([[ 1480 ## grid 1 1481 [2:---------------------------------------------]|*7 1482 [3:---------------------------------------------]| 1483 ## grid 2 1484 {13:^---------------------------------------------}| 1485 {1:~ }|*6 1486 ## grid 3 1487 | 1488 ]]) 1489 else 1490 screen:expect([[ 1491 {13:^---------------------------------------------}| 1492 {1:~ }|*6 1493 | 1494 ]]) 1495 end 1496 assert_alive() 1497 end) 1498 1499 it('fold text is shown when text has been scrolled to the right #19123', function() 1500 insert(content1) 1501 command('set number nowrap') 1502 command('3,4fold') 1503 feed('gg') 1504 if multigrid then 1505 screen:expect([[ 1506 ## grid 1 1507 [2:---------------------------------------------]|*7 1508 [3:---------------------------------------------]| 1509 ## grid 2 1510 {8: 1 }^This is a | 1511 {8: 2 }valid English | 1512 {8: 3 }{13:+-- 2 lines: sentence composed by·······}| 1513 {8: 5 }in his cave. | 1514 {8: 6 } | 1515 {1:~ }|*2 1516 ## grid 3 1517 | 1518 ]]) 1519 else 1520 screen:expect([[ 1521 {8: 1 }^This is a | 1522 {8: 2 }valid English | 1523 {8: 3 }{13:+-- 2 lines: sentence composed by·······}| 1524 {8: 5 }in his cave. | 1525 {8: 6 } | 1526 {1:~ }|*2 1527 | 1528 ]]) 1529 end 1530 1531 feed('zl') 1532 if multigrid then 1533 screen:expect([[ 1534 ## grid 1 1535 [2:---------------------------------------------]|*7 1536 [3:---------------------------------------------]| 1537 ## grid 2 1538 {8: 1 }^his is a | 1539 {8: 2 }alid English | 1540 {8: 3 }{13:+-- 2 lines: sentence composed by·······}| 1541 {8: 5 }n his cave. | 1542 {8: 6 } | 1543 {1:~ }|*2 1544 ## grid 3 1545 | 1546 ]]) 1547 else 1548 screen:expect([[ 1549 {8: 1 }^his is a | 1550 {8: 2 }alid English | 1551 {8: 3 }{13:+-- 2 lines: sentence composed by·······}| 1552 {8: 5 }n his cave. | 1553 {8: 6 } | 1554 {1:~ }|*2 1555 | 1556 ]]) 1557 end 1558 1559 eq({ 0, 1, 2, 0, 2 }, fn.getcurpos()) 1560 api.nvim_input_mouse('left', 'press', '', multigrid and 2 or 0, 2, 4) 1561 eq({ 0, 3, 2, 0, 2 }, fn.getcurpos()) 1562 feed('2k') 1563 eq({ 0, 1, 2, 0, 2 }, fn.getcurpos()) 1564 1565 api.nvim_set_option_value('foldtext', "'αβγ'", { win = 0 }) 1566 -- No crash or memory leak when scrolling beyond end of folded line #33931 1567 fn.append('$', ('!'):rep(100)) 1568 feed('G$') 1569 if multigrid then 1570 screen:expect([[ 1571 ## grid 1 1572 [2:---------------------------------------------]|*7 1573 [3:---------------------------------------------]| 1574 ## grid 2 1575 {8: 1 } | 1576 {8: 2 } | 1577 {8: 3 }{13:αβγ······································}| 1578 {8: 5 } | 1579 {8: 6 } | 1580 {8: 7 }!!!!!!!!!!!!!!!!!!!!^! | 1581 {1:~ }| 1582 ## grid 3 1583 | 1584 ]]) 1585 else 1586 screen:expect([[ 1587 {8: 1 } | 1588 {8: 2 } | 1589 {8: 3 }{13:αβγ······································}| 1590 {8: 5 } | 1591 {8: 6 } | 1592 {8: 7 }!!!!!!!!!!!!!!!!!!!!^! | 1593 {1:~ }| 1594 | 1595 ]]) 1596 end 1597 end) 1598 1599 it('fold attached virtual lines are drawn and scrolled correctly #21837', function() 1600 fn.setline(1, 'line 1') 1601 fn.setline(2, 'line 2') 1602 fn.setline(3, 'line 3') 1603 fn.setline(4, 'line 4') 1604 feed('zfj') 1605 local ns = api.nvim_create_namespace('ns') 1606 api.nvim_buf_set_extmark( 1607 0, 1608 ns, 1609 0, 1610 0, 1611 { virt_lines_above = true, virt_lines = { { { 'virt_line above line 1', '' } } } } 1612 ) 1613 api.nvim_buf_set_extmark( 1614 0, 1615 ns, 1616 1, 1617 0, 1618 { virt_lines = { { { 'virt_line below line 2', '' } } } } 1619 ) 1620 api.nvim_buf_set_extmark( 1621 0, 1622 ns, 1623 2, 1624 0, 1625 { virt_lines_above = true, virt_lines = { { { 'virt_line above line 3', '' } } } } 1626 ) 1627 api.nvim_buf_set_extmark( 1628 0, 1629 ns, 1630 3, 1631 0, 1632 { virt_lines = { { { 'virt_line below line 4', '' } } } } 1633 ) 1634 if multigrid then 1635 screen:expect { 1636 grid = [[ 1637 ## grid 1 1638 [2:---------------------------------------------]|*7 1639 [3:---------------------------------------------]| 1640 ## grid 2 1641 {13:^+-- 2 lines: line 1·························}| 1642 virt_line above line 3 | 1643 line 3 | 1644 line 4 | 1645 virt_line below line 4 | 1646 {1:~ }|*2 1647 ## grid 3 1648 | 1649 ]], 1650 win_viewport = { 1651 [2] = { 1652 win = 1000, 1653 topline = 0, 1654 botline = 5, 1655 curline = 0, 1656 curcol = 0, 1657 linecount = 4, 1658 sum_scroll_delta = 0, 1659 }, 1660 }, 1661 } 1662 else 1663 screen:expect([[ 1664 {13:^+-- 2 lines: line 1·························}| 1665 virt_line above line 3 | 1666 line 3 | 1667 line 4 | 1668 virt_line below line 4 | 1669 {1:~ }|*2 1670 | 1671 ]]) 1672 end 1673 1674 feed('jzfj') 1675 if multigrid then 1676 screen:expect { 1677 grid = [[ 1678 ## grid 1 1679 [2:---------------------------------------------]|*7 1680 [3:---------------------------------------------]| 1681 ## grid 2 1682 {13:+-- 2 lines: line 1·························}| 1683 {13:^+-- 2 lines: line 3·························}| 1684 {1:~ }|*5 1685 ## grid 3 1686 | 1687 ]], 1688 win_viewport = { 1689 [2] = { 1690 win = 1000, 1691 topline = 0, 1692 botline = 5, 1693 curline = 2, 1694 curcol = 0, 1695 linecount = 4, 1696 sum_scroll_delta = 0, 1697 }, 1698 }, 1699 } 1700 else 1701 screen:expect([[ 1702 {13:+-- 2 lines: line 1·························}| 1703 {13:^+-- 2 lines: line 3·························}| 1704 {1:~ }|*5 1705 | 1706 ]]) 1707 end 1708 1709 feed('kzo<C-Y>') 1710 fn.setline(5, 'line 5') 1711 if multigrid then 1712 screen:expect { 1713 grid = [[ 1714 ## grid 1 1715 [2:---------------------------------------------]|*7 1716 [3:---------------------------------------------]| 1717 ## grid 2 1718 virt_line above line 1 | 1719 ^line 1 | 1720 line 2 | 1721 virt_line below line 2 | 1722 {13:+-- 2 lines: line 3·························}| 1723 line 5 | 1724 {1:~ }| 1725 ## grid 3 1726 | 1727 ]], 1728 win_viewport = { 1729 [2] = { 1730 win = 1000, 1731 topline = 0, 1732 botline = 6, 1733 curline = 0, 1734 curcol = 0, 1735 linecount = 5, 1736 sum_scroll_delta = -1, 1737 }, 1738 }, 1739 } 1740 else 1741 screen:expect([[ 1742 virt_line above line 1 | 1743 ^line 1 | 1744 line 2 | 1745 virt_line below line 2 | 1746 {13:+-- 2 lines: line 3·························}| 1747 line 5 | 1748 {1:~ }| 1749 | 1750 ]]) 1751 end 1752 1753 api.nvim_input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0) 1754 eq({ 1755 screencol = 1, 1756 screenrow = 5, 1757 winid = 1000, 1758 wincol = 1, 1759 winrow = 5, 1760 line = 3, 1761 column = 1, 1762 coladd = 0, 1763 }, fn.getmousepos()) 1764 1765 api.nvim_buf_set_extmark( 1766 0, 1767 ns, 1768 1, 1769 0, 1770 { virt_lines = { { { 'more virt_line below line 2', '' } } } } 1771 ) 1772 feed('G<C-E>') 1773 if multigrid then 1774 screen:expect { 1775 grid = [[ 1776 ## grid 1 1777 [2:---------------------------------------------]|*7 1778 [3:---------------------------------------------]| 1779 ## grid 2 1780 line 1 | 1781 line 2 | 1782 virt_line below line 2 | 1783 more virt_line below line 2 | 1784 {13:+-- 2 lines: line 3·························}| 1785 ^line 5 | 1786 {1:~ }| 1787 ## grid 3 1788 | 1789 ]], 1790 win_viewport = { 1791 [2] = { 1792 win = 1000, 1793 topline = 0, 1794 botline = 6, 1795 curline = 4, 1796 curcol = 0, 1797 linecount = 5, 1798 sum_scroll_delta = 0, 1799 }, 1800 }, 1801 } 1802 else 1803 screen:expect([[ 1804 line 1 | 1805 line 2 | 1806 virt_line below line 2 | 1807 more virt_line below line 2 | 1808 {13:+-- 2 lines: line 3·························}| 1809 ^line 5 | 1810 {1:~ }| 1811 | 1812 ]]) 1813 end 1814 1815 feed('<C-E>') 1816 if multigrid then 1817 screen:expect { 1818 grid = [[ 1819 ## grid 1 1820 [2:---------------------------------------------]|*7 1821 [3:---------------------------------------------]| 1822 ## grid 2 1823 line 2 | 1824 virt_line below line 2 | 1825 more virt_line below line 2 | 1826 {13:+-- 2 lines: line 3·························}| 1827 ^line 5 | 1828 {1:~ }|*2 1829 ## grid 3 1830 | 1831 ]], 1832 win_viewport = { 1833 [2] = { 1834 win = 1000, 1835 topline = 1, 1836 botline = 6, 1837 curline = 4, 1838 curcol = 0, 1839 linecount = 5, 1840 sum_scroll_delta = 1, 1841 }, 1842 }, 1843 } 1844 else 1845 screen:expect([[ 1846 line 2 | 1847 virt_line below line 2 | 1848 more virt_line below line 2 | 1849 {13:+-- 2 lines: line 3·························}| 1850 ^line 5 | 1851 {1:~ }|*2 1852 | 1853 ]]) 1854 end 1855 1856 feed('<C-E>') 1857 if multigrid then 1858 screen:expect { 1859 grid = [[ 1860 ## grid 1 1861 [2:---------------------------------------------]|*7 1862 [3:---------------------------------------------]| 1863 ## grid 2 1864 virt_line below line 2 | 1865 more virt_line below line 2 | 1866 {13:+-- 2 lines: line 3·························}| 1867 ^line 5 | 1868 {1:~ }|*3 1869 ## grid 3 1870 | 1871 ]], 1872 win_viewport = { 1873 [2] = { 1874 win = 1000, 1875 topline = 2, 1876 botline = 6, 1877 curline = 4, 1878 curcol = 0, 1879 linecount = 5, 1880 sum_scroll_delta = 2, 1881 }, 1882 }, 1883 } 1884 else 1885 screen:expect([[ 1886 virt_line below line 2 | 1887 more virt_line below line 2 | 1888 {13:+-- 2 lines: line 3·························}| 1889 ^line 5 | 1890 {1:~ }|*3 1891 | 1892 ]]) 1893 end 1894 1895 feed('<C-E>') 1896 if multigrid then 1897 screen:expect { 1898 grid = [[ 1899 ## grid 1 1900 [2:---------------------------------------------]|*7 1901 [3:---------------------------------------------]| 1902 ## grid 2 1903 more virt_line below line 2 | 1904 {13:+-- 2 lines: line 3·························}| 1905 ^line 5 | 1906 {1:~ }|*4 1907 ## grid 3 1908 | 1909 ]], 1910 win_viewport = { 1911 [2] = { 1912 win = 1000, 1913 topline = 2, 1914 botline = 6, 1915 curline = 4, 1916 curcol = 0, 1917 linecount = 5, 1918 sum_scroll_delta = 3, 1919 }, 1920 }, 1921 } 1922 else 1923 screen:expect([[ 1924 more virt_line below line 2 | 1925 {13:+-- 2 lines: line 3·························}| 1926 ^line 5 | 1927 {1:~ }|*4 1928 | 1929 ]]) 1930 end 1931 1932 feed('<C-E>') 1933 if multigrid then 1934 screen:expect { 1935 grid = [[ 1936 ## grid 1 1937 [2:---------------------------------------------]|*7 1938 [3:---------------------------------------------]| 1939 ## grid 2 1940 {13:+-- 2 lines: line 3·························}| 1941 ^line 5 | 1942 {1:~ }|*5 1943 ## grid 3 1944 | 1945 ]], 1946 win_viewport = { 1947 [2] = { 1948 win = 1000, 1949 topline = 2, 1950 botline = 6, 1951 curline = 4, 1952 curcol = 0, 1953 linecount = 5, 1954 sum_scroll_delta = 4, 1955 }, 1956 }, 1957 } 1958 else 1959 screen:expect([[ 1960 {13:+-- 2 lines: line 3·························}| 1961 ^line 5 | 1962 {1:~ }|*5 1963 | 1964 ]]) 1965 end 1966 1967 feed('<C-E>') 1968 if multigrid then 1969 screen:expect { 1970 grid = [[ 1971 ## grid 1 1972 [2:---------------------------------------------]|*7 1973 [3:---------------------------------------------]| 1974 ## grid 2 1975 ^line 5 | 1976 {1:~ }|*6 1977 ## grid 3 1978 | 1979 ]], 1980 win_viewport = { 1981 [2] = { 1982 win = 1000, 1983 topline = 4, 1984 botline = 6, 1985 curline = 4, 1986 curcol = 0, 1987 linecount = 5, 1988 sum_scroll_delta = 5, 1989 }, 1990 }, 1991 } 1992 else 1993 screen:expect([[ 1994 ^line 5 | 1995 {1:~ }|*6 1996 | 1997 ]]) 1998 end 1999 2000 feed('3<C-Y>') 2001 if multigrid then 2002 screen:expect { 2003 grid = [[ 2004 ## grid 1 2005 [2:---------------------------------------------]|*7 2006 [3:---------------------------------------------]| 2007 ## grid 2 2008 virt_line below line 2 | 2009 more virt_line below line 2 | 2010 {13:+-- 2 lines: line 3·························}| 2011 ^line 5 | 2012 {1:~ }|*3 2013 ## grid 3 2014 | 2015 ]], 2016 win_viewport = { 2017 [2] = { 2018 win = 1000, 2019 topline = 2, 2020 botline = 6, 2021 curline = 4, 2022 curcol = 0, 2023 linecount = 5, 2024 sum_scroll_delta = 2, 2025 }, 2026 }, 2027 } 2028 else 2029 screen:expect([[ 2030 virt_line below line 2 | 2031 more virt_line below line 2 | 2032 {13:+-- 2 lines: line 3·························}| 2033 ^line 5 | 2034 {1:~ }|*3 2035 | 2036 ]]) 2037 end 2038 2039 api.nvim_input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0) 2040 if multigrid then 2041 screen:expect { 2042 grid = [[ 2043 ## grid 1 2044 [2:---------------------------------------------]|*7 2045 [3:---------------------------------------------]| 2046 ## grid 2 2047 virt_line below line 2 | 2048 more virt_line below line 2 | 2049 {13:+-- 2 lines: line 3·························}| 2050 ^l{17:ine 5} | 2051 {1:~ }|*3 2052 ## grid 3 2053 {5:-- VISUAL LINE --} | 2054 ]], 2055 win_viewport = { 2056 [2] = { 2057 win = 1000, 2058 topline = 2, 2059 botline = 6, 2060 curline = 4, 2061 curcol = 0, 2062 linecount = 5, 2063 sum_scroll_delta = 2, 2064 }, 2065 }, 2066 } 2067 else 2068 screen:expect([[ 2069 virt_line below line 2 | 2070 more virt_line below line 2 | 2071 {13:+-- 2 lines: line 3·························}| 2072 ^l{17:ine 5} | 2073 {1:~ }|*3 2074 {5:-- VISUAL LINE --} | 2075 ]]) 2076 end 2077 2078 api.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0) 2079 if multigrid then 2080 screen:expect { 2081 grid = [[ 2082 ## grid 1 2083 [2:---------------------------------------------]|*7 2084 [3:---------------------------------------------]| 2085 ## grid 2 2086 more virt_line below line 2 | 2087 {13:+-- 2 lines: line 3·························}| 2088 ^l{17:ine 5} | 2089 {1:~ }|*4 2090 ## grid 3 2091 {5:-- VISUAL LINE --} | 2092 ]], 2093 win_viewport = { 2094 [2] = { 2095 win = 1000, 2096 topline = 2, 2097 botline = 6, 2098 curline = 4, 2099 curcol = 0, 2100 linecount = 5, 2101 sum_scroll_delta = 3, 2102 }, 2103 }, 2104 } 2105 else 2106 screen:expect([[ 2107 more virt_line below line 2 | 2108 {13:+-- 2 lines: line 3·························}| 2109 ^l{17:ine 5} | 2110 {1:~ }|*4 2111 {5:-- VISUAL LINE --} | 2112 ]]) 2113 end 2114 2115 api.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5) 2116 if multigrid then 2117 screen:expect { 2118 grid = [[ 2119 ## grid 1 2120 [2:---------------------------------------------]|*7 2121 [3:---------------------------------------------]| 2122 ## grid 2 2123 {13:+-- 2 lines: line 3·························}| 2124 {17:line }^5 | 2125 {1:~ }|*5 2126 ## grid 3 2127 {5:-- VISUAL LINE --} | 2128 ]], 2129 win_viewport = { 2130 [2] = { 2131 win = 1000, 2132 topline = 2, 2133 botline = 6, 2134 curline = 4, 2135 curcol = 5, 2136 linecount = 5, 2137 sum_scroll_delta = 4, 2138 }, 2139 }, 2140 } 2141 else 2142 screen:expect([[ 2143 {13:+-- 2 lines: line 3·························}| 2144 {17:line }^5 | 2145 {1:~ }|*5 2146 {5:-- VISUAL LINE --} | 2147 ]]) 2148 end 2149 2150 feed('<Esc>gg') 2151 command('botright 1split | wincmd w') 2152 if multigrid then 2153 screen:expect { 2154 grid = [[ 2155 ## grid 1 2156 [2:---------------------------------------------]|*4 2157 {3:[No Name] [+] }| 2158 [4:---------------------------------------------]| 2159 {2:[No Name] [+] }| 2160 [3:---------------------------------------------]| 2161 ## grid 2 2162 ^line 1 | 2163 line 2 | 2164 virt_line below line 2 | 2165 more virt_line below line 2 | 2166 ## grid 3 2167 | 2168 ## grid 4 2169 line 1 | 2170 ]], 2171 win_viewport = { 2172 [2] = { 2173 win = 1000, 2174 topline = 0, 2175 botline = 3, 2176 curline = 0, 2177 curcol = 0, 2178 linecount = 5, 2179 sum_scroll_delta = 0, 2180 }, 2181 [4] = { 2182 win = 1001, 2183 topline = 0, 2184 botline = 2, 2185 curline = 0, 2186 curcol = 0, 2187 linecount = 5, 2188 sum_scroll_delta = 0, 2189 }, 2190 }, 2191 } 2192 else 2193 screen:expect([[ 2194 ^line 1 | 2195 line 2 | 2196 virt_line below line 2 | 2197 more virt_line below line 2 | 2198 {3:[No Name] [+] }| 2199 line 1 | 2200 {2:[No Name] [+] }| 2201 | 2202 ]]) 2203 end 2204 2205 feed('<C-Y>') 2206 if multigrid then 2207 screen:expect { 2208 grid = [[ 2209 ## grid 1 2210 [2:---------------------------------------------]|*4 2211 {3:[No Name] [+] }| 2212 [4:---------------------------------------------]| 2213 {2:[No Name] [+] }| 2214 [3:---------------------------------------------]| 2215 ## grid 2 2216 virt_line above line 1 | 2217 ^line 1 | 2218 line 2 | 2219 virt_line below line 2 | 2220 ## grid 3 2221 | 2222 ## grid 4 2223 line 1 | 2224 ]], 2225 win_viewport = { 2226 [2] = { 2227 win = 1000, 2228 topline = 0, 2229 botline = 3, 2230 curline = 0, 2231 curcol = 0, 2232 linecount = 5, 2233 sum_scroll_delta = -1, 2234 }, 2235 [4] = { 2236 win = 1001, 2237 topline = 0, 2238 botline = 2, 2239 curline = 0, 2240 curcol = 0, 2241 linecount = 5, 2242 sum_scroll_delta = 0, 2243 }, 2244 }, 2245 } 2246 else 2247 screen:expect([[ 2248 virt_line above line 1 | 2249 ^line 1 | 2250 line 2 | 2251 virt_line below line 2 | 2252 {3:[No Name] [+] }| 2253 line 1 | 2254 {2:[No Name] [+] }| 2255 | 2256 ]]) 2257 end 2258 end) 2259 2260 it('Folded and Visual highlights are combined #19691', function() 2261 command('hi! Visual guifg=NONE guibg=Red') 2262 insert([[ 2263 " foofoofoofoofoofoo 2264 " 口 {{{1 2265 set nocp 2266 " }}}1 2267 " barbarbarbarbarbar 2268 " 口 {{{1 2269 set foldmethod=marker 2270 " }}}1 2271 " bazbazbazbazbazbaz]]) 2272 feed('gg') 2273 command('source') 2274 feed('<C-V>G15l') 2275 if multigrid then 2276 screen:expect([[ 2277 ## grid 1 2278 [2:---------------------------------------------]|*7 2279 [3:---------------------------------------------]| 2280 ## grid 2 2281 {30:" foofoofoofoofo}ofoo | 2282 {103:+-- 3 lines: " }{13:口···························}| 2283 {30:" barbarbarbarba}rbar | 2284 {103:+-- 3 lines: " }{13:口···························}| 2285 {30:" bazbazbazbazb}^azbaz | 2286 {1:~ }|*2 2287 ## grid 3 2288 {5:-- VISUAL BLOCK --} | 2289 ]]) 2290 else 2291 screen:expect([[ 2292 {30:" foofoofoofoofo}ofoo | 2293 {103:+-- 3 lines: " }{13:口···························}| 2294 {30:" barbarbarbarba}rbar | 2295 {103:+-- 3 lines: " }{13:口···························}| 2296 {30:" bazbazbazbazb}^azbaz | 2297 {1:~ }|*2 2298 {5:-- VISUAL BLOCK --} | 2299 ]]) 2300 end 2301 2302 feed('l') 2303 if multigrid then 2304 screen:expect([[ 2305 ## grid 1 2306 [2:---------------------------------------------]|*7 2307 [3:---------------------------------------------]| 2308 ## grid 2 2309 {30:" foofoofoofoofoo}foo | 2310 {103:+-- 3 lines: " 口}{13:···························}| 2311 {30:" barbarbarbarbar}bar | 2312 {103:+-- 3 lines: " 口}{13:···························}| 2313 {30:" bazbazbazbazba}^zbaz | 2314 {1:~ }|*2 2315 ## grid 3 2316 {5:-- VISUAL BLOCK --} | 2317 ]]) 2318 else 2319 screen:expect([[ 2320 {30:" foofoofoofoofoo}foo | 2321 {103:+-- 3 lines: " 口}{13:···························}| 2322 {30:" barbarbarbarbar}bar | 2323 {103:+-- 3 lines: " 口}{13:···························}| 2324 {30:" bazbazbazbazba}^zbaz | 2325 {1:~ }|*2 2326 {5:-- VISUAL BLOCK --} | 2327 ]]) 2328 end 2329 2330 feed('l') 2331 if multigrid then 2332 screen:expect([[ 2333 ## grid 1 2334 [2:---------------------------------------------]|*7 2335 [3:---------------------------------------------]| 2336 ## grid 2 2337 {30:" foofoofoofoofoof}oo | 2338 {103:+-- 3 lines: " 口}{13:···························}| 2339 {30:" barbarbarbarbarb}ar | 2340 {103:+-- 3 lines: " 口}{13:···························}| 2341 {30:" bazbazbazbazbaz}^baz | 2342 {1:~ }|*2 2343 ## grid 3 2344 {5:-- VISUAL BLOCK --} | 2345 ]]) 2346 else 2347 screen:expect([[ 2348 {30:" foofoofoofoofoof}oo | 2349 {103:+-- 3 lines: " 口}{13:···························}| 2350 {30:" barbarbarbarbarb}ar | 2351 {103:+-- 3 lines: " 口}{13:···························}| 2352 {30:" bazbazbazbazbaz}^baz | 2353 {1:~ }|*2 2354 {5:-- VISUAL BLOCK --} | 2355 ]]) 2356 end 2357 2358 feed('2l') 2359 if multigrid then 2360 screen:expect([[ 2361 ## grid 1 2362 [2:---------------------------------------------]|*7 2363 [3:---------------------------------------------]| 2364 ## grid 2 2365 {30:" foofoofoofoofoofoo} | 2366 {103:+-- 3 lines: " 口··}{13:·························}| 2367 {30:" barbarbarbarbarbar} | 2368 {103:+-- 3 lines: " 口··}{13:·························}| 2369 {30:" bazbazbazbazbazba}^z | 2370 {1:~ }|*2 2371 ## grid 3 2372 {5:-- VISUAL BLOCK --} | 2373 ]]) 2374 else 2375 screen:expect([[ 2376 {30:" foofoofoofoofoofoo} | 2377 {103:+-- 3 lines: " 口··}{13:·························}| 2378 {30:" barbarbarbarbarbar} | 2379 {103:+-- 3 lines: " 口··}{13:·························}| 2380 {30:" bazbazbazbazbazba}^z | 2381 {1:~ }|*2 2382 {5:-- VISUAL BLOCK --} | 2383 ]]) 2384 end 2385 2386 feed('O16l') 2387 if multigrid then 2388 screen:expect([[ 2389 ## grid 1 2390 [2:---------------------------------------------]|*7 2391 [3:---------------------------------------------]| 2392 ## grid 2 2393 " foofoofoofoofo{30:ofoo} | 2394 {13:+-- 3 lines: " }{103:口··}{13:·························}| 2395 " barbarbarbarba{30:rbar} | 2396 {13:+-- 3 lines: " }{103:口··}{13:·························}| 2397 " bazbazbazbazba^z{30:baz} | 2398 {1:~ }|*2 2399 ## grid 3 2400 {5:-- VISUAL BLOCK --} | 2401 ]]) 2402 else 2403 screen:expect([[ 2404 " foofoofoofoofo{30:ofoo} | 2405 {13:+-- 3 lines: " }{103:口··}{13:·························}| 2406 " barbarbarbarba{30:rbar} | 2407 {13:+-- 3 lines: " }{103:口··}{13:·························}| 2408 " bazbazbazbazba^z{30:baz} | 2409 {1:~ }|*2 2410 {5:-- VISUAL BLOCK --} | 2411 ]]) 2412 end 2413 2414 feed('l') 2415 if multigrid then 2416 screen:expect([[ 2417 ## grid 1 2418 [2:---------------------------------------------]|*7 2419 [3:---------------------------------------------]| 2420 ## grid 2 2421 " foofoofoofoofoo{30:foo} | 2422 {13:+-- 3 lines: " }{103:口··}{13:·························}| 2423 " barbarbarbarbar{30:bar} | 2424 {13:+-- 3 lines: " }{103:口··}{13:·························}| 2425 " bazbazbazbazbaz^b{30:az} | 2426 {1:~ }|*2 2427 ## grid 3 2428 {5:-- VISUAL BLOCK --} | 2429 ]]) 2430 else 2431 screen:expect([[ 2432 " foofoofoofoofoo{30:foo} | 2433 {13:+-- 3 lines: " }{103:口··}{13:·························}| 2434 " barbarbarbarbar{30:bar} | 2435 {13:+-- 3 lines: " }{103:口··}{13:·························}| 2436 " bazbazbazbazbaz^b{30:az} | 2437 {1:~ }|*2 2438 {5:-- VISUAL BLOCK --} | 2439 ]]) 2440 end 2441 end) 2442 2443 it('do not show search or match highlight #24084', function() 2444 insert([[ 2445 line 1 2446 line 2 2447 line 3 2448 line 4]]) 2449 command('2,3fold') 2450 feed('/line') 2451 if multigrid then 2452 screen:expect([[ 2453 ## grid 1 2454 [2:---------------------------------------------]|*7 2455 [3:---------------------------------------------]| 2456 ## grid 2 2457 {2:line} 1 | 2458 {13:+-- 2 lines: line 2·························}| 2459 {10:line} 4 | 2460 {1:~ }|*4 2461 ## grid 3 2462 /line^ | 2463 ]]) 2464 else 2465 screen:expect([[ 2466 {2:line} 1 | 2467 {13:+-- 2 lines: line 2·························}| 2468 {10:line} 4 | 2469 {1:~ }|*4 2470 /line^ | 2471 ]]) 2472 end 2473 feed('<Esc>') 2474 fn.matchadd('Search', 'line') 2475 if multigrid then 2476 screen:expect([[ 2477 ## grid 1 2478 [2:---------------------------------------------]|*7 2479 [3:---------------------------------------------]| 2480 ## grid 2 2481 {10:line} 1 | 2482 {13:+-- 2 lines: line 2·························}| 2483 {10:line} ^4 | 2484 {1:~ }|*4 2485 ## grid 3 2486 | 2487 ]]) 2488 else 2489 screen:expect([[ 2490 {10:line} 1 | 2491 {13:+-- 2 lines: line 2·························}| 2492 {10:line} ^4 | 2493 {1:~ }|*4 2494 | 2495 ]]) 2496 end 2497 end) 2498 2499 it('foldtext with virtual text format', function() 2500 screen:try_resize(30, 7) 2501 insert(content1) 2502 command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') 2503 command('hi F0 guibg=Red guifg=Black') 2504 command('hi F1 guifg=White') 2505 api.nvim_set_option_value('cursorline', true, {}) 2506 api.nvim_set_option_value('foldcolumn', '4', {}) 2507 api.nvim_set_option_value( 2508 'foldtext', 2509 '[' 2510 .. '["▶", ["F0", "F1"]], ' 2511 .. '[v:folddashes], ' 2512 .. '["\t", "Search"], ' 2513 .. '[getline(v:foldstart), "NonText"]]', 2514 {} 2515 ) 2516 2517 command('3,4fold') 2518 command('5,6fold') 2519 command('2,6fold') 2520 if multigrid then 2521 screen:expect([[ 2522 ## grid 1 2523 [2:------------------------------]|*6 2524 [3:------------------------------]| 2525 ## grid 2 2526 {7: }This is a | 2527 {7:+ }{9:^▶}{101:-}{20: }{104:valid English}{101:·····}| 2528 {1:~ }|*4 2529 ## grid 3 2530 | 2531 ]]) 2532 else 2533 screen:expect([[ 2534 {7: }This is a | 2535 {7:+ }{9:^▶}{101:-}{20: }{104:valid English}{101:·····}| 2536 {1:~ }|*4 2537 | 2538 ]]) 2539 end 2540 eq('▶-\tvalid English', fn.foldtextresult(2)) 2541 2542 feed('zo') 2543 if multigrid then 2544 screen:expect([[ 2545 ## grid 1 2546 [2:------------------------------]|*6 2547 [3:------------------------------]| 2548 ## grid 2 2549 {7: }This is a | 2550 {7:- }valid English | 2551 {7:│+ }{9:▶}{13:--}{105: }{104:sentence composed }| 2552 {7:│+ }{9:^▶}{101:--}{20: }{104:in his cave.}{101:······}| 2553 {1:~ }|*2 2554 ## grid 3 2555 | 2556 ]]) 2557 else 2558 screen:expect([[ 2559 {7: }This is a | 2560 {7:- }valid English | 2561 {7:│+ }{9:▶}{13:--}{105: }{104:sentence composed }| 2562 {7:│+ }{9:^▶}{101:--}{20: }{104:in his cave.}{101:······}| 2563 {1:~ }|*2 2564 | 2565 ]]) 2566 end 2567 eq('▶--\tsentence composed by', fn.foldtextresult(3)) 2568 eq('▶--\tin his cave.', fn.foldtextresult(5)) 2569 2570 command('hi! Visual guifg=NONE guibg=Red') 2571 feed('V2k') 2572 if multigrid then 2573 screen:expect([[ 2574 ## grid 1 2575 [2:------------------------------]|*6 2576 [3:------------------------------]| 2577 ## grid 2 2578 {7: }This is a | 2579 {7:- }^v{30:alid English} | 2580 {7:│+ }{9:▶}{103:--}{105: }{106:sentence composed }| 2581 {7:│+ }{9:▶}{103:--}{105: }{106:in his cave.}{103:······}| 2582 {1:~ }|*2 2583 ## grid 3 2584 {5:-- VISUAL LINE --} | 2585 ]]) 2586 else 2587 screen:expect([[ 2588 {7: }This is a | 2589 {7:- }^v{30:alid English} | 2590 {7:│+ }{9:▶}{103:--}{105: }{106:sentence composed }| 2591 {7:│+ }{9:▶}{103:--}{105: }{106:in his cave.}{103:······}| 2592 {1:~ }|*2 2593 {5:-- VISUAL LINE --} | 2594 ]]) 2595 end 2596 2597 api.nvim_set_option_value('rightleft', true, {}) 2598 if multigrid then 2599 screen:expect([[ 2600 ## grid 1 2601 [2:------------------------------]|*6 2602 [3:------------------------------]| 2603 ## grid 2 2604 a si sihT{7: }| 2605 {30:hsilgnE dila}^v{7: -}| 2606 {106: desopmoc ecnetnes}{105: }{103:--}{9:▶}{7: +│}| 2607 {103:······}{106:.evac sih ni}{105: }{103:--}{9:▶}{7: +│}| 2608 {1: ~}|*2 2609 ## grid 3 2610 {5:-- VISUAL LINE --} | 2611 ]]) 2612 else 2613 screen:expect([[ 2614 a si sihT{7: }| 2615 {30:hsilgnE dila}^v{7: -}| 2616 {106: desopmoc ecnetnes}{105: }{103:--}{9:▶}{7: +│}| 2617 {103:······}{106:.evac sih ni}{105: }{103:--}{9:▶}{7: +│}| 2618 {1: ~}|*2 2619 {5:-- VISUAL LINE --} | 2620 ]]) 2621 end 2622 end) 2623 2624 it('transparent foldtext', function() 2625 screen:try_resize(30, 7) 2626 insert(content1) 2627 command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') 2628 command([[syn match Keyword /\<sentence\>/]]) 2629 command('hi! Keyword guibg=NONE guifg=Green') 2630 api.nvim_set_option_value('cursorline', true, {}) 2631 api.nvim_set_option_value('foldcolumn', '4', {}) 2632 api.nvim_set_option_value('foldtext', '', {}) 2633 2634 command('3,4fold') 2635 command('5,6fold') 2636 command('2,6fold') 2637 if multigrid then 2638 screen:expect([[ 2639 ## grid 1 2640 [2:------------------------------]|*6 2641 [3:------------------------------]| 2642 ## grid 2 2643 {7: }This is a | 2644 {7:+ }{101:^valid English·············}| 2645 {1:~ }|*4 2646 ## grid 3 2647 | 2648 ]]) 2649 else 2650 screen:expect([[ 2651 {7: }This is a | 2652 {7:+ }{101:^valid English·············}| 2653 {1:~ }|*4 2654 | 2655 ]]) 2656 end 2657 2658 feed('zo') 2659 if multigrid then 2660 screen:expect([[ 2661 ## grid 1 2662 [2:------------------------------]|*6 2663 [3:------------------------------]| 2664 ## grid 2 2665 {7: }This is a | 2666 {7:- }valid English | 2667 {7:│+ }{107:sentence}{13: composed by······}| 2668 {7:│+ }{101:^in his cave.··············}| 2669 {1:~ }|*2 2670 ## grid 3 2671 | 2672 ]]) 2673 else 2674 screen:expect([[ 2675 {7: }This is a | 2676 {7:- }valid English | 2677 {7:│+ }{107:sentence}{13: composed by······}| 2678 {7:│+ }{101:^in his cave.··············}| 2679 {1:~ }|*2 2680 | 2681 ]]) 2682 end 2683 2684 command('hi! Visual guifg=NONE guibg=Red') 2685 feed('V2k') 2686 if multigrid then 2687 screen:expect([[ 2688 ## grid 1 2689 [2:------------------------------]|*6 2690 [3:------------------------------]| 2691 ## grid 2 2692 {7: }This is a | 2693 {7:- }^v{30:alid English} | 2694 {7:│+ }{108:sentence}{103: composed by······}| 2695 {7:│+ }{103:in his cave.··············}| 2696 {1:~ }|*2 2697 ## grid 3 2698 {5:-- VISUAL LINE --} | 2699 ]]) 2700 else 2701 screen:expect([[ 2702 {7: }This is a | 2703 {7:- }^v{30:alid English} | 2704 {7:│+ }{108:sentence}{103: composed by······}| 2705 {7:│+ }{103:in his cave.··············}| 2706 {1:~ }|*2 2707 {5:-- VISUAL LINE --} | 2708 ]]) 2709 end 2710 2711 api.nvim_set_option_value('rightleft', true, {}) 2712 if multigrid then 2713 screen:expect([[ 2714 ## grid 1 2715 [2:------------------------------]|*6 2716 [3:------------------------------]| 2717 ## grid 2 2718 a si sihT{7: }| 2719 {30:hsilgnE dila}^v{7: -}| 2720 {103:······yb desopmoc }{108:ecnetnes}{7: +│}| 2721 {103:··············.evac sih ni}{7: +│}| 2722 {1: ~}|*2 2723 ## grid 3 2724 {5:-- VISUAL LINE --} | 2725 ]]) 2726 else 2727 screen:expect([[ 2728 a si sihT{7: }| 2729 {30:hsilgnE dila}^v{7: -}| 2730 {103:······yb desopmoc }{108:ecnetnes}{7: +│}| 2731 {103:··············.evac sih ni}{7: +│}| 2732 {1: ~}|*2 2733 {5:-- VISUAL LINE --} | 2734 ]]) 2735 end 2736 2737 api.nvim_set_option_value('rightleft', false, {}) 2738 api.nvim_set_option_value('wrap', false, {}) 2739 feed('<Esc>zl') 2740 if multigrid then 2741 screen:expect([[ 2742 ## grid 1 2743 [2:------------------------------]|*6 2744 [3:------------------------------]| 2745 ## grid 2 2746 {7: }his is a | 2747 {7:- }{100:^alid English }| 2748 {7:│+ }{107:entence}{13: composed by·······}| 2749 {7:│+ }{13:n his cave.···············}| 2750 {1:~ }|*2 2751 ## grid 3 2752 | 2753 ]]) 2754 else 2755 screen:expect([[ 2756 {7: }his is a | 2757 {7:- }{100:^alid English }| 2758 {7:│+ }{107:entence}{13: composed by·······}| 2759 {7:│+ }{13:n his cave.···············}| 2760 {1:~ }|*2 2761 | 2762 ]]) 2763 end 2764 2765 fn.append(0, ('!'):rep(15)) 2766 feed('gg$zs') 2767 if multigrid then 2768 screen:expect([[ 2769 ## grid 1 2770 [2:------------------------------]|*6 2771 [3:------------------------------]| 2772 ## grid 2 2773 {7: }{100:^! }| 2774 {7: } | 2775 {7:- } | 2776 {7:│+ }{13:sed by····················}| 2777 {7:│+ }{13:··························}| 2778 {1:~ }| 2779 ## grid 3 2780 | 2781 ]]) 2782 else 2783 screen:expect([[ 2784 {7: }{100:^! }| 2785 {7: } | 2786 {7:- } | 2787 {7:│+ }{13:sed by····················}| 2788 {7:│+ }{13:··························}| 2789 {1:~ }| 2790 | 2791 ]]) 2792 end 2793 end) 2794 2795 it('transparent foldtext filler text search highlighting', function() 2796 screen:try_resize(30, 7) 2797 insert(content1) 2798 api.nvim_set_option_value('foldtext', '', {}) 2799 2800 command("3,4fold | let v:hlsearch = 1 | let @/ = '.'") 2801 if multigrid then 2802 screen:expect([[ 2803 ## grid 1 2804 [2:------------------------------]|*6 2805 [3:------------------------------]| 2806 ## grid 2 2807 {10:This is a} | 2808 {10:valid English} | 2809 {105:sentence composed by}{13:··········}| 2810 {10:in his cave.} | 2811 ^ | 2812 {1:~ }| 2813 ## grid 3 2814 | 2815 ]]) 2816 else 2817 screen:expect([[ 2818 {10:This is a} | 2819 {10:valid English} | 2820 {105:sentence composed by}{13:··········}| 2821 {10:in his cave.} | 2822 ^ | 2823 {1:~ }| 2824 | 2825 ]]) 2826 end 2827 2828 command("let @/ = '$'") 2829 if multigrid then 2830 screen:expect([[ 2831 ## grid 1 2832 [2:------------------------------]|*6 2833 [3:------------------------------]| 2834 ## grid 2 2835 This is a{10: } | 2836 valid English{10: } | 2837 {13:sentence composed by}{105:·}{13:·········}| 2838 in his cave.{10: } | 2839 {10:^ } | 2840 {1:~ }| 2841 ## grid 3 2842 | 2843 ]]) 2844 else 2845 screen:expect([[ 2846 This is a{10: } | 2847 valid English{10: } | 2848 {13:sentence composed by}{105:·}{13:·········}| 2849 in his cave.{10: } | 2850 {10:^ } | 2851 {1:~ }| 2852 | 2853 ]]) 2854 end 2855 2856 command("let @/ = '.\\?'") 2857 if multigrid then 2858 screen:expect([[ 2859 ## grid 1 2860 [2:------------------------------]|*6 2861 [3:------------------------------]| 2862 ## grid 2 2863 {10:This is a } | 2864 {10:valid English } | 2865 {105:sentence composed by·}{13:·········}| 2866 {10:in his cave. } | 2867 {10:^ } | 2868 {1:~ }| 2869 ## grid 3 2870 | 2871 ]]) 2872 else 2873 screen:expect([[ 2874 {10:This is a } | 2875 {10:valid English } | 2876 {105:sentence composed by·}{13:·········}| 2877 {10:in his cave. } | 2878 {10:^ } | 2879 {1:~ }| 2880 | 2881 ]]) 2882 end 2883 2884 command('set list') 2885 screen:expect_unchanged() -- No "eol" set for &listchars yet. 2886 2887 command("set listchars+=eol:& | let @/ = '.'") 2888 if multigrid then 2889 screen:expect([[ 2890 ## grid 1 2891 [2:------------------------------]|*6 2892 [3:------------------------------]| 2893 ## grid 2 2894 {10:This is a}{1:&} | 2895 {10:valid English}{1:&} | 2896 {105:sentence composed by}{104:&}{13:·········}| 2897 {10:in his cave.}{1:&} | 2898 {1:^&} | 2899 {1:~ }| 2900 ## grid 3 2901 | 2902 ]]) 2903 else 2904 screen:expect([[ 2905 {10:This is a}{1:&} | 2906 {10:valid English}{1:&} | 2907 {105:sentence composed by}{104:&}{13:·········}| 2908 {10:in his cave.}{1:&} | 2909 {1:^&} | 2910 {1:~ }| 2911 | 2912 ]]) 2913 end 2914 2915 command("let @/ = '$'") 2916 if multigrid then 2917 screen:expect([[ 2918 ## grid 1 2919 [2:------------------------------]|*6 2920 [3:------------------------------]| 2921 ## grid 2 2922 This is a{109:&} | 2923 valid English{109:&} | 2924 {13:sentence composed by}{109:&}{13:·········}| 2925 in his cave.{109:&} | 2926 {109:^&} | 2927 {1:~ }| 2928 ## grid 3 2929 | 2930 ]]) 2931 else 2932 screen:expect([[ 2933 This is a{109:&} | 2934 valid English{109:&} | 2935 {13:sentence composed by}{109:&}{13:·········}| 2936 in his cave.{109:&} | 2937 {109:^&} | 2938 {1:~ }| 2939 | 2940 ]]) 2941 end 2942 2943 command("let @/ = '.\\?'") 2944 if multigrid then 2945 screen:expect([[ 2946 ## grid 1 2947 [2:------------------------------]|*6 2948 [3:------------------------------]| 2949 ## grid 2 2950 {10:This is a}{109:&} | 2951 {10:valid English}{109:&} | 2952 {105:sentence composed by}{109:&}{13:·········}| 2953 {10:in his cave.}{109:&} | 2954 {109:^&} | 2955 {1:~ }| 2956 ## grid 3 2957 | 2958 ]]) 2959 else 2960 screen:expect([[ 2961 {10:This is a}{109:&} | 2962 {10:valid English}{109:&} | 2963 {105:sentence composed by}{109:&}{13:·········}| 2964 {10:in his cave.}{109:&} | 2965 {109:^&} | 2966 {1:~ }| 2967 | 2968 ]]) 2969 end 2970 end) 2971 end 2972 2973 describe('with ext_multigrid', function() 2974 with_ext_multigrid(true) 2975 end) 2976 2977 describe('without ext_multigrid', function() 2978 with_ext_multigrid(false) 2979 end) 2980 2981 it("do not interfere with corrected cursor position for 'scrolloff'", function() 2982 local screen = Screen.new(40, 7) 2983 exec([[ 2984 call setline(1, range(10)) 2985 6,7fold 2986 set scrolloff=1 2987 norm L 2988 ]]) 2989 screen:expect([[ 2990 0 | 2991 1 | 2992 2 | 2993 3 | 2994 ^4 | 2995 {13:+-- 2 lines: 5·························}| 2996 | 2997 ]]) 2998 end) 2999 end)