popupmenu_spec.lua (371085B)
1 local t = require('test.testutil') 2 local n = require('test.functional.testnvim')() 3 local Screen = require('test.functional.ui.screen') 4 5 local assert_alive = n.assert_alive 6 local clear, feed = n.clear, n.feed 7 local source = n.source 8 local insert = n.insert 9 local api = n.api 10 local async_meths = n.async_meths 11 local command = n.command 12 local fn = n.fn 13 local eq = t.eq 14 local pcall_err = t.pcall_err 15 local exec_lua = n.exec_lua 16 local exec = n.exec 17 local poke_eventloop = n.poke_eventloop 18 19 describe('ui/ext_popupmenu', function() 20 local screen 21 before_each(function() 22 clear() 23 screen = Screen.new(60, 8, { rgb = true, ext_popupmenu = true }) 24 source([[ 25 function! TestComplete() abort 26 call complete(1, [{'word':'foo', 'abbr':'fo', 'menu':'the foo', 'info':'foo-y', 'kind':'x'}, 'bar', 'spam']) 27 return '' 28 endfunction 29 ]]) 30 end) 31 32 local expected = { 33 { 'fo', 'x', 'the foo', 'foo-y' }, 34 { 'bar', '', '', '' }, 35 { 'spam', '', '', '' }, 36 } 37 38 it('works', function() 39 feed('o<C-r>=TestComplete()<CR>') 40 screen:expect { 41 grid = [[ 42 | 43 foo^ | 44 {1:~ }|*5 45 {5:-- INSERT --} | 46 ]], 47 popupmenu = { items = expected, pos = 0, anchor = { 1, 1, 0 } }, 48 } 49 50 feed('<c-p>') 51 screen:expect { 52 grid = [[ 53 | 54 ^ | 55 {1:~ }|*5 56 {5:-- INSERT --} | 57 ]], 58 popupmenu = { items = expected, pos = -1, anchor = { 1, 1, 0 } }, 59 } 60 61 -- down moves the selection in the menu, but does not insert anything 62 feed('<down><down>') 63 screen:expect { 64 grid = [[ 65 | 66 ^ | 67 {1:~ }|*5 68 {5:-- INSERT --} | 69 ]], 70 popupmenu = { items = expected, pos = 1, anchor = { 1, 1, 0 } }, 71 } 72 73 feed('<cr>') 74 screen:expect([[ 75 | 76 bar^ | 77 {1:~ }|*5 78 {5:-- INSERT --} | 79 ]]) 80 end) 81 82 it('can be controlled by API', function() 83 feed('o<C-r>=TestComplete()<CR>') 84 screen:expect { 85 grid = [[ 86 | 87 foo^ | 88 {1:~ }|*5 89 {5:-- INSERT --} | 90 ]], 91 popupmenu = { items = expected, pos = 0, anchor = { 1, 1, 0 } }, 92 } 93 94 api.nvim_select_popupmenu_item(1, false, false, {}) 95 screen:expect { 96 grid = [[ 97 | 98 foo^ | 99 {1:~ }|*5 100 {5:-- INSERT --} | 101 ]], 102 popupmenu = { items = expected, pos = 1, anchor = { 1, 1, 0 } }, 103 } 104 105 api.nvim_select_popupmenu_item(2, true, false, {}) 106 screen:expect { 107 grid = [[ 108 | 109 spam^ | 110 {1:~ }|*5 111 {5:-- INSERT --} | 112 ]], 113 popupmenu = { items = expected, pos = 2, anchor = { 1, 1, 0 } }, 114 } 115 116 api.nvim_select_popupmenu_item(0, true, true, {}) 117 screen:expect([[ 118 | 119 foo^ | 120 {1:~ }|*5 121 {5:-- INSERT --} | 122 ]]) 123 124 feed('<c-w><C-r>=TestComplete()<CR>') 125 screen:expect { 126 grid = [[ 127 | 128 foo^ | 129 {1:~ }|*5 130 {5:-- INSERT --} | 131 ]], 132 popupmenu = { items = expected, pos = 0, anchor = { 1, 1, 0 } }, 133 } 134 135 api.nvim_select_popupmenu_item(-1, false, false, {}) 136 screen:expect { 137 grid = [[ 138 | 139 foo^ | 140 {1:~ }|*5 141 {5:-- INSERT --} | 142 ]], 143 popupmenu = { items = expected, pos = -1, anchor = { 1, 1, 0 } }, 144 } 145 146 api.nvim_select_popupmenu_item(1, true, false, {}) 147 screen:expect { 148 grid = [[ 149 | 150 bar^ | 151 {1:~ }|*5 152 {5:-- INSERT --} | 153 ]], 154 popupmenu = { items = expected, pos = 1, anchor = { 1, 1, 0 } }, 155 } 156 157 api.nvim_select_popupmenu_item(-1, true, false, {}) 158 screen:expect { 159 grid = [[ 160 | 161 ^ | 162 {1:~ }|*5 163 {5:-- INSERT --} | 164 ]], 165 popupmenu = { items = expected, pos = -1, anchor = { 1, 1, 0 } }, 166 } 167 168 api.nvim_select_popupmenu_item(0, true, false, {}) 169 screen:expect { 170 grid = [[ 171 | 172 foo^ | 173 {1:~ }|*5 174 {5:-- INSERT --} | 175 ]], 176 popupmenu = { items = expected, pos = 0, anchor = { 1, 1, 0 } }, 177 } 178 179 api.nvim_select_popupmenu_item(-1, true, true, {}) 180 screen:expect([[ 181 | 182 ^ | 183 {1:~ }|*5 184 {5:-- INSERT --} | 185 ]]) 186 187 command('set wildmenu') 188 command('set wildoptions=pum') 189 local expected_wildpum = { 190 { 'define', '', '', '' }, 191 { 'jump', '', '', '' }, 192 { 'list', '', '', '' }, 193 { 'place', '', '', '' }, 194 { 'undefine', '', '', '' }, 195 { 'unplace', '', '', '' }, 196 } 197 feed('<Esc>:sign <Tab>') 198 screen:expect({ 199 grid = [[ 200 |*2 201 {1:~ }|*5 202 :sign define^ | 203 ]], 204 popupmenu = { items = expected_wildpum, pos = 0, anchor = { 1, 7, 6 } }, 205 }) 206 207 api.nvim_select_popupmenu_item(-1, true, false, {}) 208 screen:expect({ 209 grid = [[ 210 |*2 211 {1:~ }|*5 212 :sign ^ | 213 ]], 214 popupmenu = { items = expected_wildpum, pos = -1, anchor = { 1, 7, 6 } }, 215 }) 216 217 api.nvim_select_popupmenu_item(5, true, false, {}) 218 screen:expect({ 219 grid = [[ 220 |*2 221 {1:~ }|*5 222 :sign unplace^ | 223 ]], 224 popupmenu = { items = expected_wildpum, pos = 5, anchor = { 1, 7, 6 } }, 225 }) 226 227 api.nvim_select_popupmenu_item(-1, true, true, {}) 228 screen:expect({ 229 grid = [[ 230 |*2 231 {1:~ }|*5 232 :sign ^ | 233 ]], 234 }) 235 236 feed('<Tab>') 237 screen:expect({ 238 grid = [[ 239 |*2 240 {1:~ }|*5 241 :sign define^ | 242 ]], 243 popupmenu = { items = expected_wildpum, pos = 0, anchor = { 1, 7, 6 } }, 244 }) 245 246 api.nvim_select_popupmenu_item(5, true, true, {}) 247 screen:expect([[ 248 |*2 249 {1:~ }|*5 250 :sign unplace^ | 251 ]]) 252 253 local function test_pum_select_mappings() 254 screen:set_option('ext_popupmenu', true) 255 feed('<Esc>A<C-r>=TestComplete()<CR>') 256 screen:expect { 257 grid = [[ 258 | 259 foo^ | 260 {1:~ }|*5 261 {5:-- INSERT --} | 262 ]], 263 popupmenu = { items = expected, pos = 0, anchor = { 1, 1, 0 } }, 264 } 265 266 feed('<f1>') 267 screen:expect { 268 grid = [[ 269 | 270 spam^ | 271 {1:~ }|*5 272 {5:-- INSERT --} | 273 ]], 274 popupmenu = { items = expected, pos = 2, anchor = { 1, 1, 0 } }, 275 } 276 277 feed('<f2>') 278 screen:expect { 279 grid = [[ 280 | 281 spam^ | 282 {1:~ }|*5 283 {5:-- INSERT --} | 284 ]], 285 popupmenu = { items = expected, pos = -1, anchor = { 1, 1, 0 } }, 286 } 287 288 feed('<f3>') 289 screen:expect([[ 290 | 291 bar^ | 292 {1:~ }|*5 293 {5:-- INSERT --} | 294 ]]) 295 296 feed('<Esc>:sign <Tab>') 297 screen:expect({ 298 grid = [[ 299 | 300 bar | 301 {1:~ }|*5 302 :sign define^ | 303 ]], 304 popupmenu = { items = expected_wildpum, pos = 0, anchor = { 1, 7, 6 } }, 305 }) 306 307 feed('<f1>') 308 screen:expect({ 309 grid = [[ 310 | 311 bar | 312 {1:~ }|*5 313 :sign list^ | 314 ]], 315 popupmenu = { items = expected_wildpum, pos = 2, anchor = { 1, 7, 6 } }, 316 }) 317 318 feed('<f2>') 319 screen:expect({ 320 grid = [[ 321 | 322 bar | 323 {1:~ }|*5 324 :sign ^ | 325 ]], 326 popupmenu = { items = expected_wildpum, pos = -1, anchor = { 1, 7, 6 } }, 327 }) 328 329 feed('<f3>') 330 screen:expect({ 331 grid = [[ 332 | 333 bar | 334 {1:~ }|*5 335 :sign jump^ | 336 ]], 337 }) 338 339 -- also should work for builtin popupmenu 340 screen:set_option('ext_popupmenu', false) 341 feed('<Esc>A<C-r>=TestComplete()<CR>') 342 screen:expect([[ 343 | 344 foo^ | 345 {12:fo x the foo }{1: }| 346 {4:bar }{1: }| 347 {4:spam }{1: }| 348 {1:~ }|*2 349 {5:-- INSERT --} | 350 ]]) 351 352 feed('<f1>') 353 screen:expect([[ 354 | 355 spam^ | 356 {4:fo x the foo }{1: }| 357 {4:bar }{1: }| 358 {12:spam }{1: }| 359 {1:~ }|*2 360 {5:-- INSERT --} | 361 ]]) 362 363 feed('<f2>') 364 screen:expect([[ 365 | 366 spam^ | 367 {4:fo x the foo }{1: }| 368 {4:bar }{1: }| 369 {4:spam }{1: }| 370 {1:~ }|*2 371 {5:-- INSERT --} | 372 ]]) 373 374 feed('<f3>') 375 screen:expect([[ 376 | 377 bar^ | 378 {1:~ }|*5 379 {5:-- INSERT --} | 380 ]]) 381 382 feed('<Esc>:sign <Tab>') 383 screen:expect([[ 384 | 385 bar {12: define } | 386 {1:~ }{4: jump }{1: }| 387 {1:~ }{4: list }{1: }| 388 {1:~ }{4: place }{1: }| 389 {1:~ }{4: undefine }{1: }| 390 {1:~ }{4: unplace }{1: }| 391 :sign define^ | 392 ]]) 393 394 feed('<f1>') 395 screen:expect([[ 396 | 397 bar {4: define } | 398 {1:~ }{4: jump }{1: }| 399 {1:~ }{12: list }{1: }| 400 {1:~ }{4: place }{1: }| 401 {1:~ }{4: undefine }{1: }| 402 {1:~ }{4: unplace }{1: }| 403 :sign list^ | 404 ]]) 405 406 feed('<f2>') 407 screen:expect([[ 408 | 409 bar {4: define } | 410 {1:~ }{4: jump }{1: }| 411 {1:~ }{4: list }{1: }| 412 {1:~ }{4: place }{1: }| 413 {1:~ }{4: undefine }{1: }| 414 {1:~ }{4: unplace }{1: }| 415 :sign ^ | 416 ]]) 417 418 feed('<f3>') 419 screen:expect([[ 420 | 421 bar | 422 {1:~ }|*5 423 :sign jump^ | 424 ]]) 425 end 426 427 command('map! <f1> <cmd>call nvim_select_popupmenu_item(2,v:true,v:false,{})<cr>') 428 command('map! <f2> <cmd>call nvim_select_popupmenu_item(-1,v:false,v:false,{})<cr>') 429 command('map! <f3> <cmd>call nvim_select_popupmenu_item(1,v:false,v:true,{})<cr>') 430 test_pum_select_mappings() 431 432 command('unmap! <f1>') 433 command('unmap! <f2>') 434 command('unmap! <f3>') 435 exec_lua([[ 436 vim.keymap.set('!', '<f1>', function() vim.api.nvim_select_popupmenu_item(2, true, false, {}) end) 437 vim.keymap.set('!', '<f2>', function() vim.api.nvim_select_popupmenu_item(-1, false, false, {}) end) 438 vim.keymap.set('!', '<f3>', function() vim.api.nvim_select_popupmenu_item(1, false, true, {}) end) 439 ]]) 440 test_pum_select_mappings() 441 442 feed('<esc>ddiaa bb cc<cr>') 443 feed('<c-x><c-n>') 444 screen:expect([[ 445 aa bb cc | 446 aa^ | 447 {12:aa }{1: }| 448 {4:bb }{1: }| 449 {4:cc }{1: }| 450 {1:~ }|*2 451 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 3} | 452 ]]) 453 454 feed('<f1>') 455 screen:expect([[ 456 aa bb cc | 457 cc^ | 458 {4:aa }{1: }| 459 {4:bb }{1: }| 460 {12:cc }{1: }| 461 {1:~ }|*2 462 {5:-- Keyword Local completion (^N^P) }{6:match 3 of 3} | 463 ]]) 464 465 feed('<f2>') 466 screen:expect([[ 467 aa bb cc | 468 cc^ | 469 {4:aa }{1: }| 470 {4:bb }{1: }| 471 {4:cc }{1: }| 472 {1:~ }|*2 473 {5:-- Keyword Local completion (^N^P) }{19:Back at original} | 474 ]]) 475 476 feed('<f3>') 477 screen:expect([[ 478 aa bb cc | 479 bb^ | 480 {1:~ }|*5 481 {5:-- INSERT --} | 482 ]]) 483 end) 484 485 local function source_complete_month() 486 source([[ 487 function! TestCompleteMonth() abort 488 call complete(1, ['January', 'February', 'March', 'April', 489 \ 'May', 'June', 'July', 'August', 490 \ 'September', 'October', 'November', 'December']) 491 return '' 492 endfunction 493 ]]) 494 end 495 496 describe('pum_set_height', function() 497 it('can set pum height', function() 498 source_complete_month() 499 local month_expected = { 500 { 'January', '', '', '' }, 501 { 'February', '', '', '' }, 502 { 'March', '', '', '' }, 503 { 'April', '', '', '' }, 504 { 'May', '', '', '' }, 505 { 'June', '', '', '' }, 506 { 'July', '', '', '' }, 507 { 'August', '', '', '' }, 508 { 'September', '', '', '' }, 509 { 'October', '', '', '' }, 510 { 'November', '', '', '' }, 511 { 'December', '', '', '' }, 512 } 513 local pum_height = 6 514 feed('o<C-r>=TestCompleteMonth()<CR>') 515 api.nvim_ui_pum_set_height(pum_height) 516 feed('<PageDown>') 517 -- pos becomes pum_height-2 because it is subtracting 2 to keep some 518 -- context in ins_compl_key2count() 519 screen:expect { 520 grid = [[ 521 | 522 January^ | 523 {1:~ }|*5 524 {5:-- INSERT --} | 525 ]], 526 popupmenu = { items = month_expected, pos = pum_height - 2, anchor = { 1, 1, 0 } }, 527 } 528 end) 529 530 it('an error occurs if set 0 or less', function() 531 api.nvim_ui_pum_set_height(1) 532 eq('Expected pum height > 0', pcall_err(api.nvim_ui_pum_set_height, 0)) 533 end) 534 535 it('an error occurs when ext_popupmenu is false', function() 536 api.nvim_ui_pum_set_height(1) 537 screen:set_option('ext_popupmenu', false) 538 eq('It must support the ext_popupmenu option', pcall_err(api.nvim_ui_pum_set_height, 1)) 539 end) 540 end) 541 542 describe('pum_set_bounds', function() 543 it('can set pum bounds', function() 544 source_complete_month() 545 local month_expected = { 546 { 'January', '', '', '' }, 547 { 'February', '', '', '' }, 548 { 'March', '', '', '' }, 549 { 'April', '', '', '' }, 550 { 'May', '', '', '' }, 551 { 'June', '', '', '' }, 552 { 'July', '', '', '' }, 553 { 'August', '', '', '' }, 554 { 'September', '', '', '' }, 555 { 'October', '', '', '' }, 556 { 'November', '', '', '' }, 557 { 'December', '', '', '' }, 558 } 559 local pum_height = 6 560 feed('o<C-r>=TestCompleteMonth()<CR>') 561 api.nvim_ui_pum_set_height(pum_height) 562 -- set bounds w h r c 563 api.nvim_ui_pum_set_bounds(10.5, 5.2, 6.3, 7.4) 564 feed('<PageDown>') 565 -- pos becomes pum_height-2 because it is subtracting 2 to keep some 566 -- context in ins_compl_key2count() 567 screen:expect { 568 grid = [[ 569 | 570 January^ | 571 {1:~ }|*5 572 {5:-- INSERT --} | 573 ]], 574 popupmenu = { items = month_expected, pos = pum_height - 2, anchor = { 1, 1, 0 } }, 575 } 576 end) 577 578 it('no error occurs if row or col set less than 0', function() 579 api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) 580 api.nvim_ui_pum_set_bounds(1.0, 1.0, -1.0, 0.0) 581 api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, -1.0) 582 end) 583 584 it('an error occurs if width or height set 0 or less', function() 585 api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) 586 eq('Expected width > 0', pcall_err(api.nvim_ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0)) 587 eq('Expected height > 0', pcall_err(api.nvim_ui_pum_set_bounds, 1.0, -1.0, 1.0, 0.0)) 588 end) 589 590 it('an error occurs when ext_popupmenu is false', function() 591 api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) 592 screen:set_option('ext_popupmenu', false) 593 eq( 594 'UI must support the ext_popupmenu option', 595 pcall_err(api.nvim_ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5) 596 ) 597 end) 598 end) 599 600 it('<PageUp>, <PageDown> works without ui_pum_set_height', function() 601 source_complete_month() 602 local month_expected = { 603 { 'January', '', '', '' }, 604 { 'February', '', '', '' }, 605 { 'March', '', '', '' }, 606 { 'April', '', '', '' }, 607 { 'May', '', '', '' }, 608 { 'June', '', '', '' }, 609 { 'July', '', '', '' }, 610 { 'August', '', '', '' }, 611 { 'September', '', '', '' }, 612 { 'October', '', '', '' }, 613 { 'November', '', '', '' }, 614 { 'December', '', '', '' }, 615 } 616 feed('o<C-r>=TestCompleteMonth()<CR>') 617 feed('<PageDown>') 618 screen:expect { 619 grid = [[ 620 | 621 January^ | 622 {1:~ }|*5 623 {5:-- INSERT --} | 624 ]], 625 popupmenu = { items = month_expected, pos = 3, anchor = { 1, 1, 0 } }, 626 } 627 feed('<PageUp>') 628 screen:expect { 629 grid = [[ 630 | 631 January^ | 632 {1:~ }|*5 633 {5:-- INSERT --} | 634 ]], 635 popupmenu = { items = month_expected, pos = 0, anchor = { 1, 1, 0 } }, 636 } 637 end) 638 639 it('works with wildoptions=pum', function() 640 screen:try_resize(32, 10) 641 command('set wildmenu') 642 command('set wildoptions=pum') 643 644 local wild_expected = { 645 { 'define', '', '', '' }, 646 { 'jump', '', '', '' }, 647 { 'list', '', '', '' }, 648 { 'place', '', '', '' }, 649 { 'undefine', '', '', '' }, 650 { 'unplace', '', '', '' }, 651 } 652 653 feed(':sign ') 654 screen:expect([[ 655 | 656 {1:~ }|*8 657 :sign ^ | 658 ]]) 659 eq(0, fn.wildmenumode()) 660 661 feed('<tab>') 662 screen:expect { 663 grid = [[ 664 | 665 {1:~ }|*8 666 :sign define^ | 667 ]], 668 popupmenu = { items = wild_expected, pos = 0, anchor = { 1, 9, 6 } }, 669 } 670 eq(1, fn.wildmenumode()) 671 672 feed('<left>') 673 screen:expect { 674 grid = [[ 675 | 676 {1:~ }|*8 677 :sign ^ | 678 ]], 679 popupmenu = { items = wild_expected, pos = -1, anchor = { 1, 9, 6 } }, 680 } 681 682 feed('<left>') 683 screen:expect { 684 grid = [[ 685 | 686 {1:~ }|*8 687 :sign unplace^ | 688 ]], 689 popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } }, 690 } 691 692 feed('x') 693 screen:expect([[ 694 | 695 {1:~ }|*8 696 :sign unplacex^ | 697 ]]) 698 feed('<esc>') 699 700 -- #10042: make sure shift-tab also triggers the pum 701 feed(':sign <S-tab>') 702 screen:expect { 703 grid = [[ 704 | 705 {1:~ }|*8 706 :sign unplace^ | 707 ]], 708 popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } }, 709 } 710 feed('<esc>') 711 eq(0, fn.wildmenumode()) 712 713 -- check positioning with multibyte char in pattern 714 command('e långfile1') 715 command('sp långfile2') 716 feed(':b lå<tab>') 717 screen:expect { 718 grid = [[ 719 | 720 {1:~ }|*3 721 {3:långfile2 }| 722 | 723 {1:~ }|*2 724 {2:långfile1 }| 725 :b långfile1^ | 726 ]], 727 popupmenu = { 728 anchor = { 1, 9, 3 }, 729 items = { { 'långfile1', '', '', '' }, { 'långfile2', '', '', '' } }, 730 pos = 0, 731 }, 732 } 733 end) 734 735 it('does not interfere with mousemodel=popup', function() 736 exec([[ 737 set mouse=a mousemodel=popup 738 739 aunmenu PopUp 740 " Delete the default MenuPopup event handler. 741 autocmd! nvim.popupmenu 742 menu PopUp.foo :let g:menustr = 'foo'<CR> 743 menu PopUp.bar :let g:menustr = 'bar'<CR> 744 menu PopUp.baz :let g:menustr = 'baz'<CR> 745 ]]) 746 feed('o<C-r>=TestComplete()<CR>') 747 screen:expect { 748 grid = [[ 749 | 750 foo^ | 751 {1:~ }|*5 752 {5:-- INSERT --} | 753 ]], 754 popupmenu = { items = expected, pos = 0, anchor = { 1, 1, 0 } }, 755 } 756 757 feed('<c-p>') 758 screen:expect { 759 grid = [[ 760 | 761 ^ | 762 {1:~ }|*5 763 {5:-- INSERT --} | 764 ]], 765 popupmenu = { items = expected, pos = -1, anchor = { 1, 1, 0 } }, 766 } 767 768 feed('<esc>') 769 screen:expect([[ 770 | 771 ^ | 772 {1:~ }|*5 773 | 774 ]]) 775 feed('<RightMouse><0,0>') 776 screen:expect([[ 777 | 778 {4:^foo } | 779 {4:bar }{1: }| 780 {4:baz }{1: }| 781 {1:~ }|*3 782 | 783 ]]) 784 feed('<esc>') 785 screen:expect([[ 786 | 787 ^ | 788 {1:~ }|*5 789 | 790 ]]) 791 end) 792 end) 793 794 describe("builtin popupmenu 'pumblend'", function() 795 local screen 796 before_each(function() 797 clear() 798 screen = Screen.new(60, 14) 799 screen:add_extra_attr_ids({ 800 [100] = { background = Screen.colors.Gray55, foreground = Screen.colors.Grey45 }, 801 [101] = { background = Screen.colors.Gray55, foreground = Screen.colors.Grey0 }, 802 [102] = { background = tonumber('0x191919'), foreground = Screen.colors.Grey0 }, 803 [103] = { background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8e5') }, 804 [104] = { background = tonumber('0xffc1ff'), foreground = Screen.colors.Grey0 }, 805 [105] = { foreground = tonumber('0xffc1ff'), background = tonumber('0xe5a8e5'), bold = true }, 806 [106] = { foreground = Screen.colors.Grey55, background = Screen.colors.Gray45, bold = true }, 807 [107] = { background = tonumber('0xffc1e5'), foreground = Screen.colors.Grey0 }, 808 [108] = { background = tonumber('0xffc1e5'), foreground = tonumber('0xe5a8e5') }, 809 [109] = { background = tonumber('0xffc1ff'), foreground = tonumber('0x080202') }, 810 [110] = { background = tonumber('0xffc1ff'), bold = true, foreground = tonumber('0xf6ace9') }, 811 [111] = { background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8ff') }, 812 [112] = { background = tonumber('0xe5a8e5'), foreground = tonumber('0xffc1ff') }, 813 [113] = { background = Screen.colors.Gray45, foreground = Screen.colors.Grey55 }, 814 [114] = { background = Screen.colors.WebGray }, 815 [115] = { background = Screen.colors.Grey0 }, 816 [116] = { background = Screen.colors.Gray75, foreground = Screen.colors.Grey25 }, 817 [117] = { background = Screen.colors.Gray75, foreground = Screen.colors.Grey0 }, 818 [118] = { background = Screen.colors.Gray50, foreground = Screen.colors.Grey0 }, 819 [119] = { background = tonumber('0xffddff'), foreground = tonumber('0x7f5d7f') }, 820 [120] = { background = tonumber('0xffddff'), foreground = Screen.colors.Grey0 }, 821 [121] = { foreground = tonumber('0xffddff'), background = tonumber('0x7f5d7f'), bold = true }, 822 [123] = { foreground = tonumber('0xffddff'), background = Screen.colors.Grey0, bold = true }, 823 [124] = { foreground = Screen.colors.Gray75, background = Screen.colors.Grey25, bold = true }, 824 [125] = { background = tonumber('0xffdd7f'), foreground = Screen.colors.Grey0 }, 825 [126] = { background = tonumber('0xffdd7f'), foreground = tonumber('0x7f5d7f') }, 826 [127] = { background = tonumber('0xffddff'), bold = true, foreground = tonumber('0x290a0a') }, 827 [128] = { background = tonumber('0xffddff'), bold = true, foreground = tonumber('0xd27294') }, 828 [129] = { background = tonumber('0xffddff'), foreground = tonumber('0x7f5dff') }, 829 [130] = { background = tonumber('0x7f5d7f'), foreground = tonumber('0xffddff') }, 830 [131] = { background = Screen.colors.Grey0, foreground = tonumber('0xffddff') }, 831 [132] = { background = Screen.colors.Gray25, foreground = Screen.colors.Grey75 }, 832 [134] = { background = tonumber('0xffddff'), foreground = tonumber('0x00003f') }, 833 [135] = { foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5') }, 834 [136] = { background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f') }, 835 [137] = { foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f') }, 836 [138] = { background = Screen.colors.WebGray, blend = 0 }, 837 [139] = { background = 7, foreground = Screen.colors.Gray0 }, 838 [140] = { background = 7, foreground = 85 }, 839 [141] = { background = 225, foreground = Screen.colors.Gray0 }, 840 [142] = { background = 225, foreground = 209 }, 841 [143] = { foreground = 12 }, 842 [144] = { foreground = 2 }, 843 [145] = { foreground = tonumber('0x290a0a'), background = tonumber('0xffddff') }, 844 }) 845 end) 846 847 it('RGB-color', function() 848 command('syntax on') 849 command('set mouse=a') 850 command('set pumblend=10') 851 insert([[ 852 Lorem ipsum dolor sit amet, consectetur 853 adipisicing elit, sed do eiusmod tempor 854 incididunt ut labore et dolore magna aliqua. 855 Ut enim ad minim veniam, quis nostrud 856 exercitation ullamco laboris nisi ut aliquip ex 857 ea commodo consequat. Duis aute irure dolor in 858 reprehenderit in voluptate velit esse cillum 859 dolore eu fugiat nulla pariatur. Excepteur sint 860 occaecat cupidatat non proident, sunt in culpa 861 qui officia deserunt mollit anim id est 862 laborum.]]) 863 command('match Statement /el/') 864 command('2match Comment /ut/') 865 command('1') 866 command('split') 867 command('/ol') 868 screen:expect([[ 869 Lorem ipsum d{10:ol}or sit amet, consectetur | 870 adipisicing elit, sed do eiusmod tempor | 871 ^incididunt ut labore et d{10:ol}ore magna aliqua. | 872 Ut enim ad minim veniam, quis nostrud | 873 exercitation ullamco laboris nisi ut aliquip ex | 874 ea commodo consequat. Duis aute irure d{10:ol}or in | 875 {3:[No Name] [+] }| 876 Lorem ipsum d{10:ol}or sit amet, consectetur | 877 adipisicing {15:el}it, sed do eiusmod tempor | 878 incididunt {18:ut} labore et d{10:ol}ore magna aliqua. | 879 Ut enim ad minim veniam, quis nostrud | 880 exercitation ullamco laboris nisi {18:ut} aliquip ex | 881 {2:[No Name] [+] }| 882 | 883 ]]) 884 885 feed('Obla bla <c-x><c-n>') 886 screen:expect([[ 887 Lorem ipsum d{10:ol}or sit amet, consectetur | 888 adipisicing elit, sed do eiusmod tempor | 889 bla bla incididunt^ | 890 incidid{100:u}{101:incididunt}{100:re et}{102: }d{10:ol}ore magna aliqua. | 891 Ut enim{103: }{104:ut}{103: minim veniam}{100:,} quis nostrud | 892 exercit{103:a}{104:labore}{103:llamco la}{100:b}oris nisi ut aliquip ex | 893 {3:[No Nam}{105:e}{135:et}{105:[+] }{106: }{3: }| 894 Lorem i{103:p}{104:dolor}{107:e}{108:l}{103:or sit a}{100:m}et, consectetur | 895 adipisi{103:c}{104:magn}{109:a}{110:l}{103:it, sed d}{100:o} eiusmod tempor | 896 bla bla{103: }{104:aliqua}{103:dunt }{100: } | 897 incidid{103:u}{104:Ut}{103: }{111:ut}{103: labore et}{100: }d{10:ol}ore magna aliqua. | 898 Ut enim{103: }{104:enim}{103:inim veniam}{100:,} quis nostrud | 899 {2:[No Nam}{112:e}{135:ad}{112:[+] }{113: }{2: }| 900 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 901 ]]) 902 903 command('set pumblend=0') 904 screen:expect([[ 905 Lorem ipsum d{10:ol}or sit amet, consectetur | 906 adipisicing elit, sed do eiusmod tempor | 907 bla bla incididunt^ | 908 incidid{114: incididunt }{115: }d{10:ol}ore magna aliqua. | 909 Ut enim{4: ut }{114: } quis nostrud | 910 exercit{4: labore }{114: }oris nisi ut aliquip ex | 911 {3:[No Nam}{4: et }{114: }{3: }| 912 Lorem i{4: dolore }{114: }et, consectetur | 913 adipisi{4: magna }{114: } eiusmod tempor | 914 bla bla{4: aliqua }{114: } | 915 incidid{4: Ut }{114: }d{10:ol}ore magna aliqua. | 916 Ut enim{4: enim }{114: } quis nostrud | 917 {2:[No Nam}{4: ad }{114: }{2: }| 918 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 919 ]]) 920 921 command('set pumblend=50') 922 screen:expect([[ 923 Lorem ipsum d{10:ol}or sit amet, consectetur | 924 adipisicing elit, sed do eiusmod tempor | 925 bla bla incididunt^ | 926 incidid{116:u}{117:incididunt}{116:re et}{118: }d{10:ol}ore magna aliqua. | 927 Ut enim{119: }{120:ut}{119: minim veniam}{116:,} quis nostrud | 928 exercit{119:a}{120:labore}{119:llamco la}{116:b}oris nisi ut aliquip ex | 929 {3:[No Nam}{121:e}{137:et}{121:[+] }{124: }{3: }| 930 Lorem i{119:p}{120:dolor}{125:e}{126:l}{119:or sit a}{116:m}et, consectetur | 931 adipisi{119:c}{120:magn}{145:a}{128:l}{119:it, sed d}{116:o} eiusmod tempor | 932 bla bla{119: }{120:aliqua}{119:dunt }{116: } | 933 incidid{119:u}{120:Ut}{119: }{129:ut}{119: labore et}{116: }d{10:ol}ore magna aliqua. | 934 Ut enim{119: }{120:enim}{119:inim veniam}{116:,} quis nostrud | 935 {2:[No Nam}{130:e}{137:ad}{130:[+] }{132: }{2: }| 936 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 937 ]]) 938 939 api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) 940 screen:expect([[ 941 Lorem ipsum d{10:ol}or sit amet, consectetur | 942 adipisicing elit, sed do eiusmod tempor | 943 bla bla incididunt^ | 944 incidid{116:u}{117:incididunt}{116:re et}{118: }d{10:ol}ore magna aliqua. | 945 Ut enim{119: }{120:ut}{119: minim veniam}{116:,} quis nostrud | 946 exercit{119:a}{120:labore}{119:llamco la}{116:b}oris nisi ut aliquip ex | 947 {3:[No Nam}{121:e}{137:et}{121:[+] }{124: }{3: }| 948 incidid{119:u}{120:dol}{134:or}{120:e}{119:labore et}{116: }d{10:ol}ore magna aliqua. | 949 Ut enim{119: }{120:magna}{119:nim veniam}{116:,} quis nostrud | 950 exercit{119:a}{120:aliqua}{119:llamco la}{116:b}oris nisi {18:ut} aliquip ex | 951 ea comm{119:o}{120:Ut}{119: consequat. D}{116:u}is a{18:ut}e irure d{10:ol}or in | 952 reprehe{119:n}{120:enim}{119:t in v}{126:ol}{119:upt}{116:a}te v{15:el}it esse cillum | 953 {2:[No Nam}{130:e}{137:ad}{130:[+] }{132: }{2: }| 954 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 955 ]]) 956 957 -- can disable blending for individual attribute. For instance current 958 -- selected item. (also tests that `hi Pmenu*` take immediate effect) 959 command('hi PMenuSel blend=0') 960 screen:expect([[ 961 Lorem ipsum d{10:ol}or sit amet, consectetur | 962 adipisicing elit, sed do eiusmod tempor | 963 bla bla incididunt^ | 964 incidid{138: incididunt }{118: }d{10:ol}ore magna aliqua. | 965 Ut enim{119: }{120:ut}{119: minim veniam}{116:,} quis nostrud | 966 exercit{119:a}{120:labore}{119:llamco la}{116:b}oris nisi ut aliquip ex | 967 {3:[No Nam}{121:e}{137:et}{121:[+] }{124: }{3: }| 968 incidid{119:u}{120:dol}{134:or}{120:e}{119:labore et}{116: }d{10:ol}ore magna aliqua. | 969 Ut enim{119: }{120:magna}{119:nim veniam}{116:,} quis nostrud | 970 exercit{119:a}{120:aliqua}{119:llamco la}{116:b}oris nisi {18:ut} aliquip ex | 971 ea comm{119:o}{120:Ut}{119: consequat. D}{116:u}is a{18:ut}e irure d{10:ol}or in | 972 reprehe{119:n}{120:enim}{119:t in v}{126:ol}{119:upt}{116:a}te v{15:el}it esse cillum | 973 {2:[No Nam}{130:e}{137:ad}{130:[+] }{132: }{2: }| 974 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 975 ]]) 976 977 feed('<c-e>') 978 screen:expect([[ 979 Lorem ipsum d{10:ol}or sit amet, consectetur | 980 adipisicing elit, sed do eiusmod tempor | 981 bla bla ^ | 982 incididunt ut labore et d{10:ol}ore magna aliqua. | 983 Ut enim ad minim veniam, quis nostrud | 984 exercitation ullamco laboris nisi ut aliquip ex | 985 {3:[No Name] [+] }| 986 incididunt {18:ut} labore et d{10:ol}ore magna aliqua. | 987 Ut enim ad minim veniam, quis nostrud | 988 exercitation ullamco laboris nisi {18:ut} aliquip ex | 989 ea commodo consequat. Duis a{18:ut}e irure d{10:ol}or in | 990 reprehenderit in v{10:ol}uptate v{15:el}it esse cillum | 991 {2:[No Name] [+] }| 992 {5:-- INSERT --} | 993 ]]) 994 end) 995 996 it('256-color (non-RGB)', function() 997 screen._options.rgb = false 998 command('set pumblend=10') 999 insert([[ 1000 Lorem ipsum dolor sit amet, consectetur 1001 adipisicing elit, sed do eiusmod tempor 1002 incididunt ut labore et dolore magna aliqua. 1003 Ut enim ad minim veniam, quis nostrud 1004 laborum.]]) 1005 1006 feed('ggOdo<c-x><c-n>') 1007 screen:expect([[ 1008 dolor^ | 1009 {139:dolor}{140: ipsum dol}or sit amet, consectetur | 1010 {141:do}{142:ipisicing eli}t, sed do eiusmod tempor | 1011 {141:dolore}{142:dunt ut l}abore et dolore magna aliqua. | 1012 Ut enim ad minim veniam, quis nostrud | 1013 laborum. | 1014 {143:~ }|*7 1015 {5:-- Keyword Local completion (^N^P) }{144:match 1 of 3} | 1016 ]]) 1017 end) 1018 end) 1019 1020 describe('builtin popupmenu', function() 1021 before_each(clear) 1022 1023 local function with_ext_multigrid(multigrid, send_mouse_grid) 1024 local screen 1025 before_each(function() 1026 screen = Screen.new(32, 20, { ext_multigrid = multigrid }) 1027 screen:add_extra_attr_ids({ 1028 [100] = { foreground = Screen.colors.Yellow, background = Screen.colors.Green }, 1029 [101] = { foreground = Screen.colors.White, background = Screen.colors.Green }, 1030 [102] = { foreground = Screen.colors.Brown, bold = true, background = Screen.colors.Plum1 }, 1031 [103] = { foreground = Screen.colors.DarkCyan, background = Screen.colors.Plum1 }, 1032 [104] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Plum1 }, 1033 [105] = { foreground = Screen.colors.Magenta1, background = Screen.colors.Plum1 }, 1034 [106] = { 1035 foreground = Screen.colors.Red, 1036 italic = true, 1037 background = Screen.colors.Gray, 1038 strikethrough = true, 1039 underline = true, 1040 }, 1041 [107] = { 1042 background = Screen.colors.Grey100, 1043 foreground = Screen.colors.Black, 1044 italic = true, 1045 bold = true, 1046 underline = true, 1047 strikethrough = true, 1048 }, 1049 [108] = { 1050 italic = true, 1051 background = Screen.colors.Gray, 1052 underline = true, 1053 foreground = Screen.colors.Grey100, 1054 }, 1055 [109] = { 1056 foreground = Screen.colors.Yellow, 1057 italic = true, 1058 bold = true, 1059 underline = true, 1060 background = Screen.colors.Pink, 1061 }, 1062 [110] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkYellow }, 1063 [111] = { background = Screen.colors.Plum1, foreground = Screen.colors.DarkBlue }, 1064 [112] = { background = Screen.colors.Plum1, foreground = Screen.colors.DarkGreen }, 1065 [113] = { background = Screen.colors.Yellow, foreground = Screen.colors.Black }, 1066 [114] = { background = Screen.colors.Black, blend = 100 }, 1067 [115] = { background = Screen.colors.Black, blend = 80 }, 1068 [116] = { foreground = Screen.colors.Black }, 1069 [117] = { background = Screen.colors.Grey80, foreground = Screen.colors.Black }, 1070 -- popup non-selected item 1071 n = { background = Screen.colors.Plum1 }, 1072 -- popup scrollbar knob 1073 c = { background = Screen.colors.Black }, 1074 ks = { foreground = Screen.colors.Red, background = Screen.colors.Grey }, 1075 kn = { foreground = Screen.colors.Red, background = Screen.colors.Plum1 }, 1076 xs = { foreground = Screen.colors.Black, background = Screen.colors.Grey }, 1077 xn = { foreground = Screen.colors.White, background = Screen.colors.Plum1 }, 1078 ms = { foreground = Screen.colors.Blue, background = Screen.colors.Grey }, 1079 mn = { foreground = Screen.colors.Blue, background = Screen.colors.Plum1 }, 1080 ds = { foreground = Screen.colors.DarkRed, background = Screen.colors.Grey }, 1081 dn = { foreground = Screen.colors.DarkRed, background = Screen.colors.Plum1 }, 1082 ums = { 1083 foreground = Screen.colors.Blue, 1084 background = Screen.colors.Grey, 1085 underline = true, 1086 }, 1087 umn = { 1088 foreground = Screen.colors.Blue, 1089 background = Screen.colors.Plum1, 1090 underline = true, 1091 }, 1092 uds = { 1093 foreground = Screen.colors.DarkRed, 1094 background = Screen.colors.Grey, 1095 underline = true, 1096 }, 1097 udn = { 1098 foreground = Screen.colors.DarkRed, 1099 background = Screen.colors.Plum1, 1100 underline = true, 1101 }, 1102 }) 1103 end) 1104 1105 it('with preview-window above', function() 1106 feed(':ped<CR><c-w>4+') 1107 feed('iaa bb cc dd ee ff gg hh ii jj<cr>') 1108 feed('<c-x><c-n>') 1109 if multigrid then 1110 screen:expect { 1111 grid = [[ 1112 ## grid 1 1113 [4:--------------------------------]|*8 1114 {2:[No Name] [Preview][+] }| 1115 [2:--------------------------------]|*9 1116 {3:[No Name] [+] }| 1117 [3:--------------------------------]| 1118 ## grid 2 1119 aa bb cc dd ee ff gg hh ii jj | 1120 aa^ | 1121 {1:~ }|*7 1122 ## grid 3 1123 {5:-- }{6:match 1 of 10} | 1124 ## grid 4 1125 aa bb cc dd ee ff gg hh ii jj | 1126 aa | 1127 {1:~ }|*6 1128 ## grid 5 1129 {12:aa }{c: }| 1130 {n:bb }{c: }| 1131 {n:cc }{c: }| 1132 {n:dd }{c: }| 1133 {n:ee }{c: }| 1134 {n:ff }{c: }| 1135 {n:gg }{12: }| 1136 {n:hh }{12: }| 1137 ]], 1138 float_pos = { [5] = { -1, 'NW', 2, 2, 0, false, 100, 1, 11, 0 } }, 1139 } 1140 else 1141 screen:expect([[ 1142 aa bb cc dd ee ff gg hh ii jj | 1143 aa | 1144 {1:~ }|*6 1145 {2:[No Name] [Preview][+] }| 1146 aa bb cc dd ee ff gg hh ii jj | 1147 aa^ | 1148 {12:aa }{c: }{1: }| 1149 {n:bb }{c: }{1: }| 1150 {n:cc }{c: }{1: }| 1151 {n:dd }{c: }{1: }| 1152 {n:ee }{c: }{1: }| 1153 {n:ff }{c: }{1: }| 1154 {n:gg }{12: }{1: }| 1155 {n:hh }{12: }{3: }| 1156 {5:-- }{6:match 1 of 10} | 1157 ]]) 1158 end 1159 end) 1160 1161 it('with preview-window below', function() 1162 feed(':ped<CR><c-w>4+<c-w>r') 1163 feed('iaa bb cc dd ee ff gg hh ii jj<cr>') 1164 feed('<c-x><c-n>') 1165 if multigrid then 1166 screen:expect { 1167 grid = [[ 1168 ## grid 1 1169 [2:--------------------------------]|*9 1170 {3:[No Name] [+] }| 1171 [4:--------------------------------]|*8 1172 {2:[No Name] [Preview][+] }| 1173 [3:--------------------------------]| 1174 ## grid 2 1175 aa bb cc dd ee ff gg hh ii jj | 1176 aa^ | 1177 {1:~ }|*7 1178 ## grid 3 1179 {5:-- }{6:match 1 of 10} | 1180 ## grid 4 1181 aa bb cc dd ee ff gg hh ii jj | 1182 aa | 1183 {1:~ }|*6 1184 ## grid 5 1185 {12:aa }{c: }| 1186 {n:bb }{c: }| 1187 {n:cc }{c: }| 1188 {n:dd }{c: }| 1189 {n:ee }{c: }| 1190 {n:ff }{c: }| 1191 {n:gg }{12: }| 1192 {n:hh }{12: }| 1193 ]], 1194 float_pos = { [5] = { -1, 'NW', 2, 2, 0, false, 100, 1, 2, 0 } }, 1195 } 1196 else 1197 screen:expect([[ 1198 aa bb cc dd ee ff gg hh ii jj | 1199 aa^ | 1200 {12:aa }{c: }{1: }| 1201 {n:bb }{c: }{1: }| 1202 {n:cc }{c: }{1: }| 1203 {n:dd }{c: }{1: }| 1204 {n:ee }{c: }{1: }| 1205 {n:ff }{c: }{1: }| 1206 {n:gg }{12: }{1: }| 1207 {n:hh }{12: }{3: }| 1208 aa bb cc dd ee ff gg hh ii jj | 1209 aa | 1210 {1:~ }|*6 1211 {2:[No Name] [Preview][+] }| 1212 {5:-- }{6:match 1 of 10} | 1213 ]]) 1214 end 1215 end) 1216 1217 it('with preview-window above, tall and inverted', function() 1218 feed(':ped<CR><c-w>8+') 1219 feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>') 1220 feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>') 1221 feed('kk<cr>ll<cr>mm<cr>nn<cr>oo<cr>') 1222 feed('<c-x><c-n>') 1223 if multigrid then 1224 screen:expect { 1225 grid = [[ 1226 ## grid 1 1227 [4:--------------------------------]|*4 1228 {2:[No Name] [Preview][+] }| 1229 [2:--------------------------------]|*13 1230 {3:[No Name] [+] }| 1231 [3:--------------------------------]| 1232 ## grid 2 1233 dd | 1234 ee | 1235 ff | 1236 gg | 1237 hh | 1238 ii | 1239 jj | 1240 kk | 1241 ll | 1242 mm | 1243 nn | 1244 oo | 1245 aa^ | 1246 ## grid 3 1247 {5:-- }{6:match 1 of 15} | 1248 ## grid 4 1249 aa | 1250 bb | 1251 cc | 1252 dd | 1253 ## grid 5 1254 {12:aa }{c: }| 1255 {n:bb }{c: }| 1256 {n:cc }{c: }| 1257 {n:dd }{c: }| 1258 {n:ee }{c: }| 1259 {n:ff }{c: }| 1260 {n:gg }{c: }| 1261 {n:hh }{c: }| 1262 {n:ii }{c: }| 1263 {n:jj }{c: }| 1264 {n:kk }{c: }| 1265 {n:ll }{12: }| 1266 {n:mm }{12: }| 1267 ]], 1268 float_pos = { [5] = { -1, 'SW', 2, 12, 0, false, 100, 1, 4, 0 } }, 1269 } 1270 else 1271 screen:expect([[ 1272 aa | 1273 bb | 1274 cc | 1275 dd | 1276 {12:aa }{c: }{2:ew][+] }| 1277 {n:bb }{c: } | 1278 {n:cc }{c: } | 1279 {n:dd }{c: } | 1280 {n:ee }{c: } | 1281 {n:ff }{c: } | 1282 {n:gg }{c: } | 1283 {n:hh }{c: } | 1284 {n:ii }{c: } | 1285 {n:jj }{c: } | 1286 {n:kk }{c: } | 1287 {n:ll }{12: } | 1288 {n:mm }{12: } | 1289 aa^ | 1290 {3:[No Name] [+] }| 1291 {5:-- }{6:match 1 of 15} | 1292 ]]) 1293 end 1294 end) 1295 1296 it('with preview-window above, short and inverted', function() 1297 feed(':ped<CR><c-w>4+') 1298 feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>') 1299 feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>') 1300 feed('<c-x><c-n>') 1301 if multigrid then 1302 screen:expect { 1303 grid = [[ 1304 ## grid 1 1305 [4:--------------------------------]|*8 1306 {2:[No Name] [Preview][+] }| 1307 [2:--------------------------------]|*9 1308 {3:[No Name] [+] }| 1309 [3:--------------------------------]| 1310 ## grid 2 1311 cc | 1312 dd | 1313 ee | 1314 ff | 1315 gg | 1316 hh | 1317 ii | 1318 jj | 1319 aa^ | 1320 ## grid 3 1321 {5:-- }{6:match 1 of 10} | 1322 ## grid 4 1323 aa | 1324 bb | 1325 cc | 1326 dd | 1327 ee | 1328 ff | 1329 gg | 1330 hh | 1331 ## grid 5 1332 {12:aa }{c: }| 1333 {n:bb }{c: }| 1334 {n:cc }{c: }| 1335 {n:dd }{c: }| 1336 {n:ee }{c: }| 1337 {n:ff }{c: }| 1338 {n:gg }{c: }| 1339 {n:hh }{c: }| 1340 {n:ii }{12: }| 1341 ]], 1342 float_pos = { [5] = { -1, 'SW', 2, 8, 0, false, 100, 1, 8, 0 } }, 1343 } 1344 else 1345 screen:expect([[ 1346 aa | 1347 bb | 1348 cc | 1349 dd | 1350 ee | 1351 ff | 1352 gg | 1353 hh | 1354 {12:aa }{c: }{2:ew][+] }| 1355 {n:bb }{c: } | 1356 {n:cc }{c: } | 1357 {n:dd }{c: } | 1358 {n:ee }{c: } | 1359 {n:ff }{c: } | 1360 {n:gg }{c: } | 1361 {n:hh }{c: } | 1362 {n:ii }{12: } | 1363 aa^ | 1364 {3:[No Name] [+] }| 1365 {5:-- }{6:match 1 of 10} | 1366 ]]) 1367 end 1368 end) 1369 1370 it('with preview-window below, inverted', function() 1371 feed(':ped<CR><c-w>4+<c-w>r') 1372 feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>') 1373 feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>') 1374 feed('<c-x><c-n>') 1375 if multigrid then 1376 screen:expect { 1377 grid = [[ 1378 ## grid 1 1379 [2:--------------------------------]|*9 1380 {3:[No Name] [+] }| 1381 [4:--------------------------------]|*8 1382 {2:[No Name] [Preview][+] }| 1383 [3:--------------------------------]| 1384 ## grid 2 1385 cc | 1386 dd | 1387 ee | 1388 ff | 1389 gg | 1390 hh | 1391 ii | 1392 jj | 1393 aa^ | 1394 ## grid 3 1395 {5:-- }{6:match 1 of 10} | 1396 ## grid 4 1397 aa | 1398 bb | 1399 cc | 1400 dd | 1401 ee | 1402 ff | 1403 gg | 1404 hh | 1405 ## grid 5 1406 {12:aa }{c: }| 1407 {n:bb }{c: }| 1408 {n:cc }{c: }| 1409 {n:dd }{c: }| 1410 {n:ee }{c: }| 1411 {n:ff }{c: }| 1412 {n:gg }{12: }| 1413 {n:hh }{12: }| 1414 ]], 1415 float_pos = { [5] = { -1, 'SW', 2, 8, 0, false, 100, 1, 0, 0 } }, 1416 } 1417 else 1418 screen:expect([[ 1419 {12:aa }{c: } | 1420 {n:bb }{c: } | 1421 {n:cc }{c: } | 1422 {n:dd }{c: } | 1423 {n:ee }{c: } | 1424 {n:ff }{c: } | 1425 {n:gg }{12: } | 1426 {n:hh }{12: } | 1427 aa^ | 1428 {3:[No Name] [+] }| 1429 aa | 1430 bb | 1431 cc | 1432 dd | 1433 ee | 1434 ff | 1435 gg | 1436 hh | 1437 {2:[No Name] [Preview][+] }| 1438 {5:-- }{6:match 1 of 10} | 1439 ]]) 1440 end 1441 end) 1442 1443 describe('popup and preview window do not overlap', function() 1444 before_each(function() 1445 screen:try_resize(53, 20) 1446 end) 1447 1448 -- oldtest: Test_popup_and_previewwindow_dump_pedit() 1449 it('with :pedit', function() 1450 exec([[ 1451 set previewheight=9 1452 silent! pedit 1453 call setline(1, map(repeat(["ab"], 10), "v:val .. v:key")) 1454 exec "norm! G\<C-E>\<C-E>" 1455 ]]) 1456 feed('o') 1457 n.poke_eventloop() 1458 feed('<C-X><C-N>') 1459 if multigrid then 1460 screen:expect({ 1461 grid = [[ 1462 ## grid 1 1463 [4:-----------------------------------------------------]|*9 1464 {2:[No Name] [Preview][+] }| 1465 [2:-----------------------------------------------------]|*8 1466 {3:[No Name] [+] }| 1467 [3:-----------------------------------------------------]| 1468 ## grid 2 1469 ab4 | 1470 ab5 | 1471 ab6 | 1472 ab7 | 1473 ab8 | 1474 ab9 | 1475 ab0^ | 1476 {1:~ }| 1477 ## grid 3 1478 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 10} | 1479 ## grid 4 1480 ab0 | 1481 ab1 | 1482 ab2 | 1483 ab3 | 1484 ab4 | 1485 ab5 | 1486 ab6 | 1487 ab7 | 1488 ab8 | 1489 ## grid 5 1490 {12:ab0 }{c: }| 1491 {n:ab1 }{c: }| 1492 {n:ab2 }{c: }| 1493 {n:ab3 }{c: }| 1494 {n:ab4 }{12: }| 1495 {n:ab5 }{12: }| 1496 {n:ab6 }{12: }| 1497 ]], 1498 float_pos = { [5] = { -1, 'SW', 2, 6, 0, false, 100, 1, 9, 0 } }, 1499 }) 1500 else 1501 screen:expect([[ 1502 ab0 | 1503 ab1 | 1504 ab2 | 1505 ab3 | 1506 ab4 | 1507 ab5 | 1508 ab6 | 1509 ab7 | 1510 ab8 | 1511 {12:ab0 }{c: }{2:ew][+] }| 1512 {n:ab1 }{c: } | 1513 {n:ab2 }{c: } | 1514 {n:ab3 }{c: } | 1515 {n:ab4 }{12: } | 1516 {n:ab5 }{12: } | 1517 {n:ab6 }{12: } | 1518 ab0^ | 1519 {1:~ }| 1520 {3:[No Name] [+] }| 1521 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 10} | 1522 ]]) 1523 end 1524 end) 1525 1526 -- oldtest: Test_popup_and_previewwindow_dump_pbuffer() 1527 it('with :pbuffer', function() 1528 exec([[ 1529 set previewheight=9 1530 silent! pbuffer 1531 call setline(1, map(repeat(["ab"], 10), "v:val .. v:key")) 1532 exec "norm! G\<C-E>\<C-E>\<C-E>" 1533 ]]) 1534 feed('o') 1535 n.poke_eventloop() 1536 feed('<C-X><C-N>') 1537 if multigrid then 1538 screen:expect({ 1539 grid = [[ 1540 ## grid 1 1541 [4:-----------------------------------------------------]|*9 1542 {2:[No Name] [Preview][+] }| 1543 [2:-----------------------------------------------------]|*8 1544 {3:[No Name] [+] }| 1545 [3:-----------------------------------------------------]| 1546 ## grid 2 1547 ab5 | 1548 ab6 | 1549 ab7 | 1550 ab8 | 1551 ab9 | 1552 ab0^ | 1553 {1:~ }|*2 1554 ## grid 3 1555 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 10} | 1556 ## grid 4 1557 ab0 | 1558 ab1 | 1559 ab2 | 1560 ab3 | 1561 ab4 | 1562 ab5 | 1563 ab6 | 1564 ab7 | 1565 ab8 | 1566 ## grid 5 1567 {12:ab0 }{c: }| 1568 {n:ab1 }{c: }| 1569 {n:ab2 }{c: }| 1570 {n:ab3 }{12: }| 1571 {n:ab4 }{12: }| 1572 {n:ab5 }{12: }| 1573 ]], 1574 float_pos = { [5] = { -1, 'SW', 2, 5, 0, false, 100, 1, 9, 0 } }, 1575 }) 1576 else 1577 screen:expect([[ 1578 ab0 | 1579 ab1 | 1580 ab2 | 1581 ab3 | 1582 ab4 | 1583 ab5 | 1584 ab6 | 1585 ab7 | 1586 ab8 | 1587 {12:ab0 }{c: }{2:ew][+] }| 1588 {n:ab1 }{c: } | 1589 {n:ab2 }{c: } | 1590 {n:ab3 }{12: } | 1591 {n:ab4 }{12: } | 1592 {n:ab5 }{12: } | 1593 ab0^ | 1594 {1:~ }|*2 1595 {3:[No Name] [+] }| 1596 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 10} | 1597 ]]) 1598 end 1599 end) 1600 end) 1601 1602 -- oldtest: Test_pum_with_preview_win() 1603 it('preview window opened during completion', function() 1604 exec([[ 1605 funct Omni_test(findstart, base) 1606 if a:findstart 1607 return col(".") - 1 1608 endif 1609 return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}] 1610 endfunc 1611 set omnifunc=Omni_test 1612 set completeopt-=popup completeopt+=longest,preview 1613 ]]) 1614 feed('Gi<C-X><C-O>') 1615 if multigrid then 1616 screen:expect({ 1617 grid = [[ 1618 ## grid 1 1619 [2:--------------------------------]|*19 1620 [3:--------------------------------]| 1621 ## grid 2 1622 ^ | 1623 {1:~ }|*18 1624 ## grid 3 1625 {5:-- }{19:Back at original} | 1626 ## grid 4 1627 {n:one }| 1628 {n:two }| 1629 {n:three }| 1630 ]], 1631 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 1632 }) 1633 else 1634 screen:expect([[ 1635 ^ | 1636 {n:one }{1: }| 1637 {n:two }{1: }| 1638 {n:three }{1: }| 1639 {1:~ }|*15 1640 {5:-- }{19:Back at original} | 1641 ]]) 1642 end 1643 feed('<C-N>') 1644 if multigrid then 1645 screen:expect({ 1646 grid = [[ 1647 ## grid 1 1648 [5:--------------------------------]|*3 1649 {2:[Scratch] [Preview][-] }| 1650 [2:--------------------------------]|*14 1651 {3:[No Name] [+] }| 1652 [3:--------------------------------]| 1653 ## grid 2 1654 one^ | 1655 {1:~ }|*13 1656 ## grid 3 1657 {5:-- }{6:match 1 of 3} | 1658 ## grid 4 1659 {12:one }| 1660 {n:two }| 1661 {n:three }| 1662 ## grid 5 1663 1info | 1664 {1:~ }|*2 1665 ]], 1666 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 5, 0 } }, 1667 }) 1668 else 1669 screen:expect([[ 1670 1info | 1671 {1:~ }|*2 1672 {2:[Scratch] [Preview][-] }| 1673 one^ | 1674 {12:one }{1: }| 1675 {n:two }{1: }| 1676 {n:three }{1: }| 1677 {1:~ }|*10 1678 {3:[No Name] [+] }| 1679 {5:-- }{6:match 1 of 3} | 1680 ]]) 1681 end 1682 end) 1683 1684 -- oldtest: Test_scrollbar_on_wide_char() 1685 it('scrollbar overwrites half of double-width char below properly', function() 1686 screen:try_resize(32, 10) 1687 exec([[ 1688 call setline(1, ['a', ' 啊啊啊', 1689 \ ' 哦哦哦', 1690 \ ' 呃呃呃']) 1691 call setline(5, range(10)->map({i, v -> 'aa' .. v .. 'bb'})) 1692 ]]) 1693 feed('A<C-X><C-N>') 1694 if multigrid then 1695 screen:expect({ 1696 grid = [[ 1697 ## grid 1 1698 [2:--------------------------------]|*9 1699 [3:--------------------------------]| 1700 ## grid 2 1701 aa0bb^ | 1702 啊啊啊 | 1703 哦哦哦 | 1704 呃呃呃 | 1705 aa0bb | 1706 aa1bb | 1707 aa2bb | 1708 aa3bb | 1709 aa4bb | 1710 ## grid 3 1711 {5:-- }{6:match 1 of 10} | 1712 ## grid 4 1713 {12:aa0bb }{c: }| 1714 {n:aa1bb }{c: }| 1715 {n:aa2bb }{c: }| 1716 {n:aa3bb }{c: }| 1717 {n:aa4bb }{c: }| 1718 {n:aa5bb }{c: }| 1719 {n:aa6bb }{12: }| 1720 {n:aa7bb }{12: }| 1721 ]], 1722 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 1723 }) 1724 else 1725 screen:expect([[ 1726 aa0bb^ | 1727 {12:aa0bb }{c: }啊 | 1728 {n:aa1bb }{c: } 哦 | 1729 {n:aa2bb }{c: }呃呃 | 1730 {n:aa3bb }{c: } | 1731 {n:aa4bb }{c: } | 1732 {n:aa5bb }{c: } | 1733 {n:aa6bb }{12: } | 1734 {n:aa7bb }{12: } | 1735 {5:-- }{6:match 1 of 10} | 1736 ]]) 1737 end 1738 end) 1739 1740 describe('completeopt=popup shows preview in floatwin', function() 1741 before_each(function() 1742 --row must > 10 1743 screen:try_resize(40, 11) 1744 exec([[ 1745 let g:list = [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "looooooooooooooong"}] 1746 let g:bufnrs = [] 1747 funct Omni_test(findstart, base) 1748 if a:findstart 1749 return col(".") - 1 1750 endif 1751 return g:list 1752 endfunc 1753 set omnifunc=Omni_test 1754 set completeopt=menu,popup 1755 funct Set_info() 1756 let comp_info = complete_info() 1757 if get(comp_info, 'preview_bufnr', 0) > 0 1758 call add(g:bufnrs, comp_info['preview_bufnr']) 1759 endif 1760 if comp_info['selected'] == 2 1761 call nvim__complete_set(comp_info['selected'], {"info": "3info"}) 1762 endif 1763 endfunc 1764 funct TsHl() 1765 let comp_info = complete_info(['selected']) 1766 if get(comp_info, 'preview_bufnr', 0) > 0 1767 call v:lua.vim.treesitter.start(comp_info['preview_bufnr'], 'markdown') 1768 endif 1769 if comp_info['selected'] == 0 1770 call nvim__complete_set(comp_info['selected'], {"info": "```lua\nfunction test()\n print('foo')\nend\n```"}) 1771 endif 1772 endfunc 1773 augroup Group 1774 au! 1775 autocmd CompleteChanged * :call Set_info() 1776 augroup END 1777 funct TestTs() 1778 autocmd! Group 1779 autocmd CompleteChanged * call TsHl() 1780 endfunc 1781 funct Append_multipe() 1782 call extend(g:list, [#{word: "for .. ipairs", info: "```lua\nfor index, value in ipairs(t) do\n\t\nend\n```"}]) 1783 endfunc 1784 ]]) 1785 end) 1786 1787 it('pum popup preview', function() 1788 feed('Gi<C-x><C-o>') 1789 --floating preview in right 1790 if multigrid then 1791 screen:expect({ 1792 grid = [[ 1793 ## grid 1 1794 [2:----------------------------------------]|*10 1795 [3:----------------------------------------]| 1796 ## grid 2 1797 one^ | 1798 {1:~ }|*9 1799 ## grid 3 1800 {5:-- }{6:match 1 of 3} | 1801 ## grid 4 1802 {n:1info}| 1803 ## grid 5 1804 {12:one }| 1805 {n:two }| 1806 {n:looooooooooooooong }| 1807 ]], 1808 win_pos = { [2] = { height = 10, startcol = 0, startrow = 0, width = 40, win = 1000 } }, 1809 float_pos = { 1810 [5] = { -1, 'NW', 2, 1, 0, false, 100, 2, 1, 0 }, 1811 [4] = { 1001, 'NW', 1, 1, 19, false, 50, 1, 1, 19 }, 1812 }, 1813 win_viewport = { 1814 [2] = { 1815 win = 1000, 1816 topline = 0, 1817 botline = 2, 1818 curline = 0, 1819 curcol = 3, 1820 linecount = 1, 1821 sum_scroll_delta = 0, 1822 }, 1823 [4] = { 1824 win = 1001, 1825 topline = 0, 1826 botline = 1, 1827 curline = 0, 1828 curcol = 0, 1829 linecount = 1, 1830 sum_scroll_delta = 0, 1831 }, 1832 }, 1833 win_viewport_margins = { 1834 [2] = { bottom = 0, left = 0, right = 0, top = 0, win = 1000 }, 1835 [4] = { bottom = 0, left = 0, right = 0, top = 0, win = 1001 }, 1836 }, 1837 }) 1838 else 1839 screen:expect([[ 1840 one^ | 1841 {12:one }{n:1info}{1: }| 1842 {n:two }{1: }| 1843 {n:looooooooooooooong }{1: }| 1844 {1:~ }|*6 1845 {5:-- }{6:match 1 of 3} | 1846 ]]) 1847 end 1848 1849 -- delete one character make the pum width smaller than before 1850 -- info window position should be adjusted when popupmenu width changed 1851 feed('<BS>') 1852 if multigrid then 1853 screen:expect({ 1854 grid = [[ 1855 ## grid 1 1856 [2:----------------------------------------]|*10 1857 [3:----------------------------------------]| 1858 ## grid 2 1859 on^ | 1860 {1:~ }|*9 1861 ## grid 3 1862 {5:-- }{6:match 1 of 3} | 1863 ## grid 4 1864 {n:1info}| 1865 ## grid 5 1866 {12:one }| 1867 ]], 1868 win_pos = { [2] = { height = 10, startcol = 0, startrow = 0, width = 40, win = 1000 } }, 1869 float_pos = { 1870 [5] = { -1, 'NW', 2, 1, 0, false, 100, 2, 1, 0 }, 1871 [4] = { 1001, 'NW', 1, 1, 15, false, 50, 1, 1, 15 }, 1872 }, 1873 win_viewport = { 1874 [2] = { 1875 win = 1000, 1876 topline = 0, 1877 botline = 2, 1878 curline = 0, 1879 curcol = 2, 1880 linecount = 1, 1881 sum_scroll_delta = 0, 1882 }, 1883 [4] = { 1884 win = 1001, 1885 topline = 0, 1886 botline = 1, 1887 curline = 0, 1888 curcol = 0, 1889 linecount = 1, 1890 sum_scroll_delta = 0, 1891 }, 1892 }, 1893 win_viewport_margins = { 1894 [2] = { bottom = 0, left = 0, right = 0, top = 0, win = 1000 }, 1895 [4] = { bottom = 0, left = 0, right = 0, top = 0, win = 1001 }, 1896 }, 1897 }) 1898 else 1899 screen:expect([[ 1900 on^ | 1901 {12:one }{n:1info}{1: }| 1902 {1:~ }|*8 1903 {5:-- }{6:match 1 of 3} | 1904 ]]) 1905 end 1906 1907 -- when back to original the preview float should be closed. 1908 feed('<C-P>') 1909 if multigrid then 1910 screen:expect({ 1911 grid = [[ 1912 ## grid 1 1913 [2:----------------------------------------]|*10 1914 [3:----------------------------------------]| 1915 ## grid 2 1916 on^ | 1917 {1:~ }|*9 1918 ## grid 3 1919 {5:-- }{19:Back at original} | 1920 ## grid 4 (hidden) 1921 {n:1info}| 1922 ## grid 5 1923 {n:one }| 1924 ]], 1925 win_pos = { [2] = { height = 10, startcol = 0, startrow = 0, width = 40, win = 1000 } }, 1926 float_pos = { [5] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 1927 win_viewport = { 1928 [2] = { 1929 win = 1000, 1930 topline = 0, 1931 botline = 2, 1932 curline = 0, 1933 curcol = 2, 1934 linecount = 1, 1935 sum_scroll_delta = 0, 1936 }, 1937 [4] = { 1938 win = 1001, 1939 topline = 0, 1940 botline = 1, 1941 curline = 0, 1942 curcol = 0, 1943 linecount = 1, 1944 sum_scroll_delta = 0, 1945 }, 1946 }, 1947 win_viewport_margins = { 1948 [2] = { bottom = 0, left = 0, right = 0, top = 0, win = 1000 }, 1949 [4] = { bottom = 0, left = 0, right = 0, top = 0, win = 1001 }, 1950 }, 1951 }) 1952 else 1953 screen:expect([[ 1954 on^ | 1955 {n:one }{1: }| 1956 {1:~ }|*8 1957 {5:-- }{19:Back at original} | 1958 ]]) 1959 end 1960 feed('<C-E><ESC>') 1961 end) 1962 1963 it('nvim__set_complete', function() 1964 feed('S<C-X><C-O><C-N><C-N>') 1965 if multigrid then 1966 screen:expect({ 1967 grid = [[ 1968 ## grid 1 1969 [2:----------------------------------------]|*10 1970 [3:----------------------------------------]| 1971 ## grid 2 1972 looooooooooooooong^ | 1973 {1:~ }|*9 1974 ## grid 3 1975 {5:-- }{6:match 3 of 3} | 1976 ## grid 4 1977 {n:3info}| 1978 ## grid 5 1979 {n:one }| 1980 {n:two }| 1981 {12:looooooooooooooong }| 1982 ]], 1983 win_pos = { [2] = { height = 10, startcol = 0, startrow = 0, width = 40, win = 1000 } }, 1984 float_pos = { 1985 [5] = { -1, 'NW', 2, 1, 0, false, 100, 2, 1, 0 }, 1986 [4] = { 1001, 'NW', 1, 1, 19, false, 50, 1, 1, 19 }, 1987 }, 1988 win_viewport = { 1989 [2] = { 1990 win = 1000, 1991 topline = 0, 1992 botline = 2, 1993 curline = 0, 1994 curcol = 18, 1995 linecount = 1, 1996 sum_scroll_delta = 0, 1997 }, 1998 [4] = { 1999 win = 1001, 2000 topline = 0, 2001 botline = 1, 2002 curline = 0, 2003 curcol = 0, 2004 linecount = 1, 2005 sum_scroll_delta = 0, 2006 }, 2007 }, 2008 win_viewport_margins = { 2009 [2] = { bottom = 0, left = 0, right = 0, top = 0, win = 1000 }, 2010 [4] = { bottom = 0, left = 0, right = 0, top = 0, win = 1001 }, 2011 }, 2012 }) 2013 else 2014 screen:expect([[ 2015 looooooooooooooong^ | 2016 {n:one 3info}{1: }| 2017 {n:two }{1: }| 2018 {12:looooooooooooooong }{1: }| 2019 {1:~ }|*6 2020 {5:-- }{6:match 3 of 3} | 2021 ]]) 2022 end 2023 feed('<C-E><ESC>') 2024 end) 2025 2026 it('popup preview placed to left', function() 2027 insert(('test'):rep(5)) 2028 feed('i<C-x><C-o>') 2029 if multigrid then 2030 screen:expect({ 2031 grid = [[ 2032 ## grid 1 2033 [2:----------------------------------------]|*10 2034 [3:----------------------------------------]| 2035 ## grid 2 2036 testtesttesttesttesone^t | 2037 {1:~ }|*9 2038 ## grid 3 2039 {5:-- }{6:match 1 of 3} | 2040 ## grid 4 2041 {n:1info}| 2042 ## grid 5 2043 {12: one }| 2044 {n: two }| 2045 {n: looooooooooooooong }| 2046 ]], 2047 win_pos = { [2] = { height = 10, startcol = 0, startrow = 0, width = 40, win = 1000 } }, 2048 float_pos = { 2049 [5] = { -1, 'NW', 2, 1, 18, false, 100, 2, 1, 18 }, 2050 [4] = { 1001, 'NW', 1, 1, 13, false, 50, 1, 1, 13 }, 2051 }, 2052 win_viewport = { 2053 [2] = { 2054 win = 1000, 2055 topline = 0, 2056 botline = 2, 2057 curline = 0, 2058 curcol = 22, 2059 linecount = 1, 2060 sum_scroll_delta = 0, 2061 }, 2062 [4] = { 2063 win = 1001, 2064 topline = 0, 2065 botline = 1, 2066 curline = 0, 2067 curcol = 0, 2068 linecount = 1, 2069 sum_scroll_delta = 0, 2070 }, 2071 }, 2072 win_viewport_margins = { 2073 [2] = { bottom = 0, left = 0, right = 0, top = 0, win = 1000 }, 2074 [4] = { bottom = 0, left = 0, right = 0, top = 0, win = 1001 }, 2075 }, 2076 }) 2077 else 2078 screen:expect([[ 2079 testtesttesttesttesone^t | 2080 {1:~ }{n:1info}{12: one }{1: }| 2081 {1:~ }{n: two }{1: }| 2082 {1:~ }{n: looooooooooooooong }{1: }| 2083 {1:~ }|*6 2084 {5:-- }{6:match 1 of 3} | 2085 ]]) 2086 end 2087 feed('<C-E><Esc>') 2088 end) 2089 2090 it('works when scroll with treesitter highlight', function() 2091 command('call TestTs()') 2092 feed('S<C-x><C-o>') 2093 if multigrid then 2094 screen:expect({ 2095 grid = [[ 2096 ## grid 1 2097 [2:----------------------------------------]|*10 2098 [3:----------------------------------------]| 2099 ## grid 2 2100 one^ | 2101 {1:~ }|*9 2102 ## grid 3 2103 {5:-- }{6:match 1 of 3} | 2104 ## grid 4 2105 {mn:```}{102:lua}{n: }| 2106 {102:function}{mn: }{103:test}{104:()}| 2107 {mn: }{104:print(}{105:'foo'}{104:)}{n: }| 2108 {102:end}{n: }| 2109 {mn:```}{n: }| 2110 ## grid 5 2111 {12:one }| 2112 {n:two }| 2113 {n:looooooooooooooong }| 2114 ]], 2115 win_pos = { [2] = { height = 10, startcol = 0, startrow = 0, width = 40, win = 1000 } }, 2116 float_pos = { 2117 [5] = { -1, 'NW', 2, 1, 0, false, 100, 2, 1, 0 }, 2118 [4] = { 1001, 'NW', 1, 1, 19, false, 50, 1, 1, 19 }, 2119 }, 2120 win_viewport = { 2121 [2] = { 2122 win = 1000, 2123 topline = 0, 2124 botline = 2, 2125 curline = 0, 2126 curcol = 3, 2127 linecount = 1, 2128 sum_scroll_delta = 0, 2129 }, 2130 [4] = { 2131 win = 1001, 2132 topline = 0, 2133 botline = 5, 2134 curline = 0, 2135 curcol = 0, 2136 linecount = 5, 2137 sum_scroll_delta = 0, 2138 }, 2139 }, 2140 win_viewport_margins = { 2141 [2] = { bottom = 0, left = 0, right = 0, top = 0, win = 1000 }, 2142 [4] = { bottom = 0, left = 0, right = 0, top = 0, win = 1001 }, 2143 }, 2144 }) 2145 else 2146 screen:expect([[ 2147 one^ | 2148 {12:one }{mn:```}{102:lua}{n: }{1: }| 2149 {n:two }{102:function}{mn: }{103:test}{104:()}{1: }| 2150 {n:looooooooooooooong }{mn: }{104:print(}{105:'foo'}{104:)}{n: }{1: }| 2151 {1:~ }{102:end}{n: }{1: }| 2152 {1:~ }{mn:```}{n: }{1: }| 2153 {1:~ }|*4 2154 {5:-- }{6:match 1 of 3} | 2155 ]]) 2156 end 2157 feed('<C-E><ESC>') 2158 end) 2159 2160 it('avoid modified original info text', function() 2161 command('call Append_multipe()') 2162 feed('S<C-x><C-o><C-P><C-P>') 2163 if multigrid then 2164 screen:expect({ 2165 grid = [[ 2166 ## grid 1 2167 [2:----------------------------------------]|*10 2168 [3:----------------------------------------]| 2169 ## grid 2 2170 for .. ipairs^ | 2171 {1:~ }|*9 2172 ## grid 3 2173 {5:-- }{6:match 1 of 4} | 2174 ## grid 4 2175 {n:one }| 2176 {n:two }| 2177 {n:looooooooooooooong }| 2178 {12:for .. ipairs }| 2179 ## grid 5 2180 {n:```lua }| 2181 {n:for index, value in }| 2182 {n:ipairs(t) do }| 2183 {n: }| 2184 {n:end }| 2185 {n:``` }| 2186 ]], 2187 win_pos = { [2] = { height = 10, startcol = 0, startrow = 0, width = 40, win = 1000 } }, 2188 float_pos = { 2189 [5] = { 1001, 'NW', 1, 1, 19, false, 50, 1, 1, 19 }, 2190 [4] = { -1, 'NW', 2, 1, 0, false, 100, 2, 1, 0 }, 2191 }, 2192 win_viewport = { 2193 [2] = { 2194 win = 1000, 2195 topline = 0, 2196 botline = 2, 2197 curline = 0, 2198 curcol = 13, 2199 linecount = 1, 2200 sum_scroll_delta = 0, 2201 }, 2202 [5] = { 2203 win = 1001, 2204 topline = 0, 2205 botline = 5, 2206 curline = 0, 2207 curcol = 0, 2208 linecount = 5, 2209 sum_scroll_delta = 0, 2210 }, 2211 }, 2212 win_viewport_margins = { 2213 [2] = { bottom = 0, left = 0, right = 0, top = 0, win = 1000 }, 2214 [5] = { bottom = 0, left = 0, right = 0, top = 0, win = 1001 }, 2215 }, 2216 }) 2217 else 2218 screen:expect([[ 2219 for .. ipairs^ | 2220 {n:one ```lua }{1: }| 2221 {n:two for index, value in }{1: }| 2222 {n:looooooooooooooong ipairs(t) do }{1: }| 2223 {12:for .. ipairs }{n: }{1: }| 2224 {1:~ }{n:end }{1: }| 2225 {1:~ }{n:``` }{1: }| 2226 {1:~ }|*3 2227 {5:-- }{6:match 1 of 4} | 2228 ]]) 2229 end 2230 2231 feed('<C-N><C-N><C-N><C-N><C-N>') 2232 if not multigrid then 2233 screen:expect_unchanged() 2234 end 2235 feed('<C-E><ESC>') 2236 end) 2237 2238 it('popup info window reuses bufnr', function() 2239 feed('S<C-x><C-o><C-N>') 2240 eq(1, n.eval([[len(uniq(copy(g:bufnrs))) == 1]])) 2241 end) 2242 2243 it('handles tabs in info width calculation', function() 2244 screen:try_resize(50, 11) 2245 command([[ 2246 set cot+=menuone 2247 let g:list = [#{word: 'class', info: "\tClassName() = default;"}] 2248 ]]) 2249 feed('S<C-x><C-o>') 2250 local info = fn.complete_info() 2251 eq(30, api.nvim_win_get_width(info.preview_winid)) 2252 feed('<ESC>') 2253 exec([[ 2254 setlocal tabstop=1 2255 autocmd ModeChanged *:i ++once call complete(1, [#{word: 'a'}]) 2256 \| call nvim__complete_set(0, #{info: "\tfloob\tfloob"}) 2257 ]]) 2258 feed('i') 2259 info = fn.complete_info() 2260 eq(21, api.nvim_win_get_width(info.preview_winid)) 2261 if not multigrid then 2262 screen:expect([[ 2263 a^s | 2264 {12:a }{n: floob floob}{1: }| 2265 {1:~ }|*8 2266 {5:-- INSERT --} | 2267 ]]) 2268 end 2269 end) 2270 2271 it('hide info window when insufficient space', function() 2272 screen:try_resize(12, 11) 2273 feed('S<C-x><C-o>') 2274 local info = fn.complete_info() 2275 eq(true, api.nvim_win_get_config(info.preview_winid).hide) 2276 end) 2277 2278 it('enables wrap to avoid info text truncation', function() 2279 screen:try_resize(50, 11) 2280 command([[ 2281 set nowrap 2282 set cot+=menuone 2283 let g:list = [#{word: 'class', info: repeat('+', 60)}] 2284 ]]) 2285 feed('S<C-x><C-o>') 2286 local info = fn.complete_info() 2287 eq(2, api.nvim_win_get_config(info.preview_winid).height) 2288 end) 2289 end) 2290 2291 it('with vsplits', function() 2292 screen:try_resize(32, 8) 2293 insert('aaa aab aac\n') 2294 feed(':vsplit<cr>') 2295 if multigrid then 2296 screen:expect([[ 2297 ## grid 1 2298 [4:--------------------]│[2:-----------]|*6 2299 {3:[No Name] [+] }{2:<Name] [+] }| 2300 [3:--------------------------------]| 2301 ## grid 2 2302 aaa aab aac| 2303 | 2304 {1:~ }|*4 2305 ## grid 3 2306 :vsplit | 2307 ## grid 4 2308 aaa aab aac | 2309 ^ | 2310 {1:~ }|*4 2311 ]]) 2312 else 2313 screen:expect([[ 2314 aaa aab aac │aaa aab aac| 2315 ^ │ | 2316 {1:~ }│{1:~ }|*4 2317 {3:[No Name] [+] }{2:<Name] [+] }| 2318 :vsplit | 2319 ]]) 2320 end 2321 2322 feed('ibbb a<c-x><c-n>') 2323 if multigrid then 2324 screen:expect { 2325 grid = [[ 2326 ## grid 1 2327 [4:--------------------]│[2:-----------]|*6 2328 {3:[No Name] [+] }{2:<Name] [+] }| 2329 [3:--------------------------------]| 2330 ## grid 2 2331 aaa aab aac| 2332 bbb aaa | 2333 {1:~ }|*4 2334 ## grid 3 2335 {5:-- }{6:match 1 of 3} | 2336 ## grid 4 2337 aaa aab aac | 2338 bbb aaa^ | 2339 {1:~ }|*4 2340 ## grid 5 2341 {12: aaa }| 2342 {n: aab }| 2343 {n: aac }| 2344 ]], 2345 float_pos = { [5] = { -1, 'NW', 4, 2, 3, false, 100, 1, 2, 3 } }, 2346 } 2347 else 2348 screen:expect([[ 2349 aaa aab aac │aaa aab aac| 2350 bbb aaa^ │bbb aaa | 2351 {1:~ }{12: aaa }{1: }│{1:~ }| 2352 {1:~ }{n: aab }{1: }│{1:~ }| 2353 {1:~ }{n: aac }{1: }│{1:~ }| 2354 {1:~ }│{1:~ }| 2355 {3:[No Name] [+] }{2:<Name] [+] }| 2356 {5:-- }{6:match 1 of 3} | 2357 ]]) 2358 end 2359 2360 feed('<esc><c-w><c-w>oc a<c-x><c-n>') 2361 if multigrid then 2362 screen:expect { 2363 grid = [[ 2364 ## grid 1 2365 [4:-----------]│[2:--------------------]|*6 2366 {2:<Name] [+] }{3:[No Name] [+] }| 2367 [3:--------------------------------]| 2368 ## grid 2 2369 aaa aab aac | 2370 bbb aaa | 2371 c aaa^ | 2372 {1:~ }|*3 2373 ## grid 3 2374 {5:-- }{6:match 1 of 3} | 2375 ## grid 4 2376 aaa aab aac| 2377 bbb aaa | 2378 c aaa | 2379 {1:~ }|*3 2380 ## grid 5 2381 {12: aaa }| 2382 {n: aab }| 2383 {n: aac }| 2384 ]], 2385 float_pos = { [5] = { -1, 'NW', 2, 3, 1, false, 100, 1, 3, 13 } }, 2386 } 2387 else 2388 screen:expect([[ 2389 aaa aab aac│aaa aab aac | 2390 bbb aaa │bbb aaa | 2391 c aaa │c aaa^ | 2392 {1:~ }│{1:~}{12: aaa }{1: }| 2393 {1:~ }│{1:~}{n: aab }{1: }| 2394 {1:~ }│{1:~}{n: aac }{1: }| 2395 {2:<Name] [+] }{3:[No Name] [+] }| 2396 {5:-- }{6:match 1 of 3} | 2397 ]]) 2398 end 2399 2400 feed('bcdef ccc a<c-x><c-n>') 2401 if multigrid then 2402 screen:expect { 2403 grid = [[ 2404 ## grid 1 2405 [4:-----------]│[2:--------------------]|*6 2406 {2:<Name] [+] }{3:[No Name] [+] }| 2407 [3:--------------------------------]| 2408 ## grid 2 2409 aaa aab aac | 2410 bbb aaa | 2411 c aaabcdef ccc aaa^ | 2412 {1:~ }|*3 2413 ## grid 3 2414 {5:-- }{6:match 1 of 4} | 2415 ## grid 4 2416 aaa aab aac| 2417 bbb aaa | 2418 c aaabcdef | 2419 ccc aaa | 2420 {1:~ }|*2 2421 ## grid 5 2422 {12: aaa }| 2423 {n: aab }| 2424 {n: aac }| 2425 {n: aaabcdef }| 2426 ]], 2427 float_pos = { [5] = { -1, 'NW', 2, 3, 3, false, 100, 1, 3, 15 } }, 2428 } 2429 else 2430 screen:expect([[ 2431 aaa aab aac│aaa aab aac | 2432 bbb aaa │bbb aaa | 2433 c aaabcdef │c aaabcdef ccc aaa^ | 2434 ccc aaa │{1:~ }{12: aaa }| 2435 {1:~ }│{1:~ }{n: aab }| 2436 {1:~ }│{1:~ }{n: aac }| 2437 {2:<Name] [+] }{3:[No}{n: aaabcdef }| 2438 {5:-- }{6:match 1 of 4} | 2439 ]]) 2440 end 2441 2442 feed('\n<c-x><c-n>') 2443 if multigrid then 2444 screen:expect { 2445 grid = [[ 2446 ## grid 1 2447 [4:-----------]│[2:--------------------]|*6 2448 {2:<Name] [+] }{3:[No Name] [+] }| 2449 [3:--------------------------------]| 2450 ## grid 2 2451 aaa aab aac | 2452 bbb aaa | 2453 c aaabcdef ccc aaa | 2454 aaa^ | 2455 {1:~ }|*2 2456 ## grid 3 2457 {5:-- }{6:match 1 of 6} | 2458 ## grid 4 2459 aaa aab aac| 2460 bbb aaa | 2461 c aaabcdef | 2462 ccc aaa | 2463 aaa | 2464 {1:~ }| 2465 ## grid 5 2466 {12: aaa }{c: }| 2467 {n: aab }{12: }| 2468 {n: aac }{12: }| 2469 ]], 2470 float_pos = { [5] = { -1, 'NW', 2, 4, -1, false, 100, 1, 4, 11 } }, 2471 } 2472 else 2473 screen:expect([[ 2474 aaa aab aac│aaa aab aac | 2475 bbb aaa │bbb aaa | 2476 c aaabcdef │c aaabcdef ccc aaa | 2477 ccc aaa │aaa^ | 2478 aaa {12: aaa }{c: }{1: }| 2479 {1:~ }{n: aab }{12: }{1: }| 2480 {2:<Name] [+] }{n: aac }{12: }{3: }| 2481 {5:-- }{6:match 1 of 6} | 2482 ]]) 2483 end 2484 end) 2485 2486 it('with split and scroll', function() 2487 screen:try_resize(60, 14) 2488 command('split') 2489 command('set completeopt+=noinsert') 2490 command('set mouse=a') 2491 insert([[ 2492 Lorem ipsum dolor sit amet, consectetur 2493 adipisicing elit, sed do eiusmod tempor 2494 incididunt ut labore et dolore magna aliqua. 2495 Ut enim ad minim veniam, quis nostrud 2496 exercitation ullamco laboris nisi ut aliquip ex 2497 ea commodo consequat. Duis aute irure dolor in 2498 reprehenderit in voluptate velit esse cillum 2499 dolore eu fugiat nulla pariatur. Excepteur sint 2500 occaecat cupidatat non proident, sunt in culpa 2501 qui officia deserunt mollit anim id est 2502 laborum. 2503 . 2504 ]]) 2505 2506 if multigrid then 2507 screen:expect([[ 2508 ## grid 1 2509 [4:------------------------------------------------------------]|*6 2510 {3:[No Name] [+] }| 2511 [2:------------------------------------------------------------]|*5 2512 {2:[No Name] [+] }| 2513 [3:------------------------------------------------------------]| 2514 ## grid 2 2515 Lorem ipsum dolor sit amet, consectetur | 2516 adipisicing elit, sed do eiusmod tempor | 2517 incididunt ut labore et dolore magna aliqua. | 2518 Ut enim ad minim veniam, quis nostrud | 2519 exercitation ullamco laboris nisi ut aliquip ex | 2520 ## grid 3 2521 | 2522 ## grid 4 2523 dolore eu fugiat nulla pariatur. Excepteur sint | 2524 occaecat cupidatat non proident, sunt in culpa | 2525 qui officia deserunt mollit anim id est | 2526 laborum. | 2527 . | 2528 ^ | 2529 ]]) 2530 else 2531 screen:expect([[ 2532 dolore eu fugiat nulla pariatur. Excepteur sint | 2533 occaecat cupidatat non proident, sunt in culpa | 2534 qui officia deserunt mollit anim id est | 2535 laborum. | 2536 . | 2537 ^ | 2538 {3:[No Name] [+] }| 2539 Lorem ipsum dolor sit amet, consectetur | 2540 adipisicing elit, sed do eiusmod tempor | 2541 incididunt ut labore et dolore magna aliqua. | 2542 Ut enim ad minim veniam, quis nostrud | 2543 exercitation ullamco laboris nisi ut aliquip ex | 2544 {2:[No Name] [+] }| 2545 | 2546 ]]) 2547 end 2548 2549 feed('ggOEst <c-x><c-p>') 2550 if multigrid then 2551 screen:expect({ 2552 grid = [[ 2553 ## grid 1 2554 [4:------------------------------------------------------------]|*6 2555 {3:[No Name] [+] }| 2556 [2:------------------------------------------------------------]|*5 2557 {2:[No Name] [+] }| 2558 [3:------------------------------------------------------------]| 2559 ## grid 2 2560 Est | 2561 Lorem ipsum dolor sit amet, consectetur | 2562 adipisicing elit, sed do eiusmod tempor | 2563 incididunt ut labore et dolore magna aliqua. | 2564 Ut enim ad minim veniam, quis nostrud | 2565 ## grid 3 2566 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2567 ## grid 4 2568 Est ^ | 2569 Lorem ipsum dolor sit amet, consectetur | 2570 adipisicing elit, sed do eiusmod tempor | 2571 incididunt ut labore et dolore magna aliqua. | 2572 Ut enim ad minim veniam, quis nostrud | 2573 exercitation ullamco laboris nisi ut aliquip ex | 2574 ## grid 5 2575 {n: sunt }{12: }| 2576 {n: in }{12: }| 2577 {n: culpa }{12: }| 2578 {n: qui }{12: }| 2579 {n: officia }{12: }| 2580 {n: deserunt }{12: }| 2581 {n: mollit }{12: }| 2582 {n: anim }{12: }| 2583 {n: id }{12: }| 2584 {n: est }{12: }| 2585 {n: laborum }{c: }| 2586 {12: Est }{c: }| 2587 ]], 2588 float_pos = { [5] = { -1, 'NW', 4, 1, 3, false, 100, 1, 1, 3 } }, 2589 }) 2590 else 2591 screen:expect([[ 2592 Est ^ | 2593 L{n: sunt }{12: }sit amet, consectetur | 2594 a{n: in }{12: }sed do eiusmod tempor | 2595 i{n: culpa }{12: }re et dolore magna aliqua. | 2596 U{n: qui }{12: }eniam, quis nostrud | 2597 e{n: officia }{12: }co laboris nisi ut aliquip ex | 2598 {3:[No}{n: deserunt }{12: }{3: }| 2599 Est{n: mollit }{12: } | 2600 L{n: anim }{12: }sit amet, consectetur | 2601 a{n: id }{12: }sed do eiusmod tempor | 2602 i{n: est }{12: }re et dolore magna aliqua. | 2603 U{n: laborum }{c: }eniam, quis nostrud | 2604 {2:[No}{12: Est }{c: }{2: }| 2605 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2606 ]]) 2607 end 2608 2609 if send_mouse_grid then 2610 api.nvim_input_mouse('wheel', 'down', '', 2, 9, 33) 2611 else 2612 api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) 2613 end 2614 if multigrid then 2615 screen:expect({ 2616 grid = [[ 2617 ## grid 1 2618 [4:------------------------------------------------------------]|*6 2619 {3:[No Name] [+] }| 2620 [2:------------------------------------------------------------]|*5 2621 {2:[No Name] [+] }| 2622 [3:------------------------------------------------------------]| 2623 ## grid 2 2624 incididunt ut labore et dolore magna aliqua. | 2625 Ut enim ad minim veniam, quis nostrud | 2626 exercitation ullamco laboris nisi ut aliquip ex | 2627 ea commodo consequat. Duis aute irure dolor in | 2628 reprehenderit in voluptate velit esse cillum | 2629 ## grid 3 2630 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2631 ## grid 4 2632 Est ^ | 2633 Lorem ipsum dolor sit amet, consectetur | 2634 adipisicing elit, sed do eiusmod tempor | 2635 incididunt ut labore et dolore magna aliqua. | 2636 Ut enim ad minim veniam, quis nostrud | 2637 exercitation ullamco laboris nisi ut aliquip ex | 2638 ## grid 5 2639 {n: sunt }{12: }| 2640 {n: in }{12: }| 2641 {n: culpa }{12: }| 2642 {n: qui }{12: }| 2643 {n: officia }{12: }| 2644 {n: deserunt }{12: }| 2645 {n: mollit }{12: }| 2646 {n: anim }{12: }| 2647 {n: id }{12: }| 2648 {n: est }{12: }| 2649 {n: laborum }{c: }| 2650 {12: Est }{c: }| 2651 ]], 2652 float_pos = { [5] = { -1, 'NW', 4, 1, 3, false, 100, 1, 1, 3 } }, 2653 }) 2654 else 2655 screen:expect([[ 2656 Est ^ | 2657 L{n: sunt }{12: }sit amet, consectetur | 2658 a{n: in }{12: }sed do eiusmod tempor | 2659 i{n: culpa }{12: }re et dolore magna aliqua. | 2660 U{n: qui }{12: }eniam, quis nostrud | 2661 e{n: officia }{12: }co laboris nisi ut aliquip ex | 2662 {3:[No}{n: deserunt }{12: }{3: }| 2663 i{n: mollit }{12: }re et dolore magna aliqua. | 2664 U{n: anim }{12: }eniam, quis nostrud | 2665 e{n: id }{12: }co laboris nisi ut aliquip ex | 2666 e{n: est }{12: }at. Duis aute irure dolor in | 2667 r{n: laborum }{c: }oluptate velit esse cillum | 2668 {2:[No}{12: Est }{c: }{2: }| 2669 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2670 ]]) 2671 end 2672 2673 feed('e') 2674 if multigrid then 2675 screen:expect({ 2676 grid = [[ 2677 ## grid 1 2678 [4:------------------------------------------------------------]|*6 2679 {3:[No Name] [+] }| 2680 [2:------------------------------------------------------------]|*5 2681 {2:[No Name] [+] }| 2682 [3:------------------------------------------------------------]| 2683 ## grid 2 2684 incididunt ut labore et dolore magna aliqua. | 2685 Ut enim ad minim veniam, quis nostrud | 2686 exercitation ullamco laboris nisi ut aliquip ex | 2687 ea commodo consequat. Duis aute irure dolor in | 2688 reprehenderit in voluptate velit esse cillum | 2689 ## grid 3 2690 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2691 ## grid 4 2692 Est e^ | 2693 Lorem ipsum dolor sit amet, consectetur | 2694 adipisicing elit, sed do eiusmod tempor | 2695 incididunt ut labore et dolore magna aliqua. | 2696 Ut enim ad minim veniam, quis nostrud | 2697 exercitation ullamco laboris nisi ut aliquip ex | 2698 ## grid 5 2699 {n: elit }| 2700 {n: eiusmod }| 2701 {n: et }| 2702 {n: enim }| 2703 {n: exercitation }| 2704 {n: ex }| 2705 {n: ea }| 2706 {n: esse }| 2707 {n: eu }| 2708 {12: est }| 2709 ]], 2710 float_pos = { [5] = { -1, 'NW', 4, 1, 3, false, 100, 1, 1, 3 } }, 2711 }) 2712 else 2713 screen:expect([[ 2714 Est e^ | 2715 L{n: elit } sit amet, consectetur | 2716 a{n: eiusmod } sed do eiusmod tempor | 2717 i{n: et }ore et dolore magna aliqua. | 2718 U{n: enim }veniam, quis nostrud | 2719 e{n: exercitation }mco laboris nisi ut aliquip ex | 2720 {3:[No}{n: ex }{3: }| 2721 i{n: ea }ore et dolore magna aliqua. | 2722 U{n: esse }veniam, quis nostrud | 2723 e{n: eu }mco laboris nisi ut aliquip ex | 2724 e{12: est }uat. Duis aute irure dolor in | 2725 reprehenderit in voluptate velit esse cillum | 2726 {2:[No Name] [+] }| 2727 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2728 ]]) 2729 end 2730 2731 if send_mouse_grid then 2732 api.nvim_input_mouse('wheel', 'up', '', 2, 9, 33) 2733 else 2734 api.nvim_input_mouse('wheel', 'up', '', 0, 9, 40) 2735 end 2736 if multigrid then 2737 screen:expect({ 2738 grid = [[ 2739 ## grid 1 2740 [4:------------------------------------------------------------]|*6 2741 {3:[No Name] [+] }| 2742 [2:------------------------------------------------------------]|*5 2743 {2:[No Name] [+] }| 2744 [3:------------------------------------------------------------]| 2745 ## grid 2 2746 Est e | 2747 Lorem ipsum dolor sit amet, consectetur | 2748 adipisicing elit, sed do eiusmod tempor | 2749 incididunt ut labore et dolore magna aliqua. | 2750 Ut enim ad minim veniam, quis nostrud | 2751 ## grid 3 2752 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2753 ## grid 4 2754 Est e^ | 2755 Lorem ipsum dolor sit amet, consectetur | 2756 adipisicing elit, sed do eiusmod tempor | 2757 incididunt ut labore et dolore magna aliqua. | 2758 Ut enim ad minim veniam, quis nostrud | 2759 exercitation ullamco laboris nisi ut aliquip ex | 2760 ## grid 5 2761 {n: elit }| 2762 {n: eiusmod }| 2763 {n: et }| 2764 {n: enim }| 2765 {n: exercitation }| 2766 {n: ex }| 2767 {n: ea }| 2768 {n: esse }| 2769 {n: eu }| 2770 {12: est }| 2771 ]], 2772 float_pos = { [5] = { -1, 'NW', 4, 1, 3, false, 100, 1, 1, 3 } }, 2773 }) 2774 else 2775 screen:expect([[ 2776 Est e^ | 2777 L{n: elit } sit amet, consectetur | 2778 a{n: eiusmod } sed do eiusmod tempor | 2779 i{n: et }ore et dolore magna aliqua. | 2780 U{n: enim }veniam, quis nostrud | 2781 e{n: exercitation }mco laboris nisi ut aliquip ex | 2782 {3:[No}{n: ex }{3: }| 2783 Est{n: ea } | 2784 L{n: esse } sit amet, consectetur | 2785 a{n: eu } sed do eiusmod tempor | 2786 i{12: est }ore et dolore magna aliqua. | 2787 Ut enim ad minim veniam, quis nostrud | 2788 {2:[No Name] [+] }| 2789 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2790 ]]) 2791 end 2792 2793 feed('s') 2794 if multigrid then 2795 screen:expect({ 2796 grid = [[ 2797 ## grid 1 2798 [4:------------------------------------------------------------]|*6 2799 {3:[No Name] [+] }| 2800 [2:------------------------------------------------------------]|*5 2801 {2:[No Name] [+] }| 2802 [3:------------------------------------------------------------]| 2803 ## grid 2 2804 Est es | 2805 Lorem ipsum dolor sit amet, consectetur | 2806 adipisicing elit, sed do eiusmod tempor | 2807 incididunt ut labore et dolore magna aliqua. | 2808 Ut enim ad minim veniam, quis nostrud | 2809 ## grid 3 2810 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2811 ## grid 4 2812 Est es^ | 2813 Lorem ipsum dolor sit amet, consectetur | 2814 adipisicing elit, sed do eiusmod tempor | 2815 incididunt ut labore et dolore magna aliqua. | 2816 Ut enim ad minim veniam, quis nostrud | 2817 exercitation ullamco laboris nisi ut aliquip ex | 2818 ## grid 5 2819 {n: esse }| 2820 {12: est }| 2821 ]], 2822 float_pos = { [5] = { -1, 'NW', 4, 1, 3, false, 100, 1, 1, 3 } }, 2823 }) 2824 else 2825 screen:expect([[ 2826 Est es^ | 2827 L{n: esse } sit amet, consectetur | 2828 a{12: est } sed do eiusmod tempor | 2829 incididunt ut labore et dolore magna aliqua. | 2830 Ut enim ad minim veniam, quis nostrud | 2831 exercitation ullamco laboris nisi ut aliquip ex | 2832 {3:[No Name] [+] }| 2833 Est es | 2834 Lorem ipsum dolor sit amet, consectetur | 2835 adipisicing elit, sed do eiusmod tempor | 2836 incididunt ut labore et dolore magna aliqua. | 2837 Ut enim ad minim veniam, quis nostrud | 2838 {2:[No Name] [+] }| 2839 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2840 ]]) 2841 end 2842 2843 if send_mouse_grid then 2844 api.nvim_input_mouse('wheel', 'down', '', 2, 9, 33) 2845 else 2846 api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) 2847 end 2848 if multigrid then 2849 screen:expect({ 2850 grid = [[ 2851 ## grid 1 2852 [4:------------------------------------------------------------]|*6 2853 {3:[No Name] [+] }| 2854 [2:------------------------------------------------------------]|*5 2855 {2:[No Name] [+] }| 2856 [3:------------------------------------------------------------]| 2857 ## grid 2 2858 incididunt ut labore et dolore magna aliqua. | 2859 Ut enim ad minim veniam, quis nostrud | 2860 exercitation ullamco laboris nisi ut aliquip ex | 2861 ea commodo consequat. Duis aute irure dolor in | 2862 reprehenderit in voluptate velit esse cillum | 2863 ## grid 3 2864 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2865 ## grid 4 2866 Est es^ | 2867 Lorem ipsum dolor sit amet, consectetur | 2868 adipisicing elit, sed do eiusmod tempor | 2869 incididunt ut labore et dolore magna aliqua. | 2870 Ut enim ad minim veniam, quis nostrud | 2871 exercitation ullamco laboris nisi ut aliquip ex | 2872 ## grid 5 2873 {n: esse }| 2874 {12: est }| 2875 ]], 2876 float_pos = { [5] = { -1, 'NW', 4, 1, 3, false, 100, 1, 1, 3 } }, 2877 }) 2878 else 2879 screen:expect([[ 2880 Est es^ | 2881 L{n: esse } sit amet, consectetur | 2882 a{12: est } sed do eiusmod tempor | 2883 incididunt ut labore et dolore magna aliqua. | 2884 Ut enim ad minim veniam, quis nostrud | 2885 exercitation ullamco laboris nisi ut aliquip ex | 2886 {3:[No Name] [+] }| 2887 incididunt ut labore et dolore magna aliqua. | 2888 Ut enim ad minim veniam, quis nostrud | 2889 exercitation ullamco laboris nisi ut aliquip ex | 2890 ea commodo consequat. Duis aute irure dolor in | 2891 reprehenderit in voluptate velit esse cillum | 2892 {2:[No Name] [+] }| 2893 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2894 ]]) 2895 end 2896 2897 feed('<bs>') 2898 if multigrid then 2899 screen:expect({ 2900 grid = [[ 2901 ## grid 1 2902 [4:------------------------------------------------------------]|*6 2903 {3:[No Name] [+] }| 2904 [2:------------------------------------------------------------]|*5 2905 {2:[No Name] [+] }| 2906 [3:------------------------------------------------------------]| 2907 ## grid 2 2908 incididunt ut labore et dolore magna aliqua. | 2909 Ut enim ad minim veniam, quis nostrud | 2910 exercitation ullamco laboris nisi ut aliquip ex | 2911 ea commodo consequat. Duis aute irure dolor in | 2912 reprehenderit in voluptate velit esse cillum | 2913 ## grid 3 2914 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2915 ## grid 4 2916 Est e^ | 2917 Lorem ipsum dolor sit amet, consectetur | 2918 adipisicing elit, sed do eiusmod tempor | 2919 incididunt ut labore et dolore magna aliqua. | 2920 Ut enim ad minim veniam, quis nostrud | 2921 exercitation ullamco laboris nisi ut aliquip ex | 2922 ## grid 5 2923 {n: elit }| 2924 {n: eiusmod }| 2925 {n: et }| 2926 {n: enim }| 2927 {n: exercitation }| 2928 {n: ex }| 2929 {n: ea }| 2930 {n: esse }| 2931 {n: eu }| 2932 {12: est }| 2933 ]], 2934 float_pos = { [5] = { -1, 'NW', 4, 1, 3, false, 100, 1, 1, 3 } }, 2935 }) 2936 else 2937 screen:expect([[ 2938 Est e^ | 2939 L{n: elit } sit amet, consectetur | 2940 a{n: eiusmod } sed do eiusmod tempor | 2941 i{n: et }ore et dolore magna aliqua. | 2942 U{n: enim }veniam, quis nostrud | 2943 e{n: exercitation }mco laboris nisi ut aliquip ex | 2944 {3:[No}{n: ex }{3: }| 2945 i{n: ea }ore et dolore magna aliqua. | 2946 U{n: esse }veniam, quis nostrud | 2947 e{n: eu }mco laboris nisi ut aliquip ex | 2948 e{12: est }uat. Duis aute irure dolor in | 2949 reprehenderit in voluptate velit esse cillum | 2950 {2:[No Name] [+] }| 2951 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2952 ]]) 2953 end 2954 2955 feed('<c-p>') 2956 if multigrid then 2957 screen:expect({ 2958 grid = [[ 2959 ## grid 1 2960 [4:------------------------------------------------------------]|*6 2961 {3:[No Name] [+] }| 2962 [2:------------------------------------------------------------]|*5 2963 {2:[No Name] [+] }| 2964 [3:------------------------------------------------------------]| 2965 ## grid 2 2966 incididunt ut labore et dolore magna aliqua. | 2967 Ut enim ad minim veniam, quis nostrud | 2968 exercitation ullamco laboris nisi ut aliquip ex | 2969 ea commodo consequat. Duis aute irure dolor in | 2970 reprehenderit in voluptate velit esse cillum | 2971 ## grid 3 2972 {5:-- Keyword Local completion (^N^P) }{6:match 22 of 65} | 2973 ## grid 4 2974 Est eu^ | 2975 Lorem ipsum dolor sit amet, consectetur | 2976 adipisicing elit, sed do eiusmod tempor | 2977 incididunt ut labore et dolore magna aliqua. | 2978 Ut enim ad minim veniam, quis nostrud | 2979 exercitation ullamco laboris nisi ut aliquip ex | 2980 ## grid 5 2981 {n: elit }| 2982 {n: eiusmod }| 2983 {n: et }| 2984 {n: enim }| 2985 {n: exercitation }| 2986 {n: ex }| 2987 {n: ea }| 2988 {n: esse }| 2989 {12: eu }| 2990 {n: est }| 2991 ]], 2992 float_pos = { [5] = { -1, 'NW', 4, 1, 3, false, 100, 1, 1, 3 } }, 2993 }) 2994 else 2995 screen:expect([[ 2996 Est eu^ | 2997 L{n: elit } sit amet, consectetur | 2998 a{n: eiusmod } sed do eiusmod tempor | 2999 i{n: et }ore et dolore magna aliqua. | 3000 U{n: enim }veniam, quis nostrud | 3001 e{n: exercitation }mco laboris nisi ut aliquip ex | 3002 {3:[No}{n: ex }{3: }| 3003 i{n: ea }ore et dolore magna aliqua. | 3004 U{n: esse }veniam, quis nostrud | 3005 e{12: eu }mco laboris nisi ut aliquip ex | 3006 e{n: est }uat. Duis aute irure dolor in | 3007 reprehenderit in voluptate velit esse cillum | 3008 {2:[No Name] [+] }| 3009 {5:-- Keyword Local completion (^N^P) }{6:match 22 of 65} | 3010 ]]) 3011 end 3012 3013 if send_mouse_grid then 3014 api.nvim_input_mouse('wheel', 'down', '', 2, 9, 33) 3015 else 3016 api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) 3017 end 3018 if multigrid then 3019 screen:expect({ 3020 grid = [[ 3021 ## grid 1 3022 [4:------------------------------------------------------------]|*6 3023 {3:[No Name] [+] }| 3024 [2:------------------------------------------------------------]|*5 3025 {2:[No Name] [+] }| 3026 [3:------------------------------------------------------------]| 3027 ## grid 2 3028 ea commodo consequat. Duis aute irure dolor in | 3029 reprehenderit in voluptate velit esse cillum | 3030 dolore eu fugiat nulla pariatur. Excepteur sint | 3031 occaecat cupidatat non proident, sunt in culpa | 3032 qui officia deserunt mollit anim id est | 3033 ## grid 3 3034 {5:-- Keyword Local completion (^N^P) }{6:match 22 of 65} | 3035 ## grid 4 3036 Est eu^ | 3037 Lorem ipsum dolor sit amet, consectetur | 3038 adipisicing elit, sed do eiusmod tempor | 3039 incididunt ut labore et dolore magna aliqua. | 3040 Ut enim ad minim veniam, quis nostrud | 3041 exercitation ullamco laboris nisi ut aliquip ex | 3042 ## grid 5 3043 {n: elit }| 3044 {n: eiusmod }| 3045 {n: et }| 3046 {n: enim }| 3047 {n: exercitation }| 3048 {n: ex }| 3049 {n: ea }| 3050 {n: esse }| 3051 {12: eu }| 3052 {n: est }| 3053 ]], 3054 float_pos = { [5] = { -1, 'NW', 4, 1, 3, false, 100, 1, 1, 3 } }, 3055 }) 3056 else 3057 screen:expect([[ 3058 Est eu^ | 3059 L{n: elit } sit amet, consectetur | 3060 a{n: eiusmod } sed do eiusmod tempor | 3061 i{n: et }ore et dolore magna aliqua. | 3062 U{n: enim }veniam, quis nostrud | 3063 e{n: exercitation }mco laboris nisi ut aliquip ex | 3064 {3:[No}{n: ex }{3: }| 3065 e{n: ea }uat. Duis aute irure dolor in | 3066 r{n: esse }voluptate velit esse cillum | 3067 d{12: eu }nulla pariatur. Excepteur sint | 3068 o{n: est }t non proident, sunt in culpa | 3069 qui officia deserunt mollit anim id est | 3070 {2:[No Name] [+] }| 3071 {5:-- Keyword Local completion (^N^P) }{6:match 22 of 65} | 3072 ]]) 3073 end 3074 3075 fn.complete(4, { 'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' }) 3076 if multigrid then 3077 screen:expect({ 3078 grid = [[ 3079 ## grid 1 3080 [4:------------------------------------------------------------]|*6 3081 {3:[No Name] [+] }| 3082 [2:------------------------------------------------------------]|*5 3083 {2:[No Name] [+] }| 3084 [3:------------------------------------------------------------]| 3085 ## grid 2 3086 ea commodo consequat. Duis aute irure dolor in | 3087 reprehenderit in voluptate velit esse cillum | 3088 dolore eu fugiat nulla pariatur. Excepteur sint | 3089 occaecat cupidatat non proident, sunt in culpa | 3090 qui officia deserunt mollit anim id est | 3091 ## grid 3 3092 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 9} | 3093 ## grid 4 3094 Est eu^ | 3095 Lorem ipsum dolor sit amet, consectetur | 3096 adipisicing elit, sed do eiusmod tempor | 3097 incididunt ut labore et dolore magna aliqua. | 3098 Ut enim ad minim veniam, quis nostrud | 3099 exercitation ullamco laboris nisi ut aliquip ex | 3100 ## grid 5 3101 {12: ea }| 3102 {n: eeeeeeeeeeeeeeeeee }| 3103 {n: ei }| 3104 {n: eo }| 3105 {n: eu }| 3106 {n: ey }| 3107 {n: eå }| 3108 {n: eä }| 3109 {n: eö }| 3110 ]], 3111 float_pos = { [5] = { -1, 'NW', 4, 1, 2, false, 100, 1, 1, 2 } }, 3112 }) 3113 else 3114 screen:expect([[ 3115 Est eu^ | 3116 {12: ea }t amet, consectetur | 3117 {n: eeeeeeeeeeeeeeeeee }d do eiusmod tempor | 3118 {n: ei } et dolore magna aliqua. | 3119 {n: eo }iam, quis nostrud | 3120 {n: eu } laboris nisi ut aliquip ex | 3121 {3:[N}{n: ey }{3: }| 3122 {n: eå }. Duis aute irure dolor in | 3123 {n: eä }uptate velit esse cillum | 3124 {n: eö }la pariatur. Excepteur sint | 3125 occaecat cupidatat non proident, sunt in culpa | 3126 qui officia deserunt mollit anim id est | 3127 {2:[No Name] [+] }| 3128 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 9} | 3129 ]]) 3130 end 3131 3132 fn.complete(4, { 'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' }) 3133 if multigrid then 3134 screen:expect({ 3135 grid = [[ 3136 ## grid 1 3137 [4:------------------------------------------------------------]|*6 3138 {3:[No Name] [+] }| 3139 [2:------------------------------------------------------------]|*5 3140 {2:[No Name] [+] }| 3141 [3:------------------------------------------------------------]| 3142 ## grid 2 3143 ea commodo consequat. Duis aute irure dolor in | 3144 reprehenderit in voluptate velit esse cillum | 3145 dolore eu fugiat nulla pariatur. Excepteur sint | 3146 occaecat cupidatat non proident, sunt in culpa | 3147 qui officia deserunt mollit anim id est | 3148 ## grid 3 3149 {5:-- INSERT --} | 3150 ## grid 4 3151 Est eu^ | 3152 Lorem ipsum dolor sit amet, consectetur | 3153 adipisicing elit, sed do eiusmod tempor | 3154 incididunt ut labore et dolore magna aliqua. | 3155 Ut enim ad minim veniam, quis nostrud | 3156 exercitation ullamco laboris nisi ut aliquip ex | 3157 ## grid 5 3158 {12: ea }| 3159 {n: eee }| 3160 {n: ei }| 3161 {n: eo }| 3162 {n: eu }| 3163 {n: ey }| 3164 {n: eå }| 3165 {n: eä }| 3166 {n: eö }| 3167 ]], 3168 float_pos = { [5] = { -1, 'NW', 4, 1, 2, false, 100, 1, 1, 2 } }, 3169 }) 3170 else 3171 screen:expect([[ 3172 Est eu^ | 3173 {12: ea }r sit amet, consectetur | 3174 {n: eee }, sed do eiusmod tempor | 3175 {n: ei }bore et dolore magna aliqua. | 3176 {n: eo } veniam, quis nostrud | 3177 {n: eu }amco laboris nisi ut aliquip ex | 3178 {3:[N}{n: ey }{3: }| 3179 {n: eå }quat. Duis aute irure dolor in | 3180 {n: eä } voluptate velit esse cillum | 3181 {n: eö } nulla pariatur. Excepteur sint | 3182 occaecat cupidatat non proident, sunt in culpa | 3183 qui officia deserunt mollit anim id est | 3184 {2:[No Name] [+] }| 3185 {5:-- INSERT --} | 3186 ]]) 3187 end 3188 3189 feed('<c-n>') 3190 if multigrid then 3191 screen:expect({ 3192 grid = [[ 3193 ## grid 1 3194 [4:------------------------------------------------------------]|*6 3195 {3:[No Name] [+] }| 3196 [2:------------------------------------------------------------]|*5 3197 {2:[No Name] [+] }| 3198 [3:------------------------------------------------------------]| 3199 ## grid 2 3200 ea commodo consequat. Duis aute irure dolor in | 3201 reprehenderit in voluptate velit esse cillum | 3202 dolore eu fugiat nulla pariatur. Excepteur sint | 3203 occaecat cupidatat non proident, sunt in culpa | 3204 qui officia deserunt mollit anim id est | 3205 ## grid 3 3206 {5:-- INSERT --} | 3207 ## grid 4 3208 Esteee^ | 3209 Lorem ipsum dolor sit amet, consectetur | 3210 adipisicing elit, sed do eiusmod tempor | 3211 incididunt ut labore et dolore magna aliqua. | 3212 Ut enim ad minim veniam, quis nostrud | 3213 exercitation ullamco laboris nisi ut aliquip ex | 3214 ## grid 5 3215 {n: ea }| 3216 {12: eee }| 3217 {n: ei }| 3218 {n: eo }| 3219 {n: eu }| 3220 {n: ey }| 3221 {n: eå }| 3222 {n: eä }| 3223 {n: eö }| 3224 ]], 3225 float_pos = { [5] = { -1, 'NW', 4, 1, 2, false, 100, 1, 1, 2 } }, 3226 }) 3227 else 3228 screen:expect([[ 3229 Esteee^ | 3230 {n: ea }r sit amet, consectetur | 3231 {12: eee }, sed do eiusmod tempor | 3232 {n: ei }bore et dolore magna aliqua. | 3233 {n: eo } veniam, quis nostrud | 3234 {n: eu }amco laboris nisi ut aliquip ex | 3235 {3:[N}{n: ey }{3: }| 3236 {n: eå }quat. Duis aute irure dolor in | 3237 {n: eä } voluptate velit esse cillum | 3238 {n: eö } nulla pariatur. Excepteur sint | 3239 occaecat cupidatat non proident, sunt in culpa | 3240 qui officia deserunt mollit anim id est | 3241 {2:[No Name] [+] }| 3242 {5:-- INSERT --} | 3243 ]]) 3244 end 3245 3246 fn.complete(6, { 'foo', 'bar' }) 3247 if multigrid then 3248 screen:expect({ 3249 grid = [[ 3250 ## grid 1 3251 [4:------------------------------------------------------------]|*6 3252 {3:[No Name] [+] }| 3253 [2:------------------------------------------------------------]|*5 3254 {2:[No Name] [+] }| 3255 [3:------------------------------------------------------------]| 3256 ## grid 2 3257 ea commodo consequat. Duis aute irure dolor in | 3258 reprehenderit in voluptate velit esse cillum | 3259 dolore eu fugiat nulla pariatur. Excepteur sint | 3260 occaecat cupidatat non proident, sunt in culpa | 3261 qui officia deserunt mollit anim id est | 3262 ## grid 3 3263 {5:-- INSERT --} | 3264 ## grid 4 3265 Esteee^ | 3266 Lorem ipsum dolor sit amet, consectetur | 3267 adipisicing elit, sed do eiusmod tempor | 3268 incididunt ut labore et dolore magna aliqua. | 3269 Ut enim ad minim veniam, quis nostrud | 3270 exercitation ullamco laboris nisi ut aliquip ex | 3271 ## grid 5 3272 {12: foo }| 3273 {n: bar }| 3274 ]], 3275 float_pos = { [5] = { -1, 'NW', 4, 1, 4, false, 100, 1, 1, 4 } }, 3276 }) 3277 else 3278 screen:expect([[ 3279 Esteee^ | 3280 Lo{12: foo }sit amet, consectetur | 3281 ad{n: bar }sed do eiusmod tempor | 3282 incididunt ut labore et dolore magna aliqua. | 3283 Ut enim ad minim veniam, quis nostrud | 3284 exercitation ullamco laboris nisi ut aliquip ex | 3285 {3:[No Name] [+] }| 3286 ea commodo consequat. Duis aute irure dolor in | 3287 reprehenderit in voluptate velit esse cillum | 3288 dolore eu fugiat nulla pariatur. Excepteur sint | 3289 occaecat cupidatat non proident, sunt in culpa | 3290 qui officia deserunt mollit anim id est | 3291 {2:[No Name] [+] }| 3292 {5:-- INSERT --} | 3293 ]]) 3294 end 3295 3296 feed('<c-y>') 3297 if multigrid then 3298 screen:expect([[ 3299 ## grid 1 3300 [4:------------------------------------------------------------]|*6 3301 {3:[No Name] [+] }| 3302 [2:------------------------------------------------------------]|*5 3303 {2:[No Name] [+] }| 3304 [3:------------------------------------------------------------]| 3305 ## grid 2 3306 ea commodo consequat. Duis aute irure dolor in | 3307 reprehenderit in voluptate velit esse cillum | 3308 dolore eu fugiat nulla pariatur. Excepteur sint | 3309 occaecat cupidatat non proident, sunt in culpa | 3310 qui officia deserunt mollit anim id est | 3311 ## grid 3 3312 {5:-- INSERT --} | 3313 ## grid 4 3314 Esteefoo^ | 3315 Lorem ipsum dolor sit amet, consectetur | 3316 adipisicing elit, sed do eiusmod tempor | 3317 incididunt ut labore et dolore magna aliqua. | 3318 Ut enim ad minim veniam, quis nostrud | 3319 exercitation ullamco laboris nisi ut aliquip ex | 3320 ]]) 3321 else 3322 screen:expect([[ 3323 Esteefoo^ | 3324 Lorem ipsum dolor sit amet, consectetur | 3325 adipisicing elit, sed do eiusmod tempor | 3326 incididunt ut labore et dolore magna aliqua. | 3327 Ut enim ad minim veniam, quis nostrud | 3328 exercitation ullamco laboris nisi ut aliquip ex | 3329 {3:[No Name] [+] }| 3330 ea commodo consequat. Duis aute irure dolor in | 3331 reprehenderit in voluptate velit esse cillum | 3332 dolore eu fugiat nulla pariatur. Excepteur sint | 3333 occaecat cupidatat non proident, sunt in culpa | 3334 qui officia deserunt mollit anim id est | 3335 {2:[No Name] [+] }| 3336 {5:-- INSERT --} | 3337 ]]) 3338 end 3339 end) 3340 3341 it('can be moved due to wrap or resize', function() 3342 feed('isome long prefix before the ') 3343 command('set completeopt+=noinsert,noselect') 3344 command('set linebreak') 3345 fn.complete(29, { 'word', 'choice', 'text', 'thing' }) 3346 if multigrid then 3347 screen:expect({ 3348 grid = [[ 3349 ## grid 1 3350 [2:--------------------------------]|*19 3351 [3:--------------------------------]| 3352 ## grid 2 3353 some long prefix before the ^ | 3354 {1:~ }|*18 3355 ## grid 3 3356 {5:-- INSERT --} | 3357 ## grid 4 3358 {n: word }| 3359 {n: choice }| 3360 {n: text }| 3361 {n: thing }| 3362 ]], 3363 float_pos = { [4] = { -1, 'NW', 2, 1, 15, false, 100, 1, 1, 15 } }, 3364 }) 3365 else 3366 screen:expect([[ 3367 some long prefix before the ^ | 3368 {1:~ }{n: word }| 3369 {1:~ }{n: choice }| 3370 {1:~ }{n: text }| 3371 {1:~ }{n: thing }| 3372 {1:~ }|*14 3373 {5:-- INSERT --} | 3374 ]]) 3375 end 3376 3377 feed('<c-p>') 3378 if multigrid then 3379 screen:expect({ 3380 grid = [[ 3381 ## grid 1 3382 [2:--------------------------------]|*19 3383 [3:--------------------------------]| 3384 ## grid 2 3385 some long prefix before the | 3386 thing^ | 3387 {1:~ }|*17 3388 ## grid 3 3389 {5:-- INSERT --} | 3390 ## grid 4 3391 {n:word }| 3392 {n:choice }| 3393 {n:text }| 3394 {12:thing }| 3395 ]], 3396 float_pos = { [4] = { -1, 'NW', 2, 2, 0, false, 100, 1, 2, 0 } }, 3397 }) 3398 else 3399 screen:expect([[ 3400 some long prefix before the | 3401 thing^ | 3402 {n:word }{1: }| 3403 {n:choice }{1: }| 3404 {n:text }{1: }| 3405 {12:thing }{1: }| 3406 {1:~ }|*13 3407 {5:-- INSERT --} | 3408 ]]) 3409 end 3410 3411 feed('<c-p>') 3412 if multigrid then 3413 screen:expect({ 3414 grid = [[ 3415 ## grid 1 3416 [2:--------------------------------]|*19 3417 [3:--------------------------------]| 3418 ## grid 2 3419 some long prefix before the text| 3420 {1:^~ }| 3421 {1:~ }|*17 3422 ## grid 3 3423 {5:-- INSERT --} | 3424 ## grid 4 3425 {n: word }| 3426 {n: choice }| 3427 {12: text }| 3428 {n: thing }| 3429 ]], 3430 float_pos = { [4] = { -1, 'NW', 2, 1, 15, false, 100, 1, 1, 15 } }, 3431 }) 3432 else 3433 screen:expect([[ 3434 some long prefix before the text| 3435 {1:^~ }{n: word }| 3436 {1:~ }{n: choice }| 3437 {1:~ }{12: text }| 3438 {1:~ }{n: thing }| 3439 {1:~ }|*14 3440 {5:-- INSERT --} | 3441 ]]) 3442 end 3443 3444 screen:try_resize(30, 8) 3445 if multigrid then 3446 screen:expect({ 3447 grid = [[ 3448 ## grid 1 3449 [2:------------------------------]|*7 3450 [3:------------------------------]| 3451 ## grid 2 3452 some long prefix before the | 3453 text^ | 3454 {1:~ }|*5 3455 ## grid 3 3456 {5:-- INSERT --} | 3457 ## grid 4 3458 {n:word }| 3459 {n:choice }| 3460 {12:text }| 3461 {n:thing }| 3462 ]], 3463 float_pos = { [4] = { -1, 'NW', 2, 2, 0, false, 100, 1, 2, 0 } }, 3464 }) 3465 else 3466 screen:expect([[ 3467 some long prefix before the | 3468 text^ | 3469 {n:word }{1: }| 3470 {n:choice }{1: }| 3471 {12:text }{1: }| 3472 {n:thing }{1: }| 3473 {1:~ }| 3474 {5:-- INSERT --} | 3475 ]]) 3476 end 3477 3478 screen:try_resize(50, 8) 3479 if multigrid then 3480 screen:expect({ 3481 grid = [[ 3482 ## grid 1 3483 [2:--------------------------------------------------]|*7 3484 [3:--------------------------------------------------]| 3485 ## grid 2 3486 some long prefix before the text^ | 3487 {1:~ }|*6 3488 ## grid 3 3489 {5:-- INSERT --} | 3490 ## grid 4 3491 {n: word }| 3492 {n: choice }| 3493 {12: text }| 3494 {n: thing }| 3495 ]], 3496 float_pos = { [4] = { -1, 'NW', 2, 1, 27, false, 100, 1, 1, 27 } }, 3497 }) 3498 else 3499 screen:expect([[ 3500 some long prefix before the text^ | 3501 {1:~ }{n: word }{1: }| 3502 {1:~ }{n: choice }{1: }| 3503 {1:~ }{12: text }{1: }| 3504 {1:~ }{n: thing }{1: }| 3505 {1:~ }|*2 3506 {5:-- INSERT --} | 3507 ]]) 3508 end 3509 3510 screen:try_resize(25, 10) 3511 if multigrid then 3512 screen:expect({ 3513 grid = [[ 3514 ## grid 1 3515 [2:-------------------------]|*9 3516 [3:-------------------------]| 3517 ## grid 2 3518 some long prefix before | 3519 the text^ | 3520 {1:~ }|*7 3521 ## grid 3 3522 {5:-- INSERT --} | 3523 ## grid 4 3524 {n: word }| 3525 {n: choice }| 3526 {12: text }| 3527 {n: thing }| 3528 ]], 3529 float_pos = { [4] = { -1, 'NW', 2, 2, 3, false, 100, 1, 2, 3 } }, 3530 }) 3531 else 3532 screen:expect([[ 3533 some long prefix before | 3534 the text^ | 3535 {1:~ }{n: word }{1: }| 3536 {1:~ }{n: choice }{1: }| 3537 {1:~ }{12: text }{1: }| 3538 {1:~ }{n: thing }{1: }| 3539 {1:~ }|*3 3540 {5:-- INSERT --} | 3541 ]]) 3542 end 3543 3544 screen:try_resize(12, 5) 3545 if multigrid then 3546 screen:expect({ 3547 grid = [[ 3548 ## grid 1 3549 [2:------------]|*4 3550 [3:------------]| 3551 ## grid 2 3552 some long | 3553 prefix | 3554 before the | 3555 text^ | 3556 ## grid 3 3557 {5:-- INSERT --}| 3558 ## grid 4 3559 {n: word }| 3560 {n: choice }| 3561 {12: text }| 3562 {n: thing }| 3563 ]], 3564 float_pos = { [4] = { -1, 'NW', 2, 2, 3, false, 100, 1, 2, 3 } }, 3565 }) 3566 else 3567 screen:expect([[ 3568 some long | 3569 prefix | 3570 bef{n: word } | 3571 tex{n: }^ | 3572 {5:-- INSERT --}| 3573 ]]) 3574 end 3575 3576 -- can't draw the pum, but check we don't crash 3577 screen:try_resize(12, 2) 3578 if multigrid then 3579 screen:expect({ 3580 grid = [[ 3581 ## grid 1 3582 [2:------------]| 3583 [3:------------]| 3584 ## grid 2 3585 {1:<<<}t^ | 3586 ## grid 3 3587 {5:-- INSERT --}| 3588 ## grid 4 3589 {n: word }| 3590 {n: choice }| 3591 {12: text }| 3592 {n: thing }| 3593 ]], 3594 float_pos = { [4] = { -1, 'NW', 2, 2, 3, false, 100, 1, 2, 3 } }, 3595 }) 3596 else 3597 screen:expect([[ 3598 {1:<<<}t^ | 3599 {5:-- INSERT --}| 3600 ]]) 3601 end 3602 3603 -- but state is preserved, pum reappears 3604 screen:try_resize(20, 8) 3605 if multigrid then 3606 screen:expect({ 3607 grid = [[ 3608 ## grid 1 3609 [2:--------------------]|*7 3610 [3:--------------------]| 3611 ## grid 2 3612 some long prefix | 3613 before the text^ | 3614 {1:~ }|*5 3615 ## grid 3 3616 {5:-- INSERT --} | 3617 ## grid 4 3618 {n: word }| 3619 {n: choice }| 3620 {12: text }| 3621 {n: thing }| 3622 ]], 3623 float_pos = { [4] = { -1, 'NW', 2, 2, 3, false, 100, 1, 2, 3 } }, 3624 }) 3625 else 3626 screen:expect([[ 3627 some long prefix | 3628 before the text^ | 3629 {1:~ }{n: word }| 3630 {1:~ }{n: choice }| 3631 {1:~ }{12: text }| 3632 {1:~ }{n: thing }| 3633 {1:~ }| 3634 {5:-- INSERT --} | 3635 ]]) 3636 end 3637 end) 3638 3639 it('with VimResized autocmd', function() 3640 feed('isome long prefix before the ') 3641 command('set completeopt+=noinsert,noselect pumwidth=12') 3642 command('autocmd VimResized * redraw!') 3643 command('set linebreak') 3644 fn.complete(29, { 'word', 'choice', 'text', 'thing' }) 3645 if multigrid then 3646 screen:expect({ 3647 grid = [[ 3648 ## grid 1 3649 [2:--------------------------------]|*19 3650 [3:--------------------------------]| 3651 ## grid 2 3652 some long prefix before the ^ | 3653 {1:~ }|*18 3654 ## grid 3 3655 {5:-- INSERT --} | 3656 ## grid 4 3657 {n: word }| 3658 {n: choice }| 3659 {n: text }| 3660 {n: thing }| 3661 ]], 3662 float_pos = { [4] = { -1, 'NW', 2, 1, 18, false, 100, 1, 1, 18 } }, 3663 }) 3664 else 3665 screen:expect([[ 3666 some long prefix before the ^ | 3667 {1:~ }{n: word }| 3668 {1:~ }{n: choice }| 3669 {1:~ }{n: text }| 3670 {1:~ }{n: thing }| 3671 {1:~ }|*14 3672 {5:-- INSERT --} | 3673 ]]) 3674 end 3675 3676 screen:try_resize(16, 10) 3677 if multigrid then 3678 screen:expect({ 3679 grid = [[ 3680 ## grid 1 3681 [2:----------------]|*9 3682 [3:----------------]| 3683 ## grid 2 3684 some long | 3685 prefix before | 3686 the ^ | 3687 {1:~ }|*6 3688 ## grid 3 3689 {5:-- INSERT --} | 3690 ## grid 4 3691 {n: word }| 3692 {n: choice }| 3693 {n: text }| 3694 {n: thing }| 3695 ]], 3696 float_pos = { [4] = { -1, 'NW', 2, 3, 3, false, 100, 1, 3, 3 } }, 3697 }) 3698 else 3699 screen:expect([[ 3700 some long | 3701 prefix before | 3702 the ^ | 3703 {1:~ }{n: word }| 3704 {1:~ }{n: choice }| 3705 {1:~ }{n: text }| 3706 {1:~ }{n: thing }| 3707 {1:~ }|*2 3708 {5:-- INSERT --} | 3709 ]]) 3710 end 3711 end) 3712 3713 it('with rightleft window', function() 3714 command('set rl wildoptions+=pum') 3715 feed('isome rightleft ') 3716 if multigrid then 3717 screen:expect([[ 3718 ## grid 1 3719 [2:--------------------------------]|*19 3720 [3:--------------------------------]| 3721 ## grid 2 3722 ^ tfelthgir emos| 3723 {1: ~}|*18 3724 ## grid 3 3725 {5:-- INSERT --} | 3726 ]]) 3727 else 3728 screen:expect([[ 3729 ^ tfelthgir emos| 3730 {1: ~}|*18 3731 {5:-- INSERT --} | 3732 ]]) 3733 end 3734 3735 command('set completeopt+=noinsert,noselect') 3736 fn.complete(16, { 'word', 'choice', 'text', 'thing' }) 3737 if multigrid then 3738 screen:expect({ 3739 grid = [[ 3740 ## grid 1 3741 [2:--------------------------------]|*19 3742 [3:--------------------------------]| 3743 ## grid 2 3744 ^ tfelthgir emos| 3745 {1: ~}|*18 3746 ## grid 3 3747 {5:-- INSERT --} | 3748 ## grid 4 3749 {n: drow }| 3750 {n: eciohc }| 3751 {n: txet }| 3752 {n: gniht }| 3753 ]], 3754 float_pos = { [4] = { -1, 'NW', 2, 1, 2, false, 100, 1, 1, 2 } }, 3755 }) 3756 else 3757 screen:expect([[ 3758 ^ tfelthgir emos| 3759 {1: }{n: drow }{1: ~}| 3760 {1: }{n: eciohc }{1: ~}| 3761 {1: }{n: txet }{1: ~}| 3762 {1: }{n: gniht }{1: ~}| 3763 {1: ~}|*14 3764 {5:-- INSERT --} | 3765 ]]) 3766 end 3767 3768 feed('<c-n>') 3769 if multigrid then 3770 screen:expect({ 3771 grid = [[ 3772 ## grid 1 3773 [2:--------------------------------]|*19 3774 [3:--------------------------------]| 3775 ## grid 2 3776 ^ drow tfelthgir emos| 3777 {1: ~}|*18 3778 ## grid 3 3779 {5:-- INSERT --} | 3780 ## grid 4 3781 {12: drow }| 3782 {n: eciohc }| 3783 {n: txet }| 3784 {n: gniht }| 3785 ]], 3786 float_pos = { [4] = { -1, 'NW', 2, 1, 2, false, 100, 1, 1, 2 } }, 3787 }) 3788 else 3789 screen:expect([[ 3790 ^ drow tfelthgir emos| 3791 {1: }{12: drow }{1: ~}| 3792 {1: }{n: eciohc }{1: ~}| 3793 {1: }{n: txet }{1: ~}| 3794 {1: }{n: gniht }{1: ~}| 3795 {1: ~}|*14 3796 {5:-- INSERT --} | 3797 ]]) 3798 end 3799 3800 feed('<c-y>') 3801 if multigrid then 3802 screen:expect([[ 3803 ## grid 1 3804 [2:--------------------------------]|*19 3805 [3:--------------------------------]| 3806 ## grid 2 3807 ^ drow tfelthgir emos| 3808 {1: ~}|*18 3809 ## grid 3 3810 {5:-- INSERT --} | 3811 ]]) 3812 else 3813 screen:expect([[ 3814 ^ drow tfelthgir emos| 3815 {1: ~}|*18 3816 {5:-- INSERT --} | 3817 ]]) 3818 end 3819 3820 -- oldtest: Test_wildmenu_pum_rightleft() 3821 feed('<esc>:sign ') 3822 if multigrid then 3823 screen:expect([[ 3824 ## grid 1 3825 [2:--------------------------------]|*19 3826 [3:--------------------------------]| 3827 ## grid 2 3828 drow tfelthgir emos| 3829 {1: ~}|*18 3830 ## grid 3 3831 :sign ^ | 3832 ]]) 3833 else 3834 screen:expect([[ 3835 drow tfelthgir emos| 3836 {1: ~}|*18 3837 :sign ^ | 3838 ]]) 3839 end 3840 -- Not rightleft on the cmdline. 3841 feed('<Tab>') 3842 if multigrid then 3843 screen:expect({ 3844 grid = [[ 3845 ## grid 1 3846 [2:--------------------------------]|*19 3847 [3:--------------------------------]| 3848 ## grid 2 3849 drow tfelthgir emos| 3850 {1: ~}|*18 3851 ## grid 3 3852 :sign define^ | 3853 ## grid 4 3854 {12: define }| 3855 {n: jump }| 3856 {n: list }| 3857 {n: place }| 3858 {n: undefine }| 3859 {n: unplace }| 3860 ]], 3861 float_pos = { [4] = { -1, 'SW', 1, 19, 5, false, 250, 2, 13, 5 } }, 3862 }) 3863 else 3864 screen:expect([[ 3865 drow tfelthgir emos| 3866 {1: ~}|*12 3867 {1: }{12: define }{1: ~}| 3868 {1: }{n: jump }{1: ~}| 3869 {1: }{n: list }{1: ~}| 3870 {1: }{n: place }{1: ~}| 3871 {1: }{n: undefine }{1: ~}| 3872 {1: }{n: unplace }{1: ~}| 3873 :sign define^ | 3874 ]]) 3875 end 3876 3877 -- Behavior is the same when using 'keymap'. 3878 feed('<Esc>') 3879 command('set keymap=dvorak') 3880 -- ";gul" -> "sign" when using Dvorak keymap. 3881 feed(':<C-^>;gul <Tab>') 3882 screen:expect_unchanged(true) 3883 feed('<Esc>') 3884 command('set keymap&') 3885 end) 3886 3887 it('with rightleft vsplits', function() 3888 screen:try_resize(40, 6) 3889 command('set rightleft') 3890 command('rightbelow vsplit') 3891 command('set completeopt+=noinsert,noselect') 3892 command('set pumheight=2') 3893 feed('isome rightleft ') 3894 fn.complete(16, { 'word', 'choice', 'text', 'thing' }) 3895 if multigrid then 3896 screen:expect { 3897 grid = [[ 3898 ## grid 1 3899 [2:-------------------]│[4:--------------------]|*4 3900 {2:[No Name] [+] }{3:[No Name] [+] }| 3901 [3:----------------------------------------]| 3902 ## grid 2 3903 tfelthgir emos| 3904 {1: ~}|*3 3905 ## grid 3 3906 {5:-- INSERT --} | 3907 ## grid 4 3908 ^ tfelthgir emos| 3909 {1: ~}|*3 3910 ## grid 5 3911 {c: }{n: drow }| 3912 {12: }{n: eciohc }| 3913 ]], 3914 float_pos = { [5] = { -1, 'NW', 4, 1, -11, false, 100, 1, 1, 9 } }, 3915 } 3916 else 3917 screen:expect([[ 3918 tfelthgir emos│ ^ tfelthgir emos| 3919 {1: }{c: }{n: drow }{1: ~}| 3920 {1: }{12: }{n: eciohc }{1: ~}| 3921 {1: ~}│{1: ~}| 3922 {2:[No Name] [+] }{3:[No Name] [+] }| 3923 {5:-- INSERT --} | 3924 ]]) 3925 end 3926 feed('<C-E><CR>') 3927 fn.complete(1, { 'word', 'choice', 'text', 'thing' }) 3928 if multigrid then 3929 screen:expect { 3930 grid = [[ 3931 ## grid 1 3932 [2:-------------------]│[4:--------------------]|*4 3933 {2:[No Name] [+] }{3:[No Name] [+] }| 3934 [3:----------------------------------------]| 3935 ## grid 2 3936 tfelthgir emos| 3937 | 3938 {1: ~}|*2 3939 ## grid 3 3940 {5:-- INSERT --} | 3941 ## grid 4 3942 tfelthgir emos| 3943 ^ | 3944 {1: ~}|*2 3945 ## grid 5 3946 {c: }{n: drow}| 3947 {12: }{n: eciohc}| 3948 ]], 3949 float_pos = { [5] = { -1, 'NW', 4, 2, 4, false, 100, 1, 2, 24 } }, 3950 } 3951 else 3952 screen:expect([[ 3953 tfelthgir emos│ tfelthgir emos| 3954 │ ^ | 3955 {1: ~}│{1: }{c: }{n: drow}| 3956 {1: ~}│{1: }{12: }{n: eciohc}| 3957 {2:[No Name] [+] }{3:[No Name] [+] }| 3958 {5:-- INSERT --} | 3959 ]]) 3960 end 3961 feed('<C-E>') 3962 async_meths.nvim_call_function('input', { '', '', 'sign' }) 3963 if multigrid then 3964 screen:expect([[ 3965 ## grid 1 3966 [2:-------------------]│[4:--------------------]|*4 3967 {2:[No Name] [+] }{3:[No Name] [+] }| 3968 [3:----------------------------------------]| 3969 ## grid 2 3970 tfelthgir emos| 3971 | 3972 {1: ~}|*2 3973 ## grid 3 3974 ^ | 3975 ## grid 4 3976 tfelthgir emos| 3977 | 3978 {1: ~}|*2 3979 ]]) 3980 else 3981 screen:expect([[ 3982 tfelthgir emos│ tfelthgir emos| 3983 │ | 3984 {1: ~}│{1: ~}|*2 3985 {2:[No Name] [+] }{3:[No Name] [+] }| 3986 ^ | 3987 ]]) 3988 end 3989 command('set wildoptions+=pum') 3990 feed('<Tab>') 3991 if multigrid then 3992 screen:expect { 3993 grid = [[ 3994 ## grid 1 3995 [2:-------------------]│[4:--------------------]|*4 3996 {2:[No Name] [+] }{3:[No Name] [+] }| 3997 [3:----------------------------------------]| 3998 ## grid 2 3999 tfelthgir emos| 4000 | 4001 {1: ~}|*2 4002 ## grid 3 4003 define^ | 4004 ## grid 4 4005 tfelthgir emos| 4006 | 4007 {1: ~}|*2 4008 ## grid 5 4009 {12:define }{c: }| 4010 {n:jump }{12: }| 4011 ]], 4012 float_pos = { [5] = { -1, 'SW', 1, 5, 0, false, 250, 2, 3, 0 } }, 4013 } 4014 else 4015 screen:expect([[ 4016 tfelthgir emos│ tfelthgir emos| 4017 │ | 4018 {1: ~}│{1: ~}| 4019 {12:define }{c: }{1: ~}│{1: ~}| 4020 {n:jump }{12: }{2: }{3:[No Name] [+] }| 4021 define^ | 4022 ]]) 4023 end 4024 end) 4025 4026 it('with multiline messages', function() 4027 screen:try_resize(40, 8) 4028 feed('ixx<cr>') 4029 command('imap <f2> <cmd>echoerr "very"\\|echoerr "much"\\|echoerr "error"<cr>') 4030 fn.complete(1, { 'word', 'choice', 'text', 'thing' }) 4031 if multigrid then 4032 screen:expect({ 4033 grid = [[ 4034 ## grid 1 4035 [2:----------------------------------------]|*7 4036 [3:----------------------------------------]| 4037 ## grid 2 4038 xx | 4039 word^ | 4040 {1:~ }|*5 4041 ## grid 3 4042 {5:-- INSERT --} | 4043 ## grid 4 4044 {12:word }| 4045 {n:choice }| 4046 {n:text }| 4047 {n:thing }| 4048 ]], 4049 float_pos = { [4] = { -1, 'NW', 2, 2, 0, false, 100, 1, 2, 0 } }, 4050 }) 4051 else 4052 screen:expect([[ 4053 xx | 4054 word^ | 4055 {12:word }{1: }| 4056 {n:choice }{1: }| 4057 {n:text }{1: }| 4058 {n:thing }{1: }| 4059 {1:~ }| 4060 {5:-- INSERT --} | 4061 ]]) 4062 end 4063 4064 feed('<f2>') 4065 if multigrid then 4066 screen:expect({ 4067 grid = [[ 4068 ## grid 1 4069 [2:----------------------------------------]|*4 4070 [3:----------------------------------------]|*4 4071 ## grid 2 4072 xx | 4073 word | 4074 {1:~ }|*5 4075 ## grid 3 4076 {9:very} | 4077 {9:much} | 4078 {9:error} | 4079 {6:Press ENTER or type command to continue}^ | 4080 ## grid 4 4081 {12:word }| 4082 {n:choice }| 4083 {n:text }| 4084 {n:thing }| 4085 ]], 4086 float_pos = { [4] = { -1, 'NW', 2, 2, 0, false, 100, 1, 2, 0 } }, 4087 }) 4088 else 4089 screen:expect([[ 4090 xx | 4091 word | 4092 {12:word }{1: }| 4093 {3: }| 4094 {9:very} | 4095 {9:much} | 4096 {9:error} | 4097 {6:Press ENTER or type command to continue}^ | 4098 ]]) 4099 end 4100 4101 feed('<cr>') 4102 if multigrid then 4103 screen:expect({ 4104 grid = [[ 4105 ## grid 1 4106 [2:----------------------------------------]|*7 4107 [3:----------------------------------------]| 4108 ## grid 2 4109 xx | 4110 word^ | 4111 {1:~ }|*5 4112 ## grid 3 4113 {5:-- INSERT --} | 4114 ## grid 4 4115 {12:word }| 4116 {n:choice }| 4117 {n:text }| 4118 {n:thing }| 4119 ]], 4120 float_pos = { [4] = { -1, 'NW', 2, 2, 0, false, 100, 1, 2, 0 } }, 4121 }) 4122 else 4123 screen:expect([[ 4124 xx | 4125 word^ | 4126 {12:word }{1: }| 4127 {n:choice }{1: }| 4128 {n:text }{1: }| 4129 {n:thing }{1: }| 4130 {1:~ }| 4131 {5:-- INSERT --} | 4132 ]]) 4133 end 4134 4135 feed('<c-n>') 4136 if multigrid then 4137 screen:expect({ 4138 grid = [[ 4139 ## grid 1 4140 [2:----------------------------------------]|*7 4141 [3:----------------------------------------]| 4142 ## grid 2 4143 xx | 4144 choice^ | 4145 {1:~ }|*5 4146 ## grid 3 4147 {5:-- INSERT --} | 4148 ## grid 4 4149 {n:word }| 4150 {12:choice }| 4151 {n:text }| 4152 {n:thing }| 4153 ]], 4154 float_pos = { [4] = { -1, 'NW', 2, 2, 0, false, 100, 1, 2, 0 } }, 4155 }) 4156 else 4157 screen:expect([[ 4158 xx | 4159 choice^ | 4160 {n:word }{1: }| 4161 {12:choice }{1: }| 4162 {n:text }{1: }| 4163 {n:thing }{1: }| 4164 {1:~ }| 4165 {5:-- INSERT --} | 4166 ]]) 4167 end 4168 4169 command('split') 4170 feed('<c-u>') 4171 fn.complete(1, { 'word', 'choice', 'text', 'thing' }) 4172 if multigrid then 4173 screen:expect({ 4174 grid = [[ 4175 ## grid 1 4176 [5:----------------------------------------]|*3 4177 {3:[No Name] [+] }| 4178 [2:----------------------------------------]|*2 4179 {2:[No Name] [+] }| 4180 [3:----------------------------------------]| 4181 ## grid 2 4182 xx | 4183 word | 4184 ## grid 3 4185 {5:-- INSERT --} | 4186 ## grid 4 4187 {12:word }| 4188 {n:choice }| 4189 {n:text }| 4190 {n:thing }| 4191 ## grid 5 4192 xx | 4193 word^ | 4194 {1:~ }| 4195 ]], 4196 float_pos = { [4] = { -1, 'NW', 5, 2, 0, false, 100, 1, 2, 0 } }, 4197 }) 4198 else 4199 screen:expect([[ 4200 xx | 4201 word^ | 4202 {12:word }{1: }| 4203 {n:choice }{3: }| 4204 {n:text } | 4205 {n:thing } | 4206 {2:[No Name] [+] }| 4207 {5:-- INSERT --} | 4208 ]]) 4209 end 4210 4211 api.nvim_input_mouse('wheel', 'down', '', 0, 6, 15) 4212 if multigrid then 4213 screen:expect({ 4214 grid = [[ 4215 ## grid 1 4216 [5:----------------------------------------]|*3 4217 {3:[No Name] [+] }| 4218 [2:----------------------------------------]|*2 4219 {2:[No Name] [+] }| 4220 [3:----------------------------------------]| 4221 ## grid 2 4222 word | 4223 {1:~ }| 4224 ## grid 3 4225 {5:-- INSERT --} | 4226 ## grid 4 4227 {12:word }| 4228 {n:choice }| 4229 {n:text }| 4230 {n:thing }| 4231 ## grid 5 4232 xx | 4233 word^ | 4234 {1:~ }| 4235 ]], 4236 float_pos = { [4] = { -1, 'NW', 5, 2, 0, false, 100, 1, 2, 0 } }, 4237 }) 4238 else 4239 screen:expect([[ 4240 xx | 4241 word^ | 4242 {12:word }{1: }| 4243 {n:choice }{3: }| 4244 {n:text } | 4245 {n:thing }{1: }| 4246 {2:[No Name] [+] }| 4247 {5:-- INSERT --} | 4248 ]]) 4249 end 4250 end) 4251 4252 if not multigrid then 4253 it('with kind, menu and abbr attributes', function() 4254 screen:try_resize(40, 8) 4255 feed('ixx ') 4256 fn.complete(4, { 4257 { word = 'wordey', kind = 'x', menu = 'extrainfo' }, 4258 'thing', 4259 { word = 'secret', abbr = 'sneaky', menu = 'bar' }, 4260 }) 4261 screen:expect([[ 4262 xx wordey^ | 4263 {1:~ }{12: wordey x extrainfo }{1: }| 4264 {1:~ }{n: thing }{1: }| 4265 {1:~ }{n: sneaky bar }{1: }| 4266 {1:~ }|*3 4267 {5:-- INSERT --} | 4268 ]]) 4269 4270 feed('<c-p>') 4271 screen:expect([[ 4272 xx ^ | 4273 {1:~ }{n: wordey x extrainfo }{1: }| 4274 {1:~ }{n: thing }{1: }| 4275 {1:~ }{n: sneaky bar }{1: }| 4276 {1:~ }|*3 4277 {5:-- INSERT --} | 4278 ]]) 4279 4280 feed('<c-p>') 4281 screen:expect([[ 4282 xx secret^ | 4283 {1:~ }{n: wordey x extrainfo }{1: }| 4284 {1:~ }{n: thing }{1: }| 4285 {1:~ }{12: sneaky bar }{1: }| 4286 {1:~ }|*3 4287 {5:-- INSERT --} | 4288 ]]) 4289 4290 feed('<esc>') 4291 screen:expect([[ 4292 xx secre^t | 4293 {1:~ }|*6 4294 | 4295 ]]) 4296 end) 4297 4298 it('wildoptions=pum', function() 4299 screen:try_resize(32, 10) 4300 command('set wildmenu') 4301 command('set wildoptions=pum') 4302 command('set shellslash') 4303 command('cd test/functional/fixtures/wildpum') 4304 4305 feed(':sign ') 4306 screen:expect([[ 4307 | 4308 {1:~ }|*8 4309 :sign ^ | 4310 ]]) 4311 4312 feed('<Tab>') 4313 screen:expect([[ 4314 | 4315 {1:~ }|*2 4316 {1:~ }{12: define }{1: }| 4317 {1:~ }{n: jump }{1: }| 4318 {1:~ }{n: list }{1: }| 4319 {1:~ }{n: place }{1: }| 4320 {1:~ }{n: undefine }{1: }| 4321 {1:~ }{n: unplace }{1: }| 4322 :sign define^ | 4323 ]]) 4324 4325 feed('<Right><Right>') 4326 screen:expect([[ 4327 | 4328 {1:~ }|*2 4329 {1:~ }{n: define }{1: }| 4330 {1:~ }{n: jump }{1: }| 4331 {1:~ }{12: list }{1: }| 4332 {1:~ }{n: place }{1: }| 4333 {1:~ }{n: undefine }{1: }| 4334 {1:~ }{n: unplace }{1: }| 4335 :sign list^ | 4336 ]]) 4337 4338 feed('<C-N>') 4339 screen:expect([[ 4340 | 4341 {1:~ }|*2 4342 {1:~ }{n: define }{1: }| 4343 {1:~ }{n: jump }{1: }| 4344 {1:~ }{n: list }{1: }| 4345 {1:~ }{12: place }{1: }| 4346 {1:~ }{n: undefine }{1: }| 4347 {1:~ }{n: unplace }{1: }| 4348 :sign place^ | 4349 ]]) 4350 4351 feed('<C-P>') 4352 screen:expect([[ 4353 | 4354 {1:~ }|*2 4355 {1:~ }{n: define }{1: }| 4356 {1:~ }{n: jump }{1: }| 4357 {1:~ }{12: list }{1: }| 4358 {1:~ }{n: place }{1: }| 4359 {1:~ }{n: undefine }{1: }| 4360 {1:~ }{n: unplace }{1: }| 4361 :sign list^ | 4362 ]]) 4363 4364 feed('<Left>') 4365 screen:expect([[ 4366 | 4367 {1:~ }|*2 4368 {1:~ }{n: define }{1: }| 4369 {1:~ }{12: jump }{1: }| 4370 {1:~ }{n: list }{1: }| 4371 {1:~ }{n: place }{1: }| 4372 {1:~ }{n: undefine }{1: }| 4373 {1:~ }{n: unplace }{1: }| 4374 :sign jump^ | 4375 ]]) 4376 4377 -- pressing <C-E> should end completion and go back to the original match 4378 feed('<C-E>') 4379 screen:expect([[ 4380 | 4381 {1:~ }|*8 4382 :sign ^ | 4383 ]]) 4384 4385 -- pressing <C-Y> should select the current match and end completion 4386 feed('<Tab><C-P><C-P><C-Y>') 4387 screen:expect([[ 4388 | 4389 {1:~ }|*8 4390 :sign unplace^ | 4391 ]]) 4392 4393 -- showing popup menu in different columns in the cmdline 4394 feed('<C-U>sign define <Tab>') 4395 screen:expect([[ 4396 | 4397 {1:~ }| 4398 {1:~ }{12: culhl= }{1: }| 4399 {1:~ }{n: icon= }{1: }| 4400 {1:~ }{n: linehl= }{1: }| 4401 {1:~ }{n: numhl= }{1: }| 4402 {1:~ }{n: priority= }{1: }| 4403 {1:~ }{n: text= }{1: }| 4404 {1:~ }{n: texthl= }{1: }| 4405 :sign define culhl=^ | 4406 ]]) 4407 4408 feed('<Space><Tab>') 4409 screen:expect([[ 4410 | 4411 {1:~ }| 4412 {1:~ }{12: culhl= }| 4413 {1:~ }{n: icon= }| 4414 {1:~ }{n: linehl= }| 4415 {1:~ }{n: numhl= }| 4416 {1:~ }{n: priority= }| 4417 {1:~ }{n: text= }| 4418 {1:~ }{n: texthl= }| 4419 :sign define culhl= culhl=^ | 4420 ]]) 4421 4422 feed('<C-U>e Xnamedi<Tab><Tab>') 4423 screen:expect([[ 4424 | 4425 {1:~ }|*6 4426 {1:~ }{12: XdirA/ }{1: }| 4427 {1:~ }{n: XfileA }{1: }| 4428 :e Xnamedir/XdirA/^ | 4429 ]]) 4430 4431 -- Pressing <Down> on a directory name should go into that directory 4432 feed('<Down>') 4433 screen:expect([[ 4434 | 4435 {1:~ }|*6 4436 {1:~ }{12: XdirB/ }| 4437 {1:~ }{n: XfileB }| 4438 :e Xnamedir/XdirA/XdirB/^ | 4439 ]]) 4440 4441 -- Pressing <Up> on a directory name should go to the parent directory 4442 feed('<Up>') 4443 screen:expect([[ 4444 | 4445 {1:~ }|*6 4446 {1:~ }{12: XdirA/ }{1: }| 4447 {1:~ }{n: XfileA }{1: }| 4448 :e Xnamedir/XdirA/^ | 4449 ]]) 4450 4451 -- Pressing <C-A> when the popup menu is displayed should list all the 4452 -- matches and remove the popup menu 4453 feed(':<C-U>sign <Tab><C-A>') 4454 screen:expect([[ 4455 | 4456 {1:~ }|*6 4457 {3: }| 4458 :sign define jump list place und| 4459 efine unplace^ | 4460 ]]) 4461 4462 -- Pressing <Left> after that should move the cursor 4463 feed('<Left>') 4464 screen:expect([[ 4465 | 4466 {1:~ }|*6 4467 {3: }| 4468 :sign define jump list place und| 4469 efine unplac^e | 4470 ]]) 4471 feed('<End>') 4472 4473 -- Pressing <C-D> when the popup menu is displayed should remove the popup 4474 -- menu 4475 feed('<C-U>sign <Tab><C-D>') 4476 screen:expect([[ 4477 | 4478 {1:~ }|*5 4479 {3: }| 4480 :sign define | 4481 define | 4482 :sign define^ | 4483 ]]) 4484 4485 -- Pressing <S-Tab> should open the popup menu with the last entry selected 4486 feed('<C-U><CR>:sign <S-Tab><C-P>') 4487 screen:expect([[ 4488 | 4489 {1:~ }|*2 4490 {1:~ }{n: define }{1: }| 4491 {1:~ }{n: jump }{1: }| 4492 {1:~ }{n: list }{1: }| 4493 {1:~ }{n: place }{1: }| 4494 {1:~ }{12: undefine }{1: }| 4495 {1:~ }{n: unplace }{1: }| 4496 :sign undefine^ | 4497 ]]) 4498 4499 -- Pressing <Esc> should close the popup menu and cancel the cmd line 4500 feed('<C-U><CR>:sign <Tab><Esc>') 4501 screen:expect([[ 4502 ^ | 4503 {1:~ }|*8 4504 | 4505 ]]) 4506 4507 -- Typing a character when the popup is open, should close the popup 4508 feed(':sign <Tab>x') 4509 screen:expect([[ 4510 | 4511 {1:~ }|*8 4512 :sign definex^ | 4513 ]]) 4514 4515 -- When the popup is open, entering the cmdline window should close the popup 4516 feed('<C-U>sign <Tab><C-F>') 4517 screen:expect([[ 4518 | 4519 {2:[No Name] }| 4520 {1::}sign define | 4521 {1::}sign define^ | 4522 {1:~ }|*4 4523 {3:[Command Line] }| 4524 :sign define | 4525 ]]) 4526 feed(':q<CR>') 4527 4528 -- After the last popup menu item, <C-N> should show the original string 4529 feed(':sign u<Tab><C-N><C-N>') 4530 screen:expect([[ 4531 | 4532 {1:~ }|*6 4533 {1:~ }{n: undefine }{1: }| 4534 {1:~ }{n: unplace }{1: }| 4535 :sign u^ | 4536 ]]) 4537 4538 -- Use the popup menu for the command name 4539 feed('<C-U>bu<Tab>') 4540 screen:expect([[ 4541 | 4542 {1:~ }|*4 4543 {12: bufdo }{1: }| 4544 {n: buffer }{1: }| 4545 {n: buffers }{1: }| 4546 {n: bunload }{1: }| 4547 :bufdo^ | 4548 ]]) 4549 4550 -- Pressing <BS> should remove the popup menu and erase the last character 4551 feed('<C-E><C-U>sign <Tab><BS>') 4552 screen:expect([[ 4553 | 4554 {1:~ }|*8 4555 :sign defin^ | 4556 ]]) 4557 4558 -- Pressing <C-W> should remove the popup menu and erase the previous word 4559 feed('<C-E><C-U>sign <Tab><C-W>') 4560 screen:expect([[ 4561 | 4562 {1:~ }|*8 4563 :sign ^ | 4564 ]]) 4565 4566 -- Pressing <C-U> should remove the popup menu and erase the entire line 4567 feed('<C-E><C-U>sign <Tab><C-U>') 4568 screen:expect([[ 4569 | 4570 {1:~ }|*8 4571 :^ | 4572 ]]) 4573 4574 -- Using <C-E> to cancel the popup menu and then pressing <Up> should recall 4575 -- the cmdline from history 4576 feed('sign xyz<Esc>:sign <Tab><C-E><Up>') 4577 screen:expect([[ 4578 | 4579 {1:~ }|*8 4580 :sign xyz^ | 4581 ]]) 4582 4583 feed('<esc>') 4584 4585 -- Check that when "longest" produces no result, "list" works 4586 command('set wildmode=longest,list') 4587 feed(':cn<Tab>') 4588 screen:expect([[ 4589 | 4590 {1:~ }|*3 4591 {3: }| 4592 :cn | 4593 cnewer cnoreabbrev | 4594 cnext cnoremap | 4595 cnfile cnoremenu | 4596 :cn^ | 4597 ]]) 4598 feed('<Tab>') 4599 screen:expect_unchanged() 4600 feed('s') 4601 screen:expect([[ 4602 | 4603 {1:~ }|*3 4604 {3: }| 4605 :cn | 4606 cnewer cnoreabbrev | 4607 cnext cnoremap | 4608 cnfile cnoremenu | 4609 :cns^ | 4610 ]]) 4611 4612 feed('<esc>') 4613 command('set wildmode=full') 4614 4615 -- Tests a directory name contained full-width characters. 4616 feed(':e あいう/<Tab>') 4617 screen:expect([[ 4618 | 4619 {1:~ }|*5 4620 {1:~ }{12: 123 }{1: }| 4621 {1:~ }{n: abc }{1: }| 4622 {1:~ }{n: xyz }{1: }| 4623 :e あいう/123^ | 4624 ]]) 4625 feed('<Esc>') 4626 4627 -- Pressing <PageDown> should scroll the menu downward 4628 feed(':sign <Tab><PageDown>') 4629 screen:expect([[ 4630 | 4631 {1:~ }|*2 4632 {1:~ }{n: define }{1: }| 4633 {1:~ }{n: jump }{1: }| 4634 {1:~ }{n: list }{1: }| 4635 {1:~ }{n: place }{1: }| 4636 {1:~ }{12: undefine }{1: }| 4637 {1:~ }{n: unplace }{1: }| 4638 :sign undefine^ | 4639 ]]) 4640 feed('<PageDown>') 4641 screen:expect([[ 4642 | 4643 {1:~ }|*2 4644 {1:~ }{n: define }{1: }| 4645 {1:~ }{n: jump }{1: }| 4646 {1:~ }{n: list }{1: }| 4647 {1:~ }{n: place }{1: }| 4648 {1:~ }{n: undefine }{1: }| 4649 {1:~ }{12: unplace }{1: }| 4650 :sign unplace^ | 4651 ]]) 4652 feed('<PageDown>') 4653 screen:expect([[ 4654 | 4655 {1:~ }|*2 4656 {1:~ }{n: define }{1: }| 4657 {1:~ }{n: jump }{1: }| 4658 {1:~ }{n: list }{1: }| 4659 {1:~ }{n: place }{1: }| 4660 {1:~ }{n: undefine }{1: }| 4661 {1:~ }{n: unplace }{1: }| 4662 :sign ^ | 4663 ]]) 4664 feed('<PageDown>') 4665 screen:expect([[ 4666 | 4667 {1:~ }|*2 4668 {1:~ }{12: define }{1: }| 4669 {1:~ }{n: jump }{1: }| 4670 {1:~ }{n: list }{1: }| 4671 {1:~ }{n: place }{1: }| 4672 {1:~ }{n: undefine }{1: }| 4673 {1:~ }{n: unplace }{1: }| 4674 :sign define^ | 4675 ]]) 4676 feed('<C-U>sign <Tab><Right><Right><PageDown>') 4677 screen:expect([[ 4678 | 4679 {1:~ }|*2 4680 {1:~ }{n: define }{1: }| 4681 {1:~ }{n: jump }{1: }| 4682 {1:~ }{n: list }{1: }| 4683 {1:~ }{n: place }{1: }| 4684 {1:~ }{n: undefine }{1: }| 4685 {1:~ }{12: unplace }{1: }| 4686 :sign unplace^ | 4687 ]]) 4688 4689 -- Pressing <PageUp> should scroll the menu upward 4690 feed('<C-U>sign <Tab><PageUp>') 4691 screen:expect([[ 4692 | 4693 {1:~ }|*2 4694 {1:~ }{n: define }{1: }| 4695 {1:~ }{n: jump }{1: }| 4696 {1:~ }{n: list }{1: }| 4697 {1:~ }{n: place }{1: }| 4698 {1:~ }{n: undefine }{1: }| 4699 {1:~ }{n: unplace }{1: }| 4700 :sign ^ | 4701 ]]) 4702 feed('<PageUp>') 4703 screen:expect([[ 4704 | 4705 {1:~ }|*2 4706 {1:~ }{n: define }{1: }| 4707 {1:~ }{n: jump }{1: }| 4708 {1:~ }{n: list }{1: }| 4709 {1:~ }{n: place }{1: }| 4710 {1:~ }{n: undefine }{1: }| 4711 {1:~ }{12: unplace }{1: }| 4712 :sign unplace^ | 4713 ]]) 4714 feed('<PageUp>') 4715 screen:expect([[ 4716 | 4717 {1:~ }|*2 4718 {1:~ }{n: define }{1: }| 4719 {1:~ }{12: jump }{1: }| 4720 {1:~ }{n: list }{1: }| 4721 {1:~ }{n: place }{1: }| 4722 {1:~ }{n: undefine }{1: }| 4723 {1:~ }{n: unplace }{1: }| 4724 :sign jump^ | 4725 ]]) 4726 feed('<PageUp>') 4727 screen:expect([[ 4728 | 4729 {1:~ }|*2 4730 {1:~ }{12: define }{1: }| 4731 {1:~ }{n: jump }{1: }| 4732 {1:~ }{n: list }{1: }| 4733 {1:~ }{n: place }{1: }| 4734 {1:~ }{n: undefine }{1: }| 4735 {1:~ }{n: unplace }{1: }| 4736 :sign define^ | 4737 ]]) 4738 4739 -- pressing <C-E> to end completion should work in middle of the line too 4740 feed('<Esc>:set wildchazz<Left><Left><Tab>') 4741 screen:expect([[ 4742 | 4743 {1:~ }|*6 4744 {1:~ }{12: wildchar }{1: }| 4745 {1:~ }{n: wildcharm }{1: }| 4746 :set wildchar^zz | 4747 ]]) 4748 feed('<C-E>') 4749 screen:expect([[ 4750 | 4751 {1:~ }|*8 4752 :set wildcha^zz | 4753 ]]) 4754 4755 -- pressing <C-Y> should select the current match and end completion 4756 feed('<Esc>:set wildchazz<Left><Left><Tab><C-Y>') 4757 screen:expect([[ 4758 | 4759 {1:~ }|*8 4760 :set wildchar^zz | 4761 ]]) 4762 4763 feed('<Esc>') 4764 4765 -- "longest:list" shows list whether it finds a candidate or not 4766 command('set wildmode=longest:list,full wildoptions=') 4767 feed(':cn<Tab>') 4768 screen:expect([[ 4769 | 4770 {1:~ }|*3 4771 {3: }| 4772 :cn | 4773 cnewer cnoreabbrev | 4774 cnext cnoremap | 4775 cnfile cnoremenu | 4776 :cn^ | 4777 ]]) 4778 feed('<Tab>') 4779 screen:expect([[ 4780 | 4781 {1:~ }|*2 4782 {3: }| 4783 :cn | 4784 cnewer cnoreabbrev | 4785 cnext cnoremap | 4786 cnfile cnoremenu | 4787 {113:cnewer}{3: cnext cnfile > }| 4788 :cnewer^ | 4789 ]]) 4790 feed('<Esc>:sign u<Tab>') 4791 screen:expect([[ 4792 | 4793 {1:~ }|*5 4794 {3: }| 4795 :sign un | 4796 undefine unplace | 4797 :sign un^ | 4798 ]]) 4799 4800 -- "longest:full" shows wildmenu whether it finds a candidate or not; 4801 -- item not selected 4802 feed('<Esc>') 4803 command('set wildmode=longest:full,full') 4804 feed(':sign u<Tab>') 4805 screen:expect([[ 4806 | 4807 {1:~ }|*7 4808 {3:undefine unplace }| 4809 :sign un^ | 4810 ]]) 4811 feed('<Tab>') 4812 screen:expect([[ 4813 | 4814 {1:~ }|*7 4815 {113:undefine}{3: unplace }| 4816 :sign undefine^ | 4817 ]]) 4818 4819 feed('<Esc>:cn<Tab>') 4820 screen:expect([[ 4821 | 4822 {1:~ }|*7 4823 {3:cnewer cnext cnfile > }| 4824 :cn^ | 4825 ]]) 4826 feed('<Tab>') 4827 screen:expect([[ 4828 | 4829 {1:~ }|*7 4830 {113:cnewer}{3: cnext cnfile > }| 4831 :cnewer^ | 4832 ]]) 4833 4834 -- If "longest,full" finds a candidate, wildmenu is not shown 4835 feed('<Esc>') 4836 command('set wildmode=longest,full') 4837 feed(':sign u<Tab>') 4838 screen:expect([[ 4839 | 4840 {1:~ }|*8 4841 :sign un^ | 4842 ]]) 4843 -- Subsequent wildchar shows wildmenu 4844 feed('<Tab>') 4845 screen:expect([[ 4846 | 4847 {1:~ }|*7 4848 {113:undefine}{3: unplace }| 4849 :sign undefine^ | 4850 ]]) 4851 4852 -- 'longest' does not find candidate, and displays menu without selecting item 4853 feed('<Esc>') 4854 command('set wildmode=longest,noselect') 4855 feed(':cn<Tab>') 4856 screen:expect([[ 4857 | 4858 {1:~ }|*7 4859 {3:cnewer cnext cnfile > }| 4860 :cn^ | 4861 ]]) 4862 4863 command('set wildmode& wildoptions=pum') 4864 4865 feed('<C-U><Esc>') 4866 4867 -- check positioning with multibyte char in pattern 4868 command('e långfile1') 4869 command('sp långfile2') 4870 feed(':b lå<tab>') 4871 screen:expect([[ 4872 | 4873 {1:~ }|*3 4874 {3:långfile2 }| 4875 | 4876 {1:~ }| 4877 {1:~ }{12: långfile1 }{1: }| 4878 {2:lå}{n: långfile2 }{2: }| 4879 :b långfile1^ | 4880 ]]) 4881 4882 -- check doesn't crash on screen resize 4883 screen:try_resize(20, 6) 4884 screen:expect([[ 4885 | 4886 {1:~ }| 4887 {3:långfile2 }| 4888 {12: långfile1 } | 4889 {2:lå}{n: långfile2 }{2: }| 4890 :b långfile1^ | 4891 ]]) 4892 4893 screen:try_resize(50, 15) 4894 screen:expect([[ 4895 | 4896 {1:~ }| 4897 {3:långfile2 }| 4898 | 4899 {1:~ }|*8 4900 {1:~ }{12: långfile1 }{1: }| 4901 {2:lå}{n: långfile2 }{2: }| 4902 :b långfile1^ | 4903 ]]) 4904 4905 -- position is calculated correctly with "longest" 4906 feed('<esc>') 4907 command('set wildmode=longest:full,full') 4908 feed(':b lå<tab>') 4909 screen:expect([[ 4910 | 4911 {1:~ }| 4912 {3:långfile2 }| 4913 | 4914 {1:~ }|*8 4915 {1:~ }{n: långfile1 }{1: }| 4916 {2:lå}{n: långfile2 }{2: }| 4917 :b långfile^ | 4918 ]]) 4919 4920 feed('<esc>') 4921 command('%bwipe') 4922 command('set wildmode=full') 4923 4924 -- special case: when patterns ends with "/", show menu items aligned 4925 -- after the "/" 4926 feed(':e compdir/<tab>') 4927 screen:expect([[ 4928 | 4929 {1:~ }|*11 4930 {1:~ }{12: file1 }{1: }| 4931 {1:~ }{n: file2 }{1: }| 4932 :e compdir/file1^ | 4933 ]]) 4934 4935 -- position is correct when expanding environment variable #20348 4936 command('cd ..') 4937 fn.setenv('XNDIR', 'wildpum/Xnamedir') 4938 feed('<C-U>e $XNDIR/<Tab>') 4939 screen:expect([[ 4940 | 4941 {1:~ }|*11 4942 {1:~ }{12: XdirA/ }{1: }| 4943 {1:~ }{n: XfileA }{1: }| 4944 :e wildpum/Xnamedir/XdirA/^ | 4945 ]]) 4946 end) 4947 end 4948 4949 it('wildoptions=pum with scrolled messages', function() 4950 screen:try_resize(40, 10) 4951 command('set wildmenu') 4952 command('set wildoptions=pum') 4953 4954 feed(':echoerr "fail"|echoerr "error"<cr>') 4955 if multigrid then 4956 screen:expect([[ 4957 ## grid 1 4958 [2:----------------------------------------]|*7 4959 [3:----------------------------------------]|*3 4960 ## grid 2 4961 | 4962 {1:~ }|*8 4963 ## grid 3 4964 {9:fail} | 4965 {9:error} | 4966 {6:Press ENTER or type command to continue}^ | 4967 ]]) 4968 else 4969 screen:expect([[ 4970 | 4971 {1:~ }|*5 4972 {3: }| 4973 {9:fail} | 4974 {9:error} | 4975 {6:Press ENTER or type command to continue}^ | 4976 ]]) 4977 end 4978 4979 feed(':sign <tab>') 4980 if multigrid then 4981 screen:expect({ 4982 grid = [[ 4983 ## grid 1 4984 [2:----------------------------------------]|*7 4985 [3:----------------------------------------]|*3 4986 ## grid 2 4987 | 4988 {1:~ }|*8 4989 ## grid 3 4990 {9:fail} | 4991 {9:error} | 4992 :sign define^ | 4993 ## grid 4 4994 {12: define }| 4995 {n: jump }| 4996 {n: list }| 4997 {n: place }| 4998 {n: undefine }| 4999 {n: unplace }| 5000 ]], 5001 float_pos = { [4] = { -1, 'SW', 1, 9, 5, false, 250, 2, 3, 5 } }, 5002 }) 5003 else 5004 screen:expect([[ 5005 | 5006 {1:~ }|*2 5007 {1:~ }{12: define }{1: }| 5008 {1:~ }{n: jump }{1: }| 5009 {1:~ }{n: list }{1: }| 5010 {3: }{n: place }{3: }| 5011 {9:fail} {n: undefine } | 5012 {9:error}{n: unplace } | 5013 :sign define^ | 5014 ]]) 5015 end 5016 5017 feed('d') 5018 if multigrid then 5019 screen:expect([[ 5020 ## grid 1 5021 [2:----------------------------------------]|*7 5022 [3:----------------------------------------]|*3 5023 ## grid 2 5024 | 5025 {1:~ }|*8 5026 ## grid 3 5027 {9:fail} | 5028 {9:error} | 5029 :sign defined^ | 5030 ]]) 5031 else 5032 screen:expect([[ 5033 | 5034 {1:~ }|*5 5035 {3: }| 5036 {9:fail} | 5037 {9:error} | 5038 :sign defined^ | 5039 ]]) 5040 end 5041 end) 5042 5043 if not multigrid then 5044 it('wildoptions=pum and wildmode=longest,full #11622', function() 5045 screen:try_resize(30, 8) 5046 command('set wildmenu') 5047 command('set wildoptions=pum') 5048 command('set wildmode=longest,full') 5049 5050 -- With 'wildmode' set to 'longest,full', completing a match should display 5051 -- the longest match, the wildmenu should not be displayed. 5052 feed(':sign u<Tab>') 5053 screen:expect([[ 5054 | 5055 {1:~ }|*6 5056 :sign un^ | 5057 ]]) 5058 eq(0, fn.wildmenumode()) 5059 5060 -- pressing <Tab> should display the wildmenu 5061 feed('<Tab>') 5062 local s1 = [[ 5063 | 5064 {1:~ }|*4 5065 {1:~ }{12: undefine }{1: }| 5066 {1:~ }{n: unplace }{1: }| 5067 :sign undefine^ | 5068 ]] 5069 screen:expect(s1) 5070 eq(1, fn.wildmenumode()) 5071 5072 -- pressing <Tab> second time should select the next entry in the menu 5073 feed('<Tab>') 5074 local s2 = [[ 5075 | 5076 {1:~ }|*4 5077 {1:~ }{n: undefine }{1: }| 5078 {1:~ }{12: unplace }{1: }| 5079 :sign unplace^ | 5080 ]] 5081 screen:expect(s2) 5082 eq(1, fn.wildmenumode()) 5083 5084 -- If "longest" finds no candidate in "longest,full", "full" is used 5085 feed('<Esc>') 5086 command('set wildmode=longest,full') 5087 command('set wildoptions=pum') 5088 feed(':sign un<Tab>') 5089 screen:expect(s1) 5090 feed('<Tab>') 5091 screen:expect(s2) 5092 5093 -- Similarly for "longest,noselect:full" 5094 feed('<Esc>') 5095 command('set wildmode=longest,noselect:full') 5096 feed(':sign un<Tab>') 5097 screen:expect([[ 5098 | 5099 {1:~ }|*4 5100 {1:~ }{n: undefine }{1: }| 5101 {1:~ }{n: unplace }{1: }| 5102 :sign un^ | 5103 ]]) 5104 feed('<Tab>') 5105 screen:expect(s1) 5106 feed('<Tab>') 5107 screen:expect(s2) 5108 end) 5109 5110 it('wildoptions=pum with a wrapped line in buffer vim-patch:8.2.4655', function() 5111 screen:try_resize(32, 10) 5112 api.nvim_buf_set_lines(0, 0, -1, true, { ('a'):rep(100) }) 5113 command('set wildoptions+=pum') 5114 feed('$') 5115 feed(':sign <Tab>') 5116 screen:expect([[ 5117 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*3 5118 aaaa {12: define } | 5119 {1:~ }{n: jump }{1: }| 5120 {1:~ }{n: list }{1: }| 5121 {1:~ }{n: place }{1: }| 5122 {1:~ }{n: undefine }{1: }| 5123 {1:~ }{n: unplace }{1: }| 5124 :sign define^ | 5125 ]]) 5126 end) 5127 5128 -- oldtest: Test_wildmenu_pum_odd_wildchar() 5129 it('wildoptions=pum with odd wildchar', function() 5130 screen:try_resize(30, 10) 5131 -- Test odd wildchar interactions with pum. Make sure they behave properly 5132 -- and don't lead to memory corruption due to improperly cleaned up memory. 5133 exec([[ 5134 set wildoptions=pum 5135 set wildchar=<C-E> 5136 ]]) 5137 5138 feed(':sign <C-E>') 5139 screen:expect([[ 5140 | 5141 {1:~ }|*2 5142 {1:~ }{12: define }{1: }| 5143 {1:~ }{n: jump }{1: }| 5144 {1:~ }{n: list }{1: }| 5145 {1:~ }{n: place }{1: }| 5146 {1:~ }{n: undefine }{1: }| 5147 {1:~ }{n: unplace }{1: }| 5148 :sign define^ | 5149 ]]) 5150 5151 -- <C-E> being a wildchar takes priority over its original functionality 5152 feed('<C-E>') 5153 screen:expect([[ 5154 | 5155 {1:~ }|*2 5156 {1:~ }{n: define }{1: }| 5157 {1:~ }{12: jump }{1: }| 5158 {1:~ }{n: list }{1: }| 5159 {1:~ }{n: place }{1: }| 5160 {1:~ }{n: undefine }{1: }| 5161 {1:~ }{n: unplace }{1: }| 5162 :sign jump^ | 5163 ]]) 5164 5165 feed('<Esc>') 5166 screen:expect([[ 5167 ^ | 5168 {1:~ }|*8 5169 | 5170 ]]) 5171 5172 -- Escape key can be wildchar too. Double-<Esc> is hard-coded to escape 5173 -- command-line, and we need to make sure to clean up properly. 5174 command('set wildchar=<Esc>') 5175 feed(':sign <Esc>') 5176 screen:expect([[ 5177 | 5178 {1:~ }|*2 5179 {1:~ }{12: define }{1: }| 5180 {1:~ }{n: jump }{1: }| 5181 {1:~ }{n: list }{1: }| 5182 {1:~ }{n: place }{1: }| 5183 {1:~ }{n: undefine }{1: }| 5184 {1:~ }{n: unplace }{1: }| 5185 :sign define^ | 5186 ]]) 5187 5188 feed('<Esc>') 5189 screen:expect([[ 5190 ^ | 5191 {1:~ }|*8 5192 | 5193 ]]) 5194 5195 -- <C-\> can also be wildchar. <C-\><C-N> however will still escape cmdline 5196 -- and we again need to make sure we clean up properly. 5197 command([[set wildchar=<C-\>]]) 5198 feed([[:sign <C-\><C-\>]]) 5199 screen:expect([[ 5200 | 5201 {1:~ }|*2 5202 {1:~ }{12: define }{1: }| 5203 {1:~ }{n: jump }{1: }| 5204 {1:~ }{n: list }{1: }| 5205 {1:~ }{n: place }{1: }| 5206 {1:~ }{n: undefine }{1: }| 5207 {1:~ }{n: unplace }{1: }| 5208 :sign define^ | 5209 ]]) 5210 5211 feed('<C-N>') 5212 screen:expect([[ 5213 ^ | 5214 {1:~ }|*8 5215 | 5216 ]]) 5217 end) 5218 5219 -- oldtest: Test_wildmenu_pum_hl_match() 5220 it('highlighting matched text in cmdline pum', function() 5221 exec([[ 5222 set wildoptions=pum,fuzzy 5223 hi PmenuMatchSel guifg=Blue guibg=Grey 5224 hi PmenuMatch guifg=Blue guibg=Plum1 5225 ]]) 5226 5227 feed(':sign plc<Tab>') 5228 screen:expect([[ 5229 | 5230 {1:~ }|*16 5231 {1:~ }{12: }{ms:pl}{12:a}{ms:c}{12:e }{1: }| 5232 {1:~ }{n: un}{mn:pl}{n:a}{mn:c}{n:e }{1: }| 5233 :sign place^ | 5234 ]]) 5235 feed('<Tab>') 5236 screen:expect([[ 5237 | 5238 {1:~ }|*16 5239 {1:~ }{n: }{mn:pl}{n:a}{mn:c}{n:e }{1: }| 5240 {1:~ }{12: un}{ms:pl}{12:a}{ms:c}{12:e }{1: }| 5241 :sign unplace^ | 5242 ]]) 5243 feed('<Tab>') 5244 screen:expect([[ 5245 | 5246 {1:~ }|*16 5247 {1:~ }{n: }{mn:pl}{n:a}{mn:c}{n:e }{1: }| 5248 {1:~ }{n: un}{mn:pl}{n:a}{mn:c}{n:e }{1: }| 5249 :sign plc^ | 5250 ]]) 5251 feed('<Esc>') 5252 command('set wildoptions-=fuzzy') 5253 feed(':sign un<Tab>') 5254 screen:expect([[ 5255 | 5256 {1:~ }|*16 5257 {1:~ }{12: }{ms:un}{12:define }{1: }| 5258 {1:~ }{n: }{mn:un}{n:place }{1: }| 5259 :sign undefine^ | 5260 ]]) 5261 feed('<Tab>') 5262 screen:expect([[ 5263 | 5264 {1:~ }|*16 5265 {1:~ }{n: }{mn:un}{n:define }{1: }| 5266 {1:~ }{12: }{ms:un}{12:place }{1: }| 5267 :sign unplace^ | 5268 ]]) 5269 feed('<Tab>') 5270 screen:expect([[ 5271 | 5272 {1:~ }|*16 5273 {1:~ }{n: }{mn:un}{n:define }{1: }| 5274 {1:~ }{n: }{mn:un}{n:place }{1: }| 5275 :sign un^ | 5276 ]]) 5277 end) 5278 5279 -- oldtest: Test_wildmenu_pum_hl_nonfirst() 5280 it('highlight matched text in the middle in cmdline pum', function() 5281 exec([[ 5282 set wildoptions=pum wildchar=<tab> wildmode=noselect,full 5283 hi PmenuMatchSel guifg=Blue guibg=Grey 5284 hi PmenuMatch guifg=Blue guibg=Plum1 5285 func T(a, c, p) 5286 return ["oneA", "o neBneB", "aoneC"] 5287 endfunc 5288 command -nargs=1 -complete=customlist,T MyCmd 5289 ]]) 5290 5291 feed(':MyCmd ne<tab>') 5292 screen:expect([[ 5293 | 5294 {1:~ }|*15 5295 {1:~ }{n: o}{mn:ne}{n:A }{1: }| 5296 {1:~ }{n: o }{mn:ne}{n:BneB }{1: }| 5297 {1:~ }{n: ao}{mn:ne}{n:C }{1: }| 5298 :MyCmd ne^ | 5299 ]]) 5300 end) 5301 5302 -- oldtest: Test_pum_scroll_noselect() 5303 it('cmdline pum does not retain scroll position with "noselect"', function() 5304 screen:try_resize(32, 10) 5305 exec([[ 5306 command! -nargs=* -complete=customlist,TestFn TestCmd echo 5307 func TestFn(a, b, c) 5308 return map(range(1, 50), 'printf("a%d", v:val)') 5309 endfunc 5310 set wildmode=noselect,full 5311 set wildoptions=pum 5312 set wildmenu 5313 set noruler 5314 ]]) 5315 5316 feed(':TestCmd <tab>' .. ('<c-n>'):rep(20)) 5317 screen:expect([[ 5318 {n: a15 }{12: } | 5319 {1:~ }{n: a16 }{12: }{1: }| 5320 {1:~ }{n: a17 }{12: }{1: }| 5321 {1:~ }{n: a18 }{c: }{1: }| 5322 {1:~ }{n: a19 }{12: }{1: }| 5323 {1:~ }{12: a20 }{1: }| 5324 {1:~ }{n: a21 }{12: }{1: }| 5325 {1:~ }{n: a22 }{12: }{1: }| 5326 {1:~ }{n: a23 }{12: }{1: }| 5327 :TestCmd a20^ | 5328 ]]) 5329 5330 feed('<esc>:TestCmd <tab>') 5331 screen:expect([[ 5332 {n: a1 }{c: } | 5333 {1:~ }{n: a2 }{12: }{1: }| 5334 {1:~ }{n: a3 }{12: }{1: }| 5335 {1:~ }{n: a4 }{12: }{1: }| 5336 {1:~ }{n: a5 }{12: }{1: }| 5337 {1:~ }{n: a6 }{12: }{1: }| 5338 {1:~ }{n: a7 }{12: }{1: }| 5339 {1:~ }{n: a8 }{12: }{1: }| 5340 {1:~ }{n: a9 }{12: }{1: }| 5341 :TestCmd ^ | 5342 ]]) 5343 end) 5344 5345 it( 5346 'cascading highlights for matched text (PmenuMatch, PmenuMatchSel) in cmdline pum', 5347 function() 5348 exec([[ 5349 set wildoptions=pum,fuzzy 5350 hi Pmenu guifg=White guibg=Grey gui=underline,italic 5351 hi PmenuSel guifg=Red gui=strikethrough 5352 hi PmenuMatch guifg=Yellow guibg=Pink gui=bold 5353 hi PmenuMatchSel guifg=Black guibg=White 5354 ]]) 5355 5356 feed(':sign plc<Tab>') 5357 screen:expect([[ 5358 | 5359 {1:~ }|*16 5360 {1:~ }{106: }{107:pl}{106:a}{107:c}{106:e }{1: }| 5361 {1:~ }{108: un}{109:pl}{108:a}{109:c}{108:e }{1: }| 5362 :sign place^ | 5363 ]]) 5364 end 5365 ) 5366 end 5367 5368 it("'pumheight'", function() 5369 screen:try_resize(32, 8) 5370 feed('isome long prefix before the ') 5371 command('set completeopt+=noinsert,noselect') 5372 command('set linebreak') 5373 command('set pumheight=2') 5374 fn.complete(29, { 'word', 'choice', 'text', 'thing' }) 5375 if multigrid then 5376 screen:expect { 5377 grid = [[ 5378 ## grid 1 5379 [2:--------------------------------]|*7 5380 [3:--------------------------------]| 5381 ## grid 2 5382 some long prefix before the ^ | 5383 {1:~ }|*6 5384 ## grid 3 5385 {5:-- INSERT --} | 5386 ## grid 4 5387 {n: word }{c: }| 5388 {n: choice }{12: }| 5389 ]], 5390 float_pos = { [4] = { -1, 'NW', 2, 1, 14, false, 100, 1, 1, 14 } }, 5391 } 5392 else 5393 screen:expect([[ 5394 some long prefix before the ^ | 5395 {1:~ }{n: word }{c: }| 5396 {1:~ }{n: choice }{12: }| 5397 {1:~ }|*4 5398 {5:-- INSERT --} | 5399 ]]) 5400 end 5401 end) 5402 5403 it("'pumwidth'", function() 5404 screen:try_resize(32, 8) 5405 feed('isome long prefix before the ') 5406 command('set completeopt+=noinsert,noselect') 5407 command('set linebreak') 5408 command('set pumwidth=8') 5409 fn.complete(29, { 'word', 'choice', 'text', 'thing' }) 5410 if multigrid then 5411 screen:expect { 5412 grid = [[ 5413 ## grid 1 5414 [2:--------------------------------]|*7 5415 [3:--------------------------------]| 5416 ## grid 2 5417 some long prefix before the ^ | 5418 {1:~ }|*6 5419 ## grid 3 5420 {5:-- INSERT --} | 5421 ## grid 4 5422 {n: word }| 5423 {n: choice }| 5424 {n: text }| 5425 {n: thing }| 5426 ]], 5427 float_pos = { [4] = { -1, 'NW', 2, 1, 22, false, 100, 1, 1, 22 } }, 5428 } 5429 else 5430 screen:expect([[ 5431 some long prefix before the ^ | 5432 {1:~ }{n: word }| 5433 {1:~ }{n: choice }| 5434 {1:~ }{n: text }| 5435 {1:~ }{n: thing }| 5436 {1:~ }|*2 5437 {5:-- INSERT --} | 5438 ]]) 5439 end 5440 end) 5441 5442 -- oldtest: Test_pum_maxwidth() 5443 it("'pummaxwidth'", function() 5444 screen:try_resize(60, 8) 5445 api.nvim_buf_set_lines(0, 0, -1, true, { 5446 '123456789_123456789_123456789_a', 5447 '123456789_123456789_123456789_b', 5448 ' 123', 5449 }) 5450 feed('G"zyy') 5451 feed('A<C-X><C-N>') 5452 if multigrid then 5453 screen:expect({ 5454 grid = [[ 5455 ## grid 1 5456 [2:------------------------------------------------------------]|*7 5457 [3:------------------------------------------------------------]| 5458 ## grid 2 5459 123456789_123456789_123456789_a | 5460 123456789_123456789_123456789_b | 5461 123456789_123456789_123456789_a^ | 5462 {1:~ }|*4 5463 ## grid 3 5464 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 5465 ## grid 4 5466 {12: 123456789_123456789_123456789_a }| 5467 {n: 123456789_123456789_123456789_b }| 5468 ]], 5469 float_pos = { [4] = { -1, 'NW', 2, 3, 11, false, 100, 1, 3, 11 } }, 5470 }) 5471 else 5472 screen:expect([[ 5473 123456789_123456789_123456789_a | 5474 123456789_123456789_123456789_b | 5475 123456789_123456789_123456789_a^ | 5476 {1:~ }{12: 123456789_123456789_123456789_a }{1: }| 5477 {1:~ }{n: 123456789_123456789_123456789_b }{1: }| 5478 {1:~ }|*2 5479 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 5480 ]]) 5481 end 5482 feed('<Esc>3Gdd"zp') 5483 5484 command('set pummaxwidth=10') 5485 feed('GA<C-X><C-N>') 5486 if multigrid then 5487 screen:expect({ 5488 grid = [[ 5489 ## grid 1 5490 [2:------------------------------------------------------------]|*7 5491 [3:------------------------------------------------------------]| 5492 ## grid 2 5493 123456789_123456789_123456789_a | 5494 123456789_123456789_123456789_b | 5495 123456789_123456789_123456789_a^ | 5496 {1:~ }|*4 5497 ## grid 3 5498 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 5499 ## grid 4 5500 {12: 123456789>}| 5501 {n: 123456789>}| 5502 ]], 5503 float_pos = { [4] = { -1, 'NW', 2, 3, 11, false, 100, 1, 3, 11 } }, 5504 }) 5505 else 5506 screen:expect([[ 5507 123456789_123456789_123456789_a | 5508 123456789_123456789_123456789_b | 5509 123456789_123456789_123456789_a^ | 5510 {1:~ }{12: 123456789>}{1: }| 5511 {1:~ }{n: 123456789>}{1: }| 5512 {1:~ }|*2 5513 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 5514 ]]) 5515 end 5516 feed('<Esc>3Gdd"zp') 5517 5518 command('set pummaxwidth=20') 5519 feed('GA<C-X><C-N>') 5520 if multigrid then 5521 screen:expect({ 5522 grid = [[ 5523 ## grid 1 5524 [2:------------------------------------------------------------]|*7 5525 [3:------------------------------------------------------------]| 5526 ## grid 2 5527 123456789_123456789_123456789_a | 5528 123456789_123456789_123456789_b | 5529 123456789_123456789_123456789_a^ | 5530 {1:~ }|*4 5531 ## grid 3 5532 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 5533 ## grid 4 5534 {12: 123456789_123456789>}| 5535 {n: 123456789_123456789>}| 5536 ]], 5537 float_pos = { [4] = { -1, 'NW', 2, 3, 11, false, 100, 1, 3, 11 } }, 5538 }) 5539 else 5540 screen:expect([[ 5541 123456789_123456789_123456789_a | 5542 123456789_123456789_123456789_b | 5543 123456789_123456789_123456789_a^ | 5544 {1:~ }{12: 123456789_123456789>}{1: }| 5545 {1:~ }{n: 123456789_123456789>}{1: }| 5546 {1:~ }|*2 5547 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 5548 ]]) 5549 end 5550 feed('<Esc>3Gdd"zp') 5551 5552 command('set pumwidth=20 pummaxwidth=8') 5553 feed('GA<C-X><C-N>') 5554 if multigrid then 5555 screen:expect({ 5556 grid = [[ 5557 ## grid 1 5558 [2:------------------------------------------------------------]|*7 5559 [3:------------------------------------------------------------]| 5560 ## grid 2 5561 123456789_123456789_123456789_a | 5562 123456789_123456789_123456789_b | 5563 123456789_123456789_123456789_a^ | 5564 {1:~ }|*4 5565 ## grid 3 5566 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 5567 ## grid 4 5568 {12: 1234567>}| 5569 {n: 1234567>}| 5570 ]], 5571 float_pos = { [4] = { -1, 'NW', 2, 3, 11, false, 100, 1, 3, 11 } }, 5572 }) 5573 else 5574 screen:expect([[ 5575 123456789_123456789_123456789_a | 5576 123456789_123456789_123456789_b | 5577 123456789_123456789_123456789_a^ | 5578 {1:~ }{12: 1234567>}{1: }| 5579 {1:~ }{n: 1234567>}{1: }| 5580 {1:~ }|*2 5581 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 5582 ]]) 5583 end 5584 feed('<Esc>3Gdd"zp') 5585 5586 screen:try_resize(32, 10) 5587 feed('GA<C-X><C-N>') 5588 if multigrid then 5589 screen:expect({ 5590 grid = [[ 5591 ## grid 1 5592 [2:--------------------------------]|*9 5593 [3:--------------------------------]| 5594 ## grid 2 5595 123456789_123456789_123456789_a | 5596 123456789_123456789_123456789_b | 5597 123456789_123456789_| 5598 123456789_a^ | 5599 {1:~ }|*5 5600 ## grid 3 5601 {5:-- }{6:match 1 of 2} | 5602 ## grid 4 5603 {12: 1234567>}| 5604 {n: 1234567>}| 5605 ]], 5606 float_pos = { [4] = { -1, 'NW', 2, 4, 11, false, 100, 1, 4, 11 } }, 5607 }) 5608 else 5609 screen:expect([[ 5610 123456789_123456789_123456789_a | 5611 123456789_123456789_123456789_b | 5612 123456789_123456789_| 5613 123456789_a^ | 5614 {1:~ }{12: 1234567>}{1: }| 5615 {1:~ }{n: 1234567>}{1: }| 5616 {1:~ }|*3 5617 {5:-- }{6:match 1 of 2} | 5618 ]]) 5619 end 5620 feed('<Esc>3Gdd"zp') 5621 end) 5622 5623 -- oldtest: Test_pum_maxwidth_multibyte() 5624 it("'pummaxwidth' with multibyte", function() 5625 screen:try_resize(60, 8) 5626 exec([[ 5627 hi StrikeFake guifg=DarkRed 5628 let g:change = 0 5629 func Omni_test(findstart, base) 5630 if a:findstart 5631 return col(".") 5632 endif 5633 if g:change == 0 5634 return [ 5635 \ #{word: "123456789_123456789_123456789_"}, 5636 \ #{word: "一二三四五六七八九十"}, 5637 \ #{word: "abcdefghij"}, 5638 \ #{word: "上下左右"}, 5639 \ ] 5640 elseif g:change == 1 5641 return [ 5642 \ #{word: "foo", menu: "fooMenu", kind: "fooKind"}, 5643 \ #{word: "bar", menu: "barMenu", kind: "barKind"}, 5644 \ #{word: "baz", menu: "bazMenu", kind: "bazKind"}, 5645 \ ] 5646 elseif g:change == 2 5647 return [ 5648 \ #{word: "foo", menu: "fooMenu", kind: "fooKind"}, 5649 \ #{word: "bar", menu: "fooMenu", kind: "一二三四"}, 5650 \ #{word: "一二三四五", kind: "multi"}, 5651 \ ] 5652 return [#{word: "bar", menu: "fooMenu", kind: "一二三"}] 5653 elseif g:change == 3 5654 return [#{word: "bar", menu: "fooMenu", kind: "一二三"}] 5655 else 5656 return [ 5657 \ #{word: "一二三四五六七八九十", abbr_hlgroup: "StrikeFake"}, 5658 \ #{word: "123456789_123456789_123456789_", abbr_hlgroup: "StrikeFake"}, 5659 \ ] 5660 endif 5661 endfunc 5662 set omnifunc=Omni_test 5663 set cot+=menuone 5664 ]]) 5665 5666 feed('S<C-X><C-O>') 5667 if multigrid then 5668 screen:expect({ 5669 grid = [[ 5670 ## grid 1 5671 [2:------------------------------------------------------------]|*7 5672 [3:------------------------------------------------------------]| 5673 ## grid 2 5674 123456789_123456789_123456789_^ | 5675 {1:~ }|*6 5676 ## grid 3 5677 {5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 5678 ## grid 4 5679 {12:123456789_123456789_123456789_ }| 5680 {n:一二三四五六七八九十 }| 5681 {n:abcdefghij }| 5682 {n:上下左右 }| 5683 ]], 5684 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 5685 }) 5686 else 5687 screen:expect([[ 5688 123456789_123456789_123456789_^ | 5689 {12:123456789_123456789_123456789_ }{1: }| 5690 {n:一二三四五六七八九十 }{1: }| 5691 {n:abcdefghij }{1: }| 5692 {n:上下左右 }{1: }| 5693 {1:~ }|*2 5694 {5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 5695 ]]) 5696 end 5697 feed('<Esc>') 5698 5699 command('set pummaxwidth=10') 5700 feed('S<C-X><C-O>') 5701 if multigrid then 5702 screen:expect({ 5703 grid = [[ 5704 ## grid 1 5705 [2:------------------------------------------------------------]|*7 5706 [3:------------------------------------------------------------]| 5707 ## grid 2 5708 123456789_123456789_123456789_^ | 5709 {1:~ }|*6 5710 ## grid 3 5711 {5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 5712 ## grid 4 5713 {12:123456789>}| 5714 {n:一二三四 >}| 5715 {n:abcdefghij}| 5716 {n:上下左右 }| 5717 ]], 5718 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 5719 }) 5720 else 5721 screen:expect([[ 5722 123456789_123456789_123456789_^ | 5723 {12:123456789>}{1: }| 5724 {n:一二三四 >}{1: }| 5725 {n:abcdefghij}{1: }| 5726 {n:上下左右 }{1: }| 5727 {1:~ }|*2 5728 {5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 5729 ]]) 5730 end 5731 feed('<Esc>') 5732 5733 command('set rightleft') 5734 feed('S<C-X><C-O>') 5735 if multigrid then 5736 screen:expect({ 5737 grid = [[ 5738 ## grid 1 5739 [2:------------------------------------------------------------]|*7 5740 [3:------------------------------------------------------------]| 5741 ## grid 2 5742 ^ _987654321_987654321_987654321| 5743 {1: ~}|*6 5744 ## grid 3 5745 {5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 5746 ## grid 4 5747 {12:<987654321}| 5748 {n:< 四三二一}| 5749 {n:jihgfedcba}| 5750 {n: 右左下上}| 5751 ]], 5752 float_pos = { [4] = { -1, 'NW', 2, 1, 50, false, 100, 1, 1, 50 } }, 5753 }) 5754 else 5755 screen:expect([[ 5756 ^ _987654321_987654321_987654321| 5757 {1: }{12:<987654321}| 5758 {1: }{n:< 四三二一}| 5759 {1: }{n:jihgfedcba}| 5760 {1: }{n: 右左下上}| 5761 {1: ~}|*2 5762 {5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 5763 ]]) 5764 end 5765 feed('<Esc>') 5766 command('set norightleft') 5767 5768 command('set pummaxwidth=2') 5769 feed('S<C-X><C-O>') 5770 if multigrid then 5771 screen:expect({ 5772 grid = [[ 5773 ## grid 1 5774 [2:------------------------------------------------------------]|*7 5775 [3:------------------------------------------------------------]| 5776 ## grid 2 5777 123456789_123456789_123456789_^ | 5778 {1:~ }|*6 5779 ## grid 3 5780 {5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 5781 ## grid 4 5782 {12:1>}| 5783 {n: >}| 5784 {n:a>}| 5785 {n: >}| 5786 ]], 5787 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 5788 }) 5789 else 5790 screen:expect([[ 5791 123456789_123456789_123456789_^ | 5792 {12:1>}{1: }| 5793 {n: >}{1: }| 5794 {n:a>}{1: }| 5795 {n: >}{1: }| 5796 {1:~ }|*2 5797 {5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 5798 ]]) 5799 end 5800 feed('<Esc>') 5801 5802 screen:try_resize(32, 20) 5803 command('set pummaxwidth=14') 5804 command('let g:change=1') 5805 feed('S<C-X><C-O>') 5806 if multigrid then 5807 screen:expect({ 5808 grid = [[ 5809 ## grid 1 5810 [2:--------------------------------]|*19 5811 [3:--------------------------------]| 5812 ## grid 2 5813 foo^ | 5814 {1:~ }|*18 5815 ## grid 3 5816 {5:-- }{6:match 1 of 3} | 5817 ## grid 4 5818 {12:foo fooKind f>}| 5819 {n:bar barKind b>}| 5820 {n:baz bazKind b>}| 5821 ]], 5822 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 5823 }) 5824 else 5825 screen:expect([[ 5826 foo^ | 5827 {12:foo fooKind f>}{1: }| 5828 {n:bar barKind b>}{1: }| 5829 {n:baz bazKind b>}{1: }| 5830 {1:~ }|*15 5831 {5:-- }{6:match 1 of 3} | 5832 ]]) 5833 end 5834 feed('<Esc>') 5835 5836 -- Unicode Character U+2026 but one cell 5837 command('set fcs+=trunc:…') 5838 feed('S<C-X><C-O>') 5839 if multigrid then 5840 screen:expect({ 5841 grid = [[ 5842 ## grid 1 5843 [2:--------------------------------]|*19 5844 [3:--------------------------------]| 5845 ## grid 2 5846 foo^ | 5847 {1:~ }|*18 5848 ## grid 3 5849 {5:-- }{6:match 1 of 3} | 5850 ## grid 4 5851 {12:foo fooKind f…}| 5852 {n:bar barKind b…}| 5853 {n:baz bazKind b…}| 5854 ]], 5855 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 5856 }) 5857 else 5858 screen:expect([[ 5859 foo^ | 5860 {12:foo fooKind f…}{1: }| 5861 {n:bar barKind b…}{1: }| 5862 {n:baz bazKind b…}{1: }| 5863 {1:~ }|*15 5864 {5:-- }{6:match 1 of 3} | 5865 ]]) 5866 end 5867 feed('<Esc>') 5868 5869 command('let g:change=2') 5870 feed('S<C-X><C-O>') 5871 if multigrid then 5872 screen:expect({ 5873 grid = [[ 5874 ## grid 1 5875 [2:--------------------------------]|*19 5876 [3:--------------------------------]| 5877 ## grid 2 5878 foo^ | 5879 {1:~ }|*18 5880 ## grid 3 5881 {5:-- }{6:match 1 of 3} | 5882 ## grid 4 5883 {12:foo fo…}| 5884 {n:bar 一…}| 5885 {n:一二三四五 mu…}| 5886 ]], 5887 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 5888 }) 5889 else 5890 screen:expect([[ 5891 foo^ | 5892 {12:foo fo…}{1: }| 5893 {n:bar 一…}{1: }| 5894 {n:一二三四五 mu…}{1: }| 5895 {1:~ }|*15 5896 {5:-- }{6:match 1 of 3} | 5897 ]]) 5898 end 5899 feed('<Esc>') 5900 5901 command('set fcs&') 5902 feed('S<C-X><C-O>') 5903 if multigrid then 5904 screen:expect({ 5905 grid = [[ 5906 ## grid 1 5907 [2:--------------------------------]|*19 5908 [3:--------------------------------]| 5909 ## grid 2 5910 foo^ | 5911 {1:~ }|*18 5912 ## grid 3 5913 {5:-- }{6:match 1 of 3} | 5914 ## grid 4 5915 {12:foo fo>}| 5916 {n:bar 一>}| 5917 {n:一二三四五 mu>}| 5918 ]], 5919 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 5920 }) 5921 else 5922 screen:expect([[ 5923 foo^ | 5924 {12:foo fo>}{1: }| 5925 {n:bar 一>}{1: }| 5926 {n:一二三四五 mu>}{1: }| 5927 {1:~ }|*15 5928 {5:-- }{6:match 1 of 3} | 5929 ]]) 5930 end 5931 feed('<Esc>') 5932 5933 command('set fcs=trunc:_') 5934 command('let g:change=1') 5935 feed('S<C-X><C-O>') 5936 if multigrid then 5937 screen:expect({ 5938 grid = [[ 5939 ## grid 1 5940 [2:--------------------------------]|*19 5941 [3:--------------------------------]| 5942 ## grid 2 5943 foo^ | 5944 {1:~ }|*18 5945 ## grid 3 5946 {5:-- }{6:match 1 of 3} | 5947 ## grid 4 5948 {12:foo fooKind f_}| 5949 {n:bar barKind b_}| 5950 {n:baz bazKind b_}| 5951 ]], 5952 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 5953 }) 5954 else 5955 screen:expect([[ 5956 foo^ | 5957 {12:foo fooKind f_}{1: }| 5958 {n:bar barKind b_}{1: }| 5959 {n:baz bazKind b_}{1: }| 5960 {1:~ }|*15 5961 {5:-- }{6:match 1 of 3} | 5962 ]]) 5963 end 5964 feed('<Esc>') 5965 command('set fcs&') 5966 5967 command('set rightleft') 5968 feed('S<C-X><C-O>') 5969 if multigrid then 5970 screen:expect({ 5971 grid = [[ 5972 ## grid 1 5973 [2:--------------------------------]|*19 5974 [3:--------------------------------]| 5975 ## grid 2 5976 ^ oof| 5977 {1: ~}|*18 5978 ## grid 3 5979 {5:-- }{6:match 1 of 3} | 5980 ## grid 4 5981 {12:<f dniKoof oof}| 5982 {n:<b dniKrab rab}| 5983 {n:<b dniKzab zab}| 5984 ]], 5985 float_pos = { [4] = { -1, 'NW', 2, 1, 18, false, 100, 1, 1, 18 } }, 5986 }) 5987 else 5988 screen:expect([[ 5989 ^ oof| 5990 {1: }{12:<f dniKoof oof}| 5991 {1: }{n:<b dniKrab rab}| 5992 {1: }{n:<b dniKzab zab}| 5993 {1: ~}|*15 5994 {5:-- }{6:match 1 of 3} | 5995 ]]) 5996 end 5997 feed('<Esc>') 5998 5999 command('let g:change=2') 6000 feed('S<C-X><C-O>') 6001 if multigrid then 6002 screen:expect({ 6003 grid = [[ 6004 ## grid 1 6005 [2:--------------------------------]|*19 6006 [3:--------------------------------]| 6007 ## grid 2 6008 ^ oof| 6009 {1: ~}|*18 6010 ## grid 3 6011 {5:-- }{6:match 1 of 3} | 6012 ## grid 4 6013 {12:<of oof}| 6014 {n:<一 rab}| 6015 {n:<um 五四三二一}| 6016 ]], 6017 float_pos = { [4] = { -1, 'NW', 2, 1, 18, false, 100, 1, 1, 18 } }, 6018 }) 6019 else 6020 screen:expect([[ 6021 ^ oof| 6022 {1: }{12:<of oof}| 6023 {1: }{n:<一 rab}| 6024 {1: }{n:<um 五四三二一}| 6025 {1: ~}|*15 6026 {5:-- }{6:match 1 of 3} | 6027 ]]) 6028 end 6029 feed('<Esc>') 6030 6031 command('set fcs+=truncrl:…') 6032 feed('S<C-X><C-O>') 6033 if multigrid then 6034 screen:expect({ 6035 grid = [[ 6036 ## grid 1 6037 [2:--------------------------------]|*19 6038 [3:--------------------------------]| 6039 ## grid 2 6040 ^ oof| 6041 {1: ~}|*18 6042 ## grid 3 6043 {5:-- }{6:match 1 of 3} | 6044 ## grid 4 6045 {12:…of oof}| 6046 {n:…一 rab}| 6047 {n:…um 五四三二一}| 6048 ]], 6049 float_pos = { [4] = { -1, 'NW', 2, 1, 18, false, 100, 1, 1, 18 } }, 6050 }) 6051 else 6052 screen:expect([[ 6053 ^ oof| 6054 {1: }{12:…of oof}| 6055 {1: }{n:…一 rab}| 6056 {1: }{n:…um 五四三二一}| 6057 {1: ~}|*15 6058 {5:-- }{6:match 1 of 3} | 6059 ]]) 6060 end 6061 feed('<Esc>') 6062 6063 command('set fcs&') 6064 command('let g:change=3') 6065 feed('S<C-X><C-O>') 6066 if multigrid then 6067 screen:expect({ 6068 grid = [[ 6069 ## grid 1 6070 [2:--------------------------------]|*19 6071 [3:--------------------------------]| 6072 ## grid 2 6073 ^ rab| 6074 {1: ~}|*18 6075 ## grid 3 6076 {5:-- The only match} | 6077 ## grid 4 6078 {12:<of 三二一 rab}| 6079 ]], 6080 float_pos = { [4] = { -1, 'NW', 2, 1, 18, false, 100, 1, 1, 18 } }, 6081 }) 6082 else 6083 screen:expect([[ 6084 ^ rab| 6085 {1: }{12:<of 三二一 rab}| 6086 {1: ~}|*17 6087 {5:-- The only match} | 6088 ]]) 6089 end 6090 feed('<Esc>') 6091 command('set norightleft') 6092 6093 command('set pummaxwidth=4') 6094 command('let g:change=2') 6095 feed('S<C-X><C-O>') 6096 if multigrid then 6097 screen:expect({ 6098 grid = [[ 6099 ## grid 1 6100 [2:--------------------------------]|*19 6101 [3:--------------------------------]| 6102 ## grid 2 6103 foo^ | 6104 {1:~ }|*18 6105 ## grid 3 6106 {5:-- }{6:match 1 of 3} | 6107 ## grid 4 6108 {12:foo>}| 6109 {n:bar>}| 6110 {n:一 >}| 6111 ]], 6112 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 6113 }) 6114 else 6115 screen:expect([[ 6116 foo^ | 6117 {12:foo>}{1: }| 6118 {n:bar>}{1: }| 6119 {n:一 >}{1: }| 6120 {1:~ }|*15 6121 {5:-- }{6:match 1 of 3} | 6122 ]]) 6123 end 6124 feed('<Esc>') 6125 6126 command('set rightleft') 6127 feed('S<C-X><C-O>') 6128 if multigrid then 6129 screen:expect({ 6130 grid = [[ 6131 ## grid 1 6132 [2:--------------------------------]|*19 6133 [3:--------------------------------]| 6134 ## grid 2 6135 ^ oof| 6136 {1: ~}|*18 6137 ## grid 3 6138 {5:-- }{6:match 1 of 3} | 6139 ## grid 4 6140 {12:<oof}| 6141 {n:<rab}| 6142 {n:< 一}| 6143 ]], 6144 float_pos = { [4] = { -1, 'NW', 2, 1, 28, false, 100, 1, 1, 28 } }, 6145 }) 6146 else 6147 screen:expect([[ 6148 ^ oof| 6149 {1: }{12:<oof}| 6150 {1: }{n:<rab}| 6151 {1: }{n:< 一}| 6152 {1: ~}|*15 6153 {5:-- }{6:match 1 of 3} | 6154 ]]) 6155 end 6156 feed('<Esc>') 6157 command('set norightleft') 6158 6159 command('set pummaxwidth=16') 6160 feed('S<C-X><C-O>') 6161 if multigrid then 6162 screen:expect({ 6163 grid = [[ 6164 ## grid 1 6165 [2:--------------------------------]|*19 6166 [3:--------------------------------]| 6167 ## grid 2 6168 foo^ | 6169 {1:~ }|*18 6170 ## grid 3 6171 {5:-- }{6:match 1 of 3} | 6172 ## grid 4 6173 {12:foo fooK>}| 6174 {n:bar 一二>}| 6175 {n:一二三四五 multi}| 6176 ]], 6177 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 6178 }) 6179 else 6180 screen:expect([[ 6181 foo^ | 6182 {12:foo fooK>}{1: }| 6183 {n:bar 一二>}{1: }| 6184 {n:一二三四五 multi}{1: }| 6185 {1:~ }|*15 6186 {5:-- }{6:match 1 of 3} | 6187 ]]) 6188 end 6189 feed('<Esc>') 6190 6191 command('set rightleft') 6192 feed('S<C-X><C-O>') 6193 if multigrid then 6194 screen:expect({ 6195 grid = [[ 6196 ## grid 1 6197 [2:--------------------------------]|*19 6198 [3:--------------------------------]| 6199 ## grid 2 6200 ^ oof| 6201 {1: ~}|*18 6202 ## grid 3 6203 {5:-- }{6:match 1 of 3} | 6204 ## grid 4 6205 {12:<Koof oof}| 6206 {n:<二一 rab}| 6207 {n:itlum 五四三二一}| 6208 ]], 6209 float_pos = { [4] = { -1, 'NW', 2, 1, 16, false, 100, 1, 1, 16 } }, 6210 }) 6211 else 6212 screen:expect([[ 6213 ^ oof| 6214 {1: }{12:<Koof oof}| 6215 {1: }{n:<二一 rab}| 6216 {1: }{n:itlum 五四三二一}| 6217 {1: ~}|*15 6218 {5:-- }{6:match 1 of 3} | 6219 ]]) 6220 end 6221 feed('<Esc>') 6222 command('set norightleft') 6223 6224 command('let g:change=4') 6225 feed('S<C-X><C-O>') 6226 if multigrid then 6227 screen:expect({ 6228 grid = [[ 6229 ## grid 1 6230 [2:--------------------------------]|*19 6231 [3:--------------------------------]| 6232 ## grid 2 6233 一二三四五六七八九十^ | 6234 {1:~ }|*18 6235 ## grid 3 6236 {5:-- }{6:match 1 of 2} | 6237 ## grid 4 6238 {ds:一二三四五六七 }{12:>}| 6239 {dn:123456789_12345}{n:>}| 6240 ]], 6241 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 6242 }) 6243 else 6244 screen:expect([[ 6245 一二三四五六七八九十^ | 6246 {ds:一二三四五六七 }{12:>}{1: }| 6247 {dn:123456789_12345}{n:>}{1: }| 6248 {1:~ }|*16 6249 {5:-- }{6:match 1 of 2} | 6250 ]]) 6251 end 6252 feed('<Esc>') 6253 end) 6254 6255 -- oldtest: Test_pum_position_when_wrap() 6256 it('with cursor on a wrapped line', function() 6257 exec([[ 6258 func Omni_test(findstart, base) 6259 if a:findstart 6260 return col(".") 6261 endif 6262 return ['foo', 'bar', 'foobar'] 6263 endfunc 6264 set omnifunc=Omni_test 6265 set wrap 6266 set cot+=noinsert 6267 ]]) 6268 screen:try_resize(25, 15) 6269 6270 insert(('abcde '):rep(20)) 6271 6272 feed('5|') 6273 feed('a<C-X><C-O>') 6274 if multigrid then 6275 screen:expect({ 6276 float_pos = { [4] = { -1, 'NW', 2, 3, 4, false, 100, 1, 3, 4 } }, 6277 }) 6278 else 6279 screen:expect([[ 6280 abcde^ abcde abcde abcde a| 6281 bcde abcde abcde abcde ab| 6282 cde abcde abcde abcde abc| 6283 de a{12: foo } abcd| 6284 e ab{n: bar } | 6285 {1:~ }{n: foobar }{1: }| 6286 {1:~ }|*8 6287 {5:-- }{6:match 1 of 3} | 6288 ]]) 6289 end 6290 feed('<Esc>') 6291 6292 feed('30|') 6293 feed('a<C-X><C-O>') 6294 if multigrid then 6295 screen:expect({ 6296 float_pos = { [4] = { -1, 'NW', 2, 4, 4, false, 100, 1, 4, 4 } }, 6297 }) 6298 else 6299 screen:expect([[ 6300 abcde abcde abcde abcde a| 6301 bcde ^abcde abcde abcde ab| 6302 cde abcde abcde abcde abc| 6303 de abcde abcde abcde abcd| 6304 e ab{12: foo } | 6305 {1:~ }{n: bar }{1: }| 6306 {1:~ }{n: foobar }{1: }| 6307 {1:~ }|*7 6308 {5:-- }{6:match 1 of 3} | 6309 ]]) 6310 end 6311 feed('<Esc>') 6312 6313 feed('55|') 6314 feed('a<C-X><C-O>') 6315 if multigrid then 6316 screen:expect({ 6317 float_pos = { [4] = { -1, 'NW', 2, 5, 4, false, 100, 1, 5, 4 } }, 6318 }) 6319 else 6320 screen:expect([[ 6321 abcde abcde abcde abcde a| 6322 bcde abcde abcde abcde ab| 6323 cde a^bcde abcde abcde abc| 6324 de abcde abcde abcde abcd| 6325 e abcde abcde abcde | 6326 {1:~ }{12: foo }{1: }| 6327 {1:~ }{n: bar }{1: }| 6328 {1:~ }{n: foobar }{1: }| 6329 {1:~ }|*6 6330 {5:-- }{6:match 1 of 3} | 6331 ]]) 6332 end 6333 feed('<Esc>') 6334 6335 feed('85|') 6336 feed('a<C-X><C-O>') 6337 if multigrid then 6338 screen:expect({ 6339 float_pos = { [4] = { -1, 'NW', 2, 5, 9, false, 100, 1, 5, 9 } }, 6340 }) 6341 else 6342 screen:expect([[ 6343 abcde abcde abcde abcde a| 6344 bcde abcde abcde abcde ab| 6345 cde abcde abcde abcde abc| 6346 de abcde a^bcde abcde abcd| 6347 e abcde abcde abcde | 6348 {1:~ }{12: foo }| 6349 {1:~ }{n: bar }| 6350 {1:~ }{n: foobar }| 6351 {1:~ }|*6 6352 {5:-- }{6:match 1 of 3} | 6353 ]]) 6354 end 6355 feed('<C-E><Esc>') 6356 6357 feed('108|') 6358 feed('a<C-X><C-O>') 6359 if multigrid then 6360 screen:expect({ 6361 float_pos = { [4] = { -1, 'NW', 2, 5, 7, false, 100, 1, 5, 7 } }, 6362 }) 6363 else 6364 screen:expect([[ 6365 abcde abcde abcde abcde a| 6366 bcde abcde abcde abcde ab| 6367 cde abcde abcde abcde abc| 6368 de abcde abcde abcde abcd| 6369 e abcde ^abcde abcde | 6370 {1:~ }{12: foo }{1: }| 6371 {1:~ }{n: bar }{1: }| 6372 {1:~ }{n: foobar }{1: }| 6373 {1:~ }|*6 6374 {5:-- }{6:match 1 of 3} | 6375 ]]) 6376 end 6377 feed('<C-E><Esc>') 6378 end) 6379 6380 it('does not crash when displayed in last column with rightleft #12032', function() 6381 local col = 30 6382 local items = { 'word', 'choice', 'text', 'thing' } 6383 local max_len = 0 6384 for _, v in ipairs(items) do 6385 max_len = max_len < #v and #v or max_len 6386 end 6387 screen:try_resize(col, 8) 6388 command('set rightleft') 6389 command('call setline(1, repeat(" ", &columns - ' .. max_len .. '))') 6390 feed('$i') 6391 fn.complete(col - max_len, items) 6392 feed('<c-y>') 6393 assert_alive() 6394 end) 6395 6396 it('truncates double-width character correctly without scrollbar', function() 6397 screen:try_resize(32, 8) 6398 command('set completeopt+=menuone,noselect') 6399 feed('i' .. string.rep(' ', 13)) 6400 6401 fn.complete(14, { '一二三四五六七八九十' }) 6402 if multigrid then 6403 screen:expect({ 6404 grid = [[ 6405 ## grid 1 6406 [2:--------------------------------]|*7 6407 [3:--------------------------------]| 6408 ## grid 2 6409 ^ | 6410 {1:~ }|*6 6411 ## grid 3 6412 {5:-- INSERT --} | 6413 ## grid 4 6414 {n: 一二三四五六七八九>}| 6415 ]], 6416 float_pos = { [4] = { -1, 'NW', 2, 1, 12, false, 100, 1, 1, 12 } }, 6417 }) 6418 else 6419 screen:expect([[ 6420 ^ | 6421 {1:~ }{n: 一二三四五六七八九>}| 6422 {1:~ }|*5 6423 {5:-- INSERT --} | 6424 ]]) 6425 end 6426 feed('<C-E>') 6427 6428 fn.complete(14, { { word = '一二三', kind = '四五六', menu = '七八九十' } }) 6429 if multigrid then 6430 screen:expect({ 6431 grid = [[ 6432 ## grid 1 6433 [2:--------------------------------]|*7 6434 [3:--------------------------------]| 6435 ## grid 2 6436 ^ | 6437 {1:~ }|*6 6438 ## grid 3 6439 {5:-- INSERT --} | 6440 ## grid 4 6441 {n: 一二三 四五六 七八>}| 6442 ]], 6443 float_pos = { [4] = { -1, 'NW', 2, 1, 12, false, 100, 1, 1, 12 } }, 6444 }) 6445 else 6446 screen:expect([[ 6447 ^ | 6448 {1:~ }{n: 一二三 四五六 七八>}| 6449 {1:~ }|*5 6450 {5:-- INSERT --} | 6451 ]]) 6452 end 6453 feed('<C-E>') 6454 6455 command('set rightleft') 6456 fn.complete(14, { '一二三四五六七八九十' }) 6457 if multigrid then 6458 screen:expect({ 6459 grid = [[ 6460 ## grid 1 6461 [2:--------------------------------]|*7 6462 [3:--------------------------------]| 6463 ## grid 2 6464 ^ | 6465 {1: ~}|*6 6466 ## grid 3 6467 {5:-- INSERT --} | 6468 ## grid 4 6469 {n:<九八七六五四三二一 }| 6470 ]], 6471 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 6472 }) 6473 else 6474 screen:expect([[ 6475 ^ | 6476 {n:<九八七六五四三二一 }{1: ~}| 6477 {1: ~}|*5 6478 {5:-- INSERT --} | 6479 ]]) 6480 end 6481 feed('<C-E>') 6482 6483 fn.complete(14, { { word = '一二三', kind = '四五六', menu = '七八九十' } }) 6484 if multigrid then 6485 screen:expect({ 6486 grid = [[ 6487 ## grid 1 6488 [2:--------------------------------]|*7 6489 [3:--------------------------------]| 6490 ## grid 2 6491 ^ | 6492 {1: ~}|*6 6493 ## grid 3 6494 {5:-- INSERT --} | 6495 ## grid 4 6496 {n:<八七 六五四 三二一 }| 6497 ]], 6498 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 6499 }) 6500 else 6501 screen:expect([[ 6502 ^ | 6503 {n:<八七 六五四 三二一 }{1: ~}| 6504 {1: ~}|*5 6505 {5:-- INSERT --} | 6506 ]]) 6507 end 6508 feed('<C-E>') 6509 end) 6510 6511 it('truncates double-width character correctly with scrollbar', function() 6512 screen:try_resize(32, 8) 6513 command('set completeopt+=noselect') 6514 command('set pumheight=4') 6515 feed('i' .. string.rep(' ', 12)) 6516 local items1 = {} 6517 local items2 = {} 6518 for _ = 1, 8 do 6519 table.insert(items1, { word = '一二三四五六七八九十', equal = 1, dup = 1 }) 6520 end 6521 for _ = 1, 2 do 6522 table.insert( 6523 items2, 6524 { word = 'abcdef', kind = 'ghijkl', menu = 'mnopqrst', equal = 1, dup = 1 } 6525 ) 6526 end 6527 for _ = 3, 8 do 6528 table.insert( 6529 items2, 6530 { word = '一二三', kind = '四五六', menu = '七八九十', equal = 1, dup = 1 } 6531 ) 6532 end 6533 6534 fn.complete(13, items1) 6535 if multigrid then 6536 screen:expect({ 6537 grid = [[ 6538 ## grid 1 6539 [2:--------------------------------]|*7 6540 [3:--------------------------------]| 6541 ## grid 2 6542 ^ | 6543 {1:~ }|*6 6544 ## grid 3 6545 {5:-- INSERT --} | 6546 ## grid 4 6547 {n: 一二三四五六七八九>}{c: }|*2 6548 {n: 一二三四五六七八九>}{12: }|*2 6549 ]], 6550 float_pos = { [4] = { -1, 'NW', 2, 1, 11, false, 100, 1, 1, 11 } }, 6551 }) 6552 else 6553 screen:expect([[ 6554 ^ | 6555 {1:~ }{n: 一二三四五六七八九>}{c: }|*2 6556 {1:~ }{n: 一二三四五六七八九>}{12: }|*2 6557 {1:~ }|*2 6558 {5:-- INSERT --} | 6559 ]]) 6560 end 6561 feed('<C-E>') 6562 6563 fn.complete(13, items2) 6564 if multigrid then 6565 screen:expect({ 6566 grid = [[ 6567 ## grid 1 6568 [2:--------------------------------]|*7 6569 [3:--------------------------------]| 6570 ## grid 2 6571 ^ | 6572 {1:~ }|*6 6573 ## grid 3 6574 {5:-- INSERT --} | 6575 ## grid 4 6576 {n: abcdef ghijkl mnop>}{c: }|*2 6577 {n: 一二三 四五六 七八>}{12: }|*2 6578 ]], 6579 float_pos = { [4] = { -1, 'NW', 2, 1, 11, false, 100, 1, 1, 11 } }, 6580 }) 6581 else 6582 screen:expect([[ 6583 ^ | 6584 {1:~ }{n: abcdef ghijkl mnop>}{c: }|*2 6585 {1:~ }{n: 一二三 四五六 七八>}{12: }|*2 6586 {1:~ }|*2 6587 {5:-- INSERT --} | 6588 ]]) 6589 end 6590 feed('<C-E>') 6591 6592 command('set rightleft') 6593 fn.complete(13, items1) 6594 if multigrid then 6595 screen:expect({ 6596 grid = [[ 6597 ## grid 1 6598 [2:--------------------------------]|*7 6599 [3:--------------------------------]| 6600 ## grid 2 6601 ^ | 6602 {1: ~}|*6 6603 ## grid 3 6604 {5:-- INSERT --} | 6605 ## grid 4 6606 {c: }{n:<九八七六五四三二一 }|*2 6607 {12: }{n:<九八七六五四三二一 }|*2 6608 ]], 6609 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 6610 }) 6611 else 6612 screen:expect([[ 6613 ^ | 6614 {c: }{n:<九八七六五四三二一 }{1: ~}|*2 6615 {12: }{n:<九八七六五四三二一 }{1: ~}|*2 6616 {1: ~}|*2 6617 {5:-- INSERT --} | 6618 ]]) 6619 end 6620 feed('<C-E>') 6621 6622 fn.complete(13, items2) 6623 if multigrid then 6624 screen:expect({ 6625 grid = [[ 6626 ## grid 1 6627 [2:--------------------------------]|*7 6628 [3:--------------------------------]| 6629 ## grid 2 6630 ^ | 6631 {1: ~}|*6 6632 ## grid 3 6633 {5:-- INSERT --} | 6634 ## grid 4 6635 {c: }{n:<ponm lkjihg fedcba }|*2 6636 {12: }{n:<八七 六五四 三二一 }|*2 6637 ]], 6638 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, 6639 }) 6640 else 6641 screen:expect([[ 6642 ^ | 6643 {c: }{n:<ponm lkjihg fedcba }{1: ~}|*2 6644 {12: }{n:<八七 六五四 三二一 }{1: ~}|*2 6645 {1: ~}|*2 6646 {5:-- INSERT --} | 6647 ]]) 6648 end 6649 feed('<C-E>') 6650 end) 6651 6652 it('supports mousemodel=popup', function() 6653 screen:try_resize(32, 6) 6654 exec([[ 6655 call setline(1, 'popup menu test') 6656 set mouse=a mousemodel=popup 6657 6658 " Delete the default MenuPopup event handler. 6659 autocmd! nvim.popupmenu 6660 aunmenu PopUp 6661 menu PopUp.foo :let g:menustr = 'foo'<CR> 6662 menu PopUp.bar :let g:menustr = 'bar'<CR> 6663 menu PopUp.baz :let g:menustr = 'baz'<CR> 6664 ]]) 6665 6666 --- @param state string|test.functional.ui.screen.Expect 6667 --- @param str string 6668 --- @param repl string 6669 --- @return string|test.functional.ui.screen.Expect 6670 local function screen_replace(state, str, repl) 6671 if type(state) == 'string' then 6672 local new_state = state:gsub(vim.pesc(str), vim.pesc(repl)) 6673 return new_state 6674 end 6675 local new_state = vim.deepcopy(state) 6676 local grid = assert(new_state.grid) 6677 grid = grid:gsub(vim.pesc(str), vim.pesc(repl)) 6678 new_state.grid = grid 6679 return new_state 6680 end 6681 6682 local no_sel_screen ---@type string|test.function.ui.screen.Expect 6683 if send_mouse_grid then 6684 api.nvim_input_mouse('right', 'press', '', 2, 0, 4) 6685 else 6686 feed('<RightMouse><4,0>') 6687 end 6688 if multigrid then 6689 no_sel_screen = { 6690 grid = [[ 6691 ## grid 1 6692 [2:--------------------------------]|*5 6693 [3:--------------------------------]| 6694 ## grid 2 6695 ^popup menu test | 6696 {1:~ }|*4 6697 ## grid 3 6698 | 6699 ## grid 4 6700 {n: foo }| 6701 {n: bar }| 6702 {n: baz }| 6703 ]], 6704 float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250, 2, 1, 3 } }, 6705 } 6706 else 6707 no_sel_screen = [[ 6708 ^popup menu test | 6709 {1:~ }{n: foo }{1: }| 6710 {1:~ }{n: bar }{1: }| 6711 {1:~ }{n: baz }{1: }| 6712 {1:~ }| 6713 | 6714 ]] 6715 end 6716 screen:expect(no_sel_screen) 6717 feed('<Down>') 6718 screen:expect(screen_replace(no_sel_screen, '{n: foo }', '{12: foo }')) 6719 feed('<Down>') 6720 screen:expect(screen_replace(no_sel_screen, '{n: bar }', '{12: bar }')) 6721 feed('<CR>') 6722 local no_menu_screen ---@type string 6723 if multigrid then 6724 no_menu_screen = [[ 6725 ## grid 1 6726 [2:--------------------------------]|*5 6727 [3:--------------------------------]| 6728 ## grid 2 6729 ^popup menu test | 6730 {1:~ }|*4 6731 ## grid 3 6732 :let g:menustr = 'bar' | 6733 ]] 6734 else 6735 no_menu_screen = [[ 6736 ^popup menu test | 6737 {1:~ }|*4 6738 :let g:menustr = 'bar' | 6739 ]] 6740 end 6741 screen:expect(no_menu_screen) 6742 eq('bar', api.nvim_get_var('menustr')) 6743 6744 if send_mouse_grid then 6745 api.nvim_input_mouse('right', 'press', '', 2, 2, 20) 6746 else 6747 feed('<RightMouse><20,2>') 6748 end 6749 if multigrid then 6750 screen:expect({ 6751 grid = [[ 6752 ## grid 1 6753 [2:--------------------------------]|*5 6754 [3:--------------------------------]| 6755 ## grid 2 6756 ^popup menu test | 6757 {1:~ }|*4 6758 ## grid 3 6759 :let g:menustr = 'bar' | 6760 ## grid 4 6761 {n: foo }| 6762 {n: bar }| 6763 {n: baz }| 6764 ]], 6765 float_pos = { [4] = { -1, 'NW', 2, 3, 19, false, 250, 2, 3, 19 } }, 6766 }) 6767 else 6768 screen:expect([[ 6769 ^popup menu test | 6770 {1:~ }|*2 6771 {1:~ }{n: foo }{1: }| 6772 {1:~ }{n: bar }{1: }| 6773 :let g:menustr = 'b{n: baz } | 6774 ]]) 6775 end 6776 if send_mouse_grid then 6777 api.nvim_input_mouse('right', 'press', '', 2, 0, 18) 6778 else 6779 feed('<RightMouse><18,0>') 6780 end 6781 if multigrid then 6782 screen:expect({ 6783 grid = [[ 6784 ## grid 1 6785 [2:--------------------------------]|*5 6786 [3:--------------------------------]| 6787 ## grid 2 6788 ^popup menu test | 6789 {1:~ }|*4 6790 ## grid 3 6791 :let g:menustr = 'bar' | 6792 ## grid 4 6793 {n: foo }| 6794 {n: bar }| 6795 {n: baz }| 6796 ]], 6797 float_pos = { [4] = { -1, 'NW', 2, 1, 17, false, 250, 2, 1, 17 } }, 6798 }) 6799 else 6800 screen:expect([[ 6801 ^popup menu test | 6802 {1:~ }{n: foo }{1: }| 6803 {1:~ }{n: bar }{1: }| 6804 {1:~ }{n: baz }{1: }| 6805 {1:~ }| 6806 :let g:menustr = 'bar' | 6807 ]]) 6808 end 6809 if send_mouse_grid then 6810 api.nvim_input_mouse('right', 'press', '', 4, 1, 3) 6811 else 6812 feed('<RightMouse><20,2>') 6813 end 6814 if multigrid then 6815 screen:expect({ 6816 grid = [[ 6817 ## grid 1 6818 [2:--------------------------------]|*5 6819 [3:--------------------------------]| 6820 ## grid 2 6821 ^popup menu test | 6822 {1:~ }|*4 6823 ## grid 3 6824 :let g:menustr = 'bar' | 6825 ## grid 4 6826 {n: foo }| 6827 {n: bar }| 6828 {n: baz }| 6829 ]], 6830 float_pos = { [4] = { -1, 'NW', 2, 3, 19, false, 250, 2, 3, 19 } }, 6831 }) 6832 else 6833 screen:expect([[ 6834 ^popup menu test | 6835 {1:~ }|*2 6836 {1:~ }{n: foo }{1: }| 6837 {1:~ }{n: bar }{1: }| 6838 :let g:menustr = 'b{n: baz } | 6839 ]]) 6840 end 6841 if send_mouse_grid then 6842 api.nvim_input_mouse('left', 'press', '', 4, 2, 2) 6843 else 6844 feed('<LeftMouse><21,5>') 6845 end 6846 no_menu_screen = no_menu_screen:gsub([['bar']], [['baz']]) 6847 screen:expect(no_menu_screen) 6848 eq('baz', api.nvim_get_var('menustr')) 6849 6850 if send_mouse_grid then 6851 api.nvim_input_mouse('right', 'press', '', 2, 0, 4) 6852 else 6853 feed('<RightMouse><4,0>') 6854 end 6855 if multigrid then 6856 no_sel_screen = { 6857 grid = [[ 6858 ## grid 1 6859 [2:--------------------------------]|*5 6860 [3:--------------------------------]| 6861 ## grid 2 6862 ^popup menu test | 6863 {1:~ }|*4 6864 ## grid 3 6865 :let g:menustr = 'baz' | 6866 ## grid 4 6867 {n: foo }| 6868 {n: bar }| 6869 {n: baz }| 6870 ]], 6871 float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250, 2, 1, 3 } }, 6872 } 6873 else 6874 no_sel_screen = [[ 6875 ^popup menu test | 6876 {1:~ }{n: foo }{1: }| 6877 {1:~ }{n: bar }{1: }| 6878 {1:~ }{n: baz }{1: }| 6879 {1:~ }| 6880 :let g:menustr = 'baz' | 6881 ]] 6882 end 6883 screen:expect(no_sel_screen) 6884 if send_mouse_grid then 6885 api.nvim_input_mouse('right', 'drag', '', 2, 3, 6) 6886 else 6887 feed('<RightDrag><6,3>') 6888 end 6889 screen:expect(screen_replace(no_sel_screen, '{n: baz }', '{12: baz }')) 6890 if send_mouse_grid then 6891 api.nvim_input_mouse('right', 'release', '', 2, 1, 6) 6892 else 6893 feed('<RightRelease><6,1>') 6894 end 6895 no_menu_screen = no_menu_screen:gsub([['baz']], [['foo']]) 6896 screen:expect(no_menu_screen) 6897 eq('foo', api.nvim_get_var('menustr')) 6898 no_sel_screen = screen_replace(no_sel_screen, [['baz']], [['foo']]) 6899 6900 eq(false, screen.options.mousemoveevent) 6901 6902 if send_mouse_grid then 6903 api.nvim_input_mouse('right', 'press', '', 2, 0, 4) 6904 else 6905 feed('<RightMouse><4,0>') 6906 end 6907 screen:expect(no_sel_screen) 6908 eq(true, screen.options.mousemoveevent) 6909 if send_mouse_grid then 6910 api.nvim_input_mouse('wheel', 'up', '', 2, 0, 4) 6911 else 6912 feed('<ScrollWheelUp><4,0>') 6913 end 6914 screen:expect(screen_replace(no_sel_screen, '{n: foo }', '{12: foo }')) 6915 eq(true, screen.options.mousemoveevent) 6916 if send_mouse_grid then 6917 api.nvim_input_mouse('move', '', '', 4, 2, 3) 6918 else 6919 feed('<MouseMove><6,3>') 6920 end 6921 screen:expect(screen_replace(no_sel_screen, '{n: baz }', '{12: baz }')) 6922 eq(true, screen.options.mousemoveevent) 6923 if send_mouse_grid then 6924 api.nvim_input_mouse('wheel', 'down', '', 4, 2, 3) 6925 else 6926 feed('<ScrollWheelDown><6,3>') 6927 end 6928 screen:expect(screen_replace(no_sel_screen, '{n: bar }', '{12: bar }')) 6929 eq(true, screen.options.mousemoveevent) 6930 if send_mouse_grid then 6931 api.nvim_input_mouse('left', 'press', '', 4, 1, 3) 6932 else 6933 feed('<LeftMouse><6,2>') 6934 end 6935 no_menu_screen = no_menu_screen:gsub([['foo']], [['bar']]) 6936 screen:expect(no_menu_screen) 6937 eq(false, screen.options.mousemoveevent) 6938 eq('bar', api.nvim_get_var('menustr')) 6939 6940 command('set laststatus=0 | botright split') 6941 if send_mouse_grid then 6942 api.nvim_input_mouse('right', 'press', '', 5, 1, 20) 6943 else 6944 feed('<RightMouse><20,4>') 6945 end 6946 if multigrid then 6947 screen:expect({ 6948 grid = [[ 6949 ## grid 1 6950 [2:--------------------------------]|*2 6951 {2:[No Name] [+] }| 6952 [5:--------------------------------]|*2 6953 [3:--------------------------------]| 6954 ## grid 2 6955 popup menu test | 6956 {1:~ }| 6957 ## grid 3 6958 :let g:menustr = 'bar' | 6959 ## grid 4 6960 {n: foo }| 6961 {n: bar }| 6962 {n: baz }| 6963 ## grid 5 6964 ^popup menu test | 6965 {1:~ }| 6966 ]], 6967 float_pos = { [4] = { -1, 'SW', 5, 1, 19, false, 250, 2, 1, 19 } }, 6968 }) 6969 else 6970 screen:expect([[ 6971 popup menu test | 6972 {1:~ }{n: foo }{1: }| 6973 {2:[No Name] [+] }{n: bar }{2: }| 6974 ^popup menu test {n: baz } | 6975 {1:~ }| 6976 :let g:menustr = 'bar' | 6977 ]]) 6978 end 6979 if send_mouse_grid then 6980 api.nvim_input_mouse('left', 'press', '', 4, 2, 2) 6981 else 6982 feed('<LeftMouse><21,3>') 6983 end 6984 if multigrid then 6985 screen:expect([[ 6986 ## grid 1 6987 [2:--------------------------------]|*2 6988 {2:[No Name] [+] }| 6989 [5:--------------------------------]|*2 6990 [3:--------------------------------]| 6991 ## grid 2 6992 popup menu test | 6993 {1:~ }| 6994 ## grid 3 6995 :let g:menustr = 'baz' | 6996 ## grid 5 6997 ^popup menu test | 6998 {1:~ }| 6999 ]]) 7000 else 7001 screen:expect([[ 7002 popup menu test | 7003 {1:~ }| 7004 {2:[No Name] [+] }| 7005 ^popup menu test | 7006 {1:~ }| 7007 :let g:menustr = 'baz' | 7008 ]]) 7009 end 7010 eq('baz', api.nvim_get_var('menustr')) 7011 7012 command('set winwidth=1 | rightbelow vsplit') 7013 if send_mouse_grid then 7014 api.nvim_input_mouse('right', 'press', '', 6, 1, 14) 7015 else 7016 feed('<RightMouse><30,4>') 7017 end 7018 if multigrid then 7019 screen:expect({ 7020 grid = [[ 7021 ## grid 1 7022 [2:--------------------------------]|*2 7023 {2:[No Name] [+] }| 7024 [5:---------------]│[6:----------------]|*2 7025 [3:--------------------------------]| 7026 ## grid 2 7027 popup menu test | 7028 {1:~ }| 7029 ## grid 3 7030 :let g:menustr = 'baz' | 7031 ## grid 4 7032 {n: foo}| 7033 {n: bar}| 7034 {n: baz}| 7035 ## grid 5 7036 popup menu test| 7037 {1:~ }| 7038 ## grid 6 7039 ^popup menu test | 7040 {1:~ }| 7041 ]], 7042 float_pos = { [4] = { -1, 'SW', 6, 1, 12, false, 250, 2, 1, 28 } }, 7043 }) 7044 else 7045 screen:expect([[ 7046 popup menu test | 7047 {1:~ }{n: foo}| 7048 {2:[No Name] [+] }{n: bar}| 7049 popup menu test│^popup menu t{n: baz}| 7050 {1:~ }│{1:~ }| 7051 :let g:menustr = 'baz' | 7052 ]]) 7053 end 7054 if send_mouse_grid then 7055 api.nvim_input_mouse('left', 'press', '', 4, 0, 2) 7056 else 7057 feed('<LeftMouse><31,1>') 7058 end 7059 if multigrid then 7060 screen:expect([[ 7061 ## grid 1 7062 [2:--------------------------------]|*2 7063 {2:[No Name] [+] }| 7064 [5:---------------]│[6:----------------]|*2 7065 [3:--------------------------------]| 7066 ## grid 2 7067 popup menu test | 7068 {1:~ }| 7069 ## grid 3 7070 :let g:menustr = 'foo' | 7071 ## grid 5 7072 popup menu test| 7073 {1:~ }| 7074 ## grid 6 7075 ^popup menu test | 7076 {1:~ }| 7077 ]]) 7078 else 7079 screen:expect([[ 7080 popup menu test | 7081 {1:~ }| 7082 {2:[No Name] [+] }| 7083 popup menu test│^popup menu test | 7084 {1:~ }│{1:~ }| 7085 :let g:menustr = 'foo' | 7086 ]]) 7087 end 7088 eq('foo', api.nvim_get_var('menustr')) 7089 7090 command('setlocal winbar=WINBAR') 7091 if send_mouse_grid then 7092 api.nvim_input_mouse('right', 'press', '', 6, 1, 14) 7093 else 7094 feed('<RightMouse><30,4>') 7095 end 7096 if multigrid then 7097 no_sel_screen = { 7098 grid = [[ 7099 ## grid 1 7100 [2:--------------------------------]|*2 7101 {2:[No Name] [+] }| 7102 [5:---------------]│[6:----------------]|*2 7103 [3:--------------------------------]| 7104 ## grid 2 7105 popup menu test | 7106 {1:~ }| 7107 ## grid 3 7108 :let g:menustr = 'foo' | 7109 ## grid 4 7110 {n: foo}| 7111 {n: bar}| 7112 {n: baz}| 7113 ## grid 5 7114 popup menu test| 7115 {1:~ }| 7116 ## grid 6 7117 {5:WINBAR }| 7118 ^popup menu test | 7119 ]], 7120 float_pos = { [4] = { -1, 'SW', 6, 1, 12, false, 250, 2, 1, 28 } }, 7121 } 7122 else 7123 no_sel_screen = [[ 7124 popup menu test | 7125 {1:~ }{n: foo}| 7126 {2:[No Name] [+] }{n: bar}| 7127 popup menu test│{5:WINBAR }{n: baz}| 7128 {1:~ }│^popup menu test | 7129 :let g:menustr = 'foo' | 7130 ]] 7131 end 7132 screen:expect(no_sel_screen) 7133 if send_mouse_grid then 7134 api.nvim_input_mouse('right', 'drag', '', 6, 0, 15) 7135 else 7136 feed('<RightDrag><31,3>') 7137 end 7138 screen:expect(screen_replace(no_sel_screen, '{n: baz}', '{12: baz}')) 7139 if send_mouse_grid then 7140 api.nvim_input_mouse('right', 'release', '', 6, 1, 15) 7141 else 7142 feed('<RightRelease><31,4>') 7143 end 7144 screen:expect(no_sel_screen) 7145 if send_mouse_grid then 7146 api.nvim_input_mouse('left', 'press', '', 4, 1, 2) 7147 else 7148 feed('<LeftMouse><31,2>') 7149 end 7150 if multigrid then 7151 screen:expect([[ 7152 ## grid 1 7153 [2:--------------------------------]|*2 7154 {2:[No Name] [+] }| 7155 [5:---------------]│[6:----------------]|*2 7156 [3:--------------------------------]| 7157 ## grid 2 7158 popup menu test | 7159 {1:~ }| 7160 ## grid 3 7161 :let g:menustr = 'bar' | 7162 ## grid 5 7163 popup menu test| 7164 {1:~ }| 7165 ## grid 6 7166 {5:WINBAR }| 7167 ^popup menu test | 7168 ]]) 7169 else 7170 screen:expect([[ 7171 popup menu test | 7172 {1:~ }| 7173 {2:[No Name] [+] }| 7174 popup menu test│{5:WINBAR }| 7175 {1:~ }│^popup menu test | 7176 :let g:menustr = 'bar' | 7177 ]]) 7178 end 7179 eq('bar', api.nvim_get_var('menustr')) 7180 7181 command([[let g:menustr = '']]) 7182 screen:try_resize(32, 9) 7183 command('wincmd t | 4vsplit | wincmd l | topleft 1split') 7184 if multigrid then 7185 no_menu_screen = [[ 7186 ## grid 1 7187 [8:--------------------------------]| 7188 {3:[No Name] [+] }| 7189 [7:----]│[2:---------------------------]|*2 7190 {2:<+] [No Name] [+] }| 7191 [5:---------------]│[6:----------------]|*3 7192 [3:--------------------------------]| 7193 ## grid 2 7194 popup menu test | 7195 {1:~ }| 7196 ## grid 3 7197 | 7198 ## grid 5 7199 popup menu test| 7200 {1:~ }|*2 7201 ## grid 6 7202 {5:WINBAR }| 7203 popup menu test | 7204 {1:~ }| 7205 ## grid 7 7206 popu| 7207 p me| 7208 ## grid 8 7209 ^popup menu test | 7210 ]] 7211 else 7212 no_menu_screen = [[ 7213 ^popup menu test | 7214 {3:[No Name] [+] }| 7215 popu│popup menu test | 7216 p me│{1:~ }| 7217 {2:<+] [No Name] [+] }| 7218 popup menu test│{5:WINBAR }| 7219 {1:~ }│popup menu test | 7220 {1:~ }│{1:~ }| 7221 | 7222 ]] 7223 end 7224 screen:expect(no_menu_screen) 7225 7226 if multigrid then 7227 no_sel_screen = { 7228 grid = [[ 7229 ## grid 1 7230 [8:--------------------------------]| 7231 {3:[No Name] [+] }| 7232 [7:----]│[2:---------------------------]|*2 7233 {2:<+] [No Name] [+] }| 7234 [5:---------------]│[6:----------------]|*3 7235 [3:--------------------------------]| 7236 ## grid 2 7237 popup menu test | 7238 {1:~ }| 7239 ## grid 3 7240 | 7241 ## grid 4 7242 {n: foo }| 7243 {n: bar }| 7244 {n: baz }| 7245 ## grid 5 7246 popup menu test| 7247 {1:~ }|*2 7248 ## grid 6 7249 {5:WINBAR }| 7250 popup menu test | 7251 {1:~ }| 7252 ## grid 7 7253 popu| 7254 p me| 7255 ## grid 8 7256 ^popup menu test | 7257 ]], 7258 float_pos = { [4] = { -1, 'NW', 2, 1, 14, false, 250, 2, 3, 19 } }, 7259 } 7260 else 7261 no_sel_screen = [[ 7262 ^popup menu test | 7263 {3:[No Name] [+] }| 7264 popu│popup menu test | 7265 p me│{1:~ }{n: foo }{1: }| 7266 {2:<+] [No Name] [+] }{n: bar }{2: }| 7267 popup menu test│{5:WIN}{n: baz }{5: }| 7268 {1:~ }│popup menu test | 7269 {1:~ }│{1:~ }| 7270 | 7271 ]] 7272 end 7273 7274 local pos = { 7275 { 0, 2, 20 }, 7276 { 0, 3, 19 }, 7277 { 0, 3, 18 }, 7278 { 0, 4, 23 }, 7279 { 0, 4, 24 }, 7280 { 0, 5, 19 }, 7281 { 0, 5, 18 }, 7282 } 7283 if send_mouse_grid then 7284 for i = 1, 7 do 7285 local _, row, col = unpack(pos[i]) 7286 pos[i] = { 2, row - 2, col - 5 } 7287 end 7288 end 7289 7290 api.nvim_input_mouse('right', 'press', '', unpack(pos[1])) 7291 screen:expect(no_sel_screen) 7292 api.nvim_input_mouse('right', 'drag', '', unpack(pos[2])) 7293 screen:expect(screen_replace(no_sel_screen, '{n: foo }', '{12: foo }')) 7294 api.nvim_input_mouse('right', 'drag', '', unpack(pos[3])) 7295 screen:expect(no_sel_screen) 7296 api.nvim_input_mouse('right', 'drag', '', unpack(pos[4])) 7297 screen:expect(screen_replace(no_sel_screen, '{n: bar }', '{12: bar }')) 7298 api.nvim_input_mouse('right', 'drag', '', unpack(pos[5])) 7299 screen:expect(no_sel_screen) 7300 api.nvim_input_mouse('right', 'drag', '', unpack(pos[6])) 7301 screen:expect(screen_replace(no_sel_screen, '{n: baz }', '{12: baz }')) 7302 api.nvim_input_mouse('right', 'release', '', unpack(pos[7])) 7303 screen:expect(no_sel_screen) 7304 api.nvim_input_mouse('left', 'press', '', unpack(pos[7])) 7305 screen:expect(no_menu_screen) 7306 eq('', api.nvim_get_var('menustr')) 7307 7308 if send_mouse_grid then 7309 for i = 2, 6, 2 do 7310 local _, row, col = unpack(pos[i]) 7311 pos[i] = { 4, row - 1, col - 14 } 7312 end 7313 end 7314 7315 api.nvim_input_mouse('right', 'press', '', unpack(pos[1])) 7316 screen:expect(no_sel_screen) 7317 api.nvim_input_mouse('move', '', '', unpack(pos[2])) 7318 screen:expect(screen_replace(no_sel_screen, '{n: foo }', '{12: foo }')) 7319 api.nvim_input_mouse('move', '', '', unpack(pos[3])) 7320 screen:expect(no_sel_screen) 7321 api.nvim_input_mouse('move', '', '', unpack(pos[4])) 7322 screen:expect(screen_replace(no_sel_screen, '{n: bar }', '{12: bar }')) 7323 api.nvim_input_mouse('move', '', '', unpack(pos[5])) 7324 screen:expect(no_sel_screen) 7325 api.nvim_input_mouse('move', '', '', unpack(pos[6])) 7326 screen:expect(screen_replace(no_sel_screen, '{n: baz }', '{12: baz }')) 7327 api.nvim_input_mouse('left', 'press', '', unpack(pos[7])) 7328 screen:expect(no_menu_screen) 7329 eq('', api.nvim_get_var('menustr')) 7330 7331 command('set rightleft | wincmd p | set rightleft | wincmd p') 7332 if multigrid then 7333 no_menu_screen = [[ 7334 ## grid 1 7335 [8:--------------------------------]| 7336 {3:[No Name] [+] }| 7337 [7:----]│[2:---------------------------]|*2 7338 {2:<+] [No Name] [+] }| 7339 [5:---------------]│[6:----------------]|*3 7340 [3:--------------------------------]| 7341 ## grid 2 7342 tset unem pupop| 7343 {1: ~}| 7344 ## grid 3 7345 | 7346 ## grid 5 7347 popup menu test| 7348 {1:~ }|*2 7349 ## grid 6 7350 {5:WINBAR }| 7351 popup menu test | 7352 {1:~ }| 7353 ## grid 7 7354 popu| 7355 p me| 7356 ## grid 8 7357 tset unem pupo^p| 7358 ]] 7359 else 7360 no_menu_screen = [[ 7361 tset unem pupo^p| 7362 {3:[No Name] [+] }| 7363 popu│ tset unem pupop| 7364 p me│{1: ~}| 7365 {2:<+] [No Name] [+] }| 7366 popup menu test│{5:WINBAR }| 7367 {1:~ }│popup menu test | 7368 {1:~ }│{1:~ }| 7369 | 7370 ]] 7371 end 7372 screen:expect(no_menu_screen) 7373 7374 if multigrid then 7375 no_sel_screen = { 7376 grid = [[ 7377 ## grid 1 7378 [8:--------------------------------]| 7379 {3:[No Name] [+] }| 7380 [7:----]│[2:---------------------------]|*2 7381 {2:<+] [No Name] [+] }| 7382 [5:---------------]│[6:----------------]|*3 7383 [3:--------------------------------]| 7384 ## grid 2 7385 tset unem pupop| 7386 {1: ~}| 7387 ## grid 3 7388 | 7389 ## grid 4 7390 {n: oof }| 7391 {n: rab }| 7392 {n: zab }| 7393 ## grid 5 7394 popup menu test| 7395 {1:~ }|*2 7396 ## grid 6 7397 {5:WINBAR }| 7398 popup menu test | 7399 {1:~ }| 7400 ## grid 7 7401 popu| 7402 p me| 7403 ## grid 8 7404 tset unem pupo^p| 7405 ]], 7406 float_pos = { [4] = { -1, 'NW', 2, 1, 12, false, 250, 2, 3, 17 } }, 7407 } 7408 else 7409 no_sel_screen = [[ 7410 tset unem pupo^p| 7411 {3:[No Name] [+] }| 7412 popu│ tset unem pupop| 7413 p me│{1: }{n: oof }{1: ~}| 7414 {2:<+] [No Name] [+}{n: rab }{2: }| 7415 popup menu test│{5:W}{n: zab }{5: }| 7416 {1:~ }│popup menu test | 7417 {1:~ }│{1:~ }| 7418 | 7419 ]] 7420 end 7421 7422 pos = { 7423 { 0, 2, 20 }, 7424 { 0, 3, 21 }, 7425 { 0, 3, 22 }, 7426 { 0, 4, 17 }, 7427 { 0, 4, 16 }, 7428 { 0, 5, 21 }, 7429 { 0, 5, 22 }, 7430 } 7431 if send_mouse_grid then 7432 for i = 1, 7 do 7433 local _, row, col = unpack(pos[i]) 7434 pos[i] = { 2, row - 2, col - 5 } 7435 end 7436 end 7437 7438 api.nvim_input_mouse('right', 'press', '', unpack(pos[1])) 7439 screen:expect(no_sel_screen) 7440 api.nvim_input_mouse('move', '', '', unpack(pos[2])) 7441 screen:expect(screen_replace(no_sel_screen, '{n: oof }', '{12: oof }')) 7442 api.nvim_input_mouse('move', '', '', unpack(pos[3])) 7443 screen:expect(no_sel_screen) 7444 api.nvim_input_mouse('move', '', '', unpack(pos[4])) 7445 screen:expect(screen_replace(no_sel_screen, '{n: rab }', '{12: rab }')) 7446 api.nvim_input_mouse('move', '', '', unpack(pos[5])) 7447 screen:expect(no_sel_screen) 7448 api.nvim_input_mouse('move', '', '', unpack(pos[6])) 7449 screen:expect(screen_replace(no_sel_screen, '{n: zab }', '{12: zab }')) 7450 api.nvim_input_mouse('left', 'press', '', unpack(pos[7])) 7451 screen:expect(no_menu_screen) 7452 eq('', api.nvim_get_var('menustr')) 7453 7454 if send_mouse_grid then 7455 for i = 2, 6, 2 do 7456 local _, row, col = unpack(pos[i]) 7457 pos[i] = { 4, row - 1, col - 12 } 7458 end 7459 end 7460 7461 api.nvim_input_mouse('right', 'press', '', unpack(pos[1])) 7462 screen:expect(no_sel_screen) 7463 api.nvim_input_mouse('right', 'drag', '', unpack(pos[2])) 7464 screen:expect(screen_replace(no_sel_screen, '{n: oof }', '{12: oof }')) 7465 api.nvim_input_mouse('right', 'drag', '', unpack(pos[3])) 7466 screen:expect(no_sel_screen) 7467 api.nvim_input_mouse('right', 'drag', '', unpack(pos[4])) 7468 screen:expect(screen_replace(no_sel_screen, '{n: rab }', '{12: rab }')) 7469 api.nvim_input_mouse('right', 'drag', '', unpack(pos[5])) 7470 screen:expect(no_sel_screen) 7471 api.nvim_input_mouse('right', 'drag', '', unpack(pos[6])) 7472 screen:expect(screen_replace(no_sel_screen, '{n: zab }', '{12: zab }')) 7473 api.nvim_input_mouse('right', 'release', '', unpack(pos[7])) 7474 screen:expect(no_sel_screen) 7475 api.nvim_input_mouse('left', 'press', '', unpack(pos[7])) 7476 eq('', api.nvim_get_var('menustr')) 7477 7478 command('set norightleft') 7479 end) 7480 7481 if not multigrid then 7482 -- oldtest: Test_popup_command_dump() 7483 it(':popup command', function() 7484 exec([[ 7485 " Delete the default MenuPopup event handler. 7486 autocmd! nvim.popupmenu 7487 7488 func ChangeMenu() 7489 aunmenu PopUp.&Paste 7490 nnoremenu 1.40 PopUp.&Paste :echomsg "pasted"<CR> 7491 echomsg 'changed' 7492 return "\<Ignore>" 7493 endfunc 7494 7495 let lines =<< trim END 7496 one two three four five 7497 and one two Xthree four five 7498 one more two three four five 7499 END 7500 call setline(1, lines) 7501 7502 aunmenu * 7503 source $VIMRUNTIME/menu.vim 7504 ]]) 7505 feed('/X<CR>:popup PopUp<CR>') 7506 screen:expect([[ 7507 one two three four five | 7508 and one two {10:^X}three four five | 7509 one more tw{n: Undo } | 7510 {1:~ }{n: }{1: }| 7511 {1:~ }{n: Paste }{1: }| 7512 {1:~ }{n: }{1: }| 7513 {1:~ }{n: Select Word }{1: }| 7514 {1:~ }{n: Select Sentence }{1: }| 7515 {1:~ }{n: Select Paragraph }{1: }| 7516 {1:~ }{n: Select Line }{1: }| 7517 {1:~ }{n: Select Block }{1: }| 7518 {1:~ }{n: Select All }{1: }| 7519 {1:~ }|*7 7520 :popup PopUp | 7521 ]]) 7522 7523 -- go to the Paste entry in the menu 7524 feed('jj') 7525 screen:expect([[ 7526 one two three four five | 7527 and one two {10:^X}three four five | 7528 one more tw{n: Undo } | 7529 {1:~ }{n: }{1: }| 7530 {1:~ }{12: Paste }{1: }| 7531 {1:~ }{n: }{1: }| 7532 {1:~ }{n: Select Word }{1: }| 7533 {1:~ }{n: Select Sentence }{1: }| 7534 {1:~ }{n: Select Paragraph }{1: }| 7535 {1:~ }{n: Select Line }{1: }| 7536 {1:~ }{n: Select Block }{1: }| 7537 {1:~ }{n: Select All }{1: }| 7538 {1:~ }|*7 7539 :popup PopUp | 7540 ]]) 7541 7542 -- Select a word 7543 feed('j') 7544 screen:expect([[ 7545 one two three four five | 7546 and one two {10:^X}three four five | 7547 one more tw{n: Undo } | 7548 {1:~ }{n: }{1: }| 7549 {1:~ }{n: Paste }{1: }| 7550 {1:~ }{n: }{1: }| 7551 {1:~ }{12: Select Word }{1: }| 7552 {1:~ }{n: Select Sentence }{1: }| 7553 {1:~ }{n: Select Paragraph }{1: }| 7554 {1:~ }{n: Select Line }{1: }| 7555 {1:~ }{n: Select Block }{1: }| 7556 {1:~ }{n: Select All }{1: }| 7557 {1:~ }|*7 7558 :popup PopUp | 7559 ]]) 7560 7561 feed('<Esc>') 7562 7563 command('set rightleft') 7564 feed('/X<CR>:popup PopUp<CR>') 7565 screen:expect([[ 7566 evif ruof eerht owt eno| 7567 evif ruof eerht{10:^X} owt eno dna| 7568 {n: odnU }wt erom eno| 7569 {1: }{n: }{1: ~}| 7570 {1: }{n: etsaP }{1: ~}| 7571 {1: }{n: }{1: ~}| 7572 {1: }{n: droW tceleS }{1: ~}| 7573 {1: }{n: ecnetneS tceleS }{1: ~}| 7574 {1: }{n: hpargaraP tceleS }{1: ~}| 7575 {1: }{n: eniL tceleS }{1: ~}| 7576 {1: }{n: kcolB tceleS }{1: ~}| 7577 {1: }{n: llA tceleS }{1: ~}| 7578 {1: ~}|*7 7579 :popup PopUp | 7580 ]]) 7581 feed('<Esc>') 7582 command('set norightleft') 7583 7584 -- Set an <expr> mapping to change a menu entry while it's displayed. 7585 -- The text should not change but the command does. 7586 -- Also verify that "changed" shows up, which means the mapping triggered. 7587 command('nnoremap <expr> <F2> ChangeMenu()') 7588 feed('/X<CR>:popup PopUp<CR><F2>') 7589 screen:expect([[ 7590 one two three four five | 7591 and one two {10:^X}three four five | 7592 one more tw{n: Undo } | 7593 {1:~ }{n: }{1: }| 7594 {1:~ }{n: Paste }{1: }| 7595 {1:~ }{n: }{1: }| 7596 {1:~ }{n: Select Word }{1: }| 7597 {1:~ }{n: Select Sentence }{1: }| 7598 {1:~ }{n: Select Paragraph }{1: }| 7599 {1:~ }{n: Select Line }{1: }| 7600 {1:~ }{n: Select Block }{1: }| 7601 {1:~ }{n: Select All }{1: }| 7602 {1:~ }|*7 7603 changed | 7604 ]]) 7605 7606 -- Select the Paste entry, executes the changed menu item. 7607 feed('jj<CR>') 7608 screen:expect([[ 7609 one two three four five | 7610 and one two {10:^X}three four five | 7611 one more two three four five | 7612 {1:~ }|*16 7613 pasted | 7614 ]]) 7615 7616 -- Add a window toolbar to the window and check the :popup menu position. 7617 command('setlocal winbar=TEST') 7618 feed('/X<CR>:popup PopUp<CR>') 7619 screen:expect([[ 7620 {5:TEST }| 7621 one two three four five | 7622 and one two {10:^X}three four five | 7623 one more tw{n: Undo } | 7624 {1:~ }{n: }{1: }| 7625 {1:~ }{n: Paste }{1: }| 7626 {1:~ }{n: }{1: }| 7627 {1:~ }{n: Select Word }{1: }| 7628 {1:~ }{n: Select Sentence }{1: }| 7629 {1:~ }{n: Select Paragraph }{1: }| 7630 {1:~ }{n: Select Line }{1: }| 7631 {1:~ }{n: Select Block }{1: }| 7632 {1:~ }{n: Select All }{1: }| 7633 {1:~ }|*6 7634 :popup PopUp | 7635 ]]) 7636 7637 feed('<Esc>') 7638 end) 7639 end 7640 7641 -- oldtest: Test_mouse_popup_position() 7642 it('position of right-click menu when clicking near edge', function() 7643 screen:try_resize(50, 20) 7644 exec([[ 7645 set mousemodel=popup_setpos 7646 " Delete the default MenuPopup event handler. 7647 autocmd! nvim.popupmenu 7648 aunmenu * 7649 source $VIMRUNTIME/menu.vim 7650 call setline(1, join(range(20))) 7651 ]]) 7652 7653 if send_mouse_grid then 7654 api.nvim_input_mouse('right', 'press', '', 2, 0, 45 - 1) 7655 else 7656 api.nvim_input_mouse('right', 'press', '', 0, 0, 45 - 1) 7657 end 7658 if multigrid then 7659 screen:expect({ 7660 grid = [[ 7661 ## grid 1 7662 [2:--------------------------------------------------]|*19 7663 [3:--------------------------------------------------]| 7664 ## grid 2 7665 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ^18 19 | 7666 {1:~ }|*18 7667 ## grid 3 7668 | 7669 ## grid 4 7670 {n: Undo }| 7671 {n: }| 7672 {n: Paste }| 7673 {n: }| 7674 {n: Select Word }| 7675 {n: Select Sentence }| 7676 {n: Select Paragraph}| 7677 {n: Select Line }| 7678 {n: Select Block }| 7679 {n: Select All }| 7680 ]], 7681 float_pos = { [4] = { -1, 'NW', 2, 1, 33, false, 250, 2, 1, 33 } }, 7682 }) 7683 else 7684 screen:expect([[ 7685 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ^18 19 | 7686 {1:~ }{n: Undo }| 7687 {1:~ }{n: }| 7688 {1:~ }{n: Paste }| 7689 {1:~ }{n: }| 7690 {1:~ }{n: Select Word }| 7691 {1:~ }{n: Select Sentence }| 7692 {1:~ }{n: Select Paragraph}| 7693 {1:~ }{n: Select Line }| 7694 {1:~ }{n: Select Block }| 7695 {1:~ }{n: Select All }| 7696 {1:~ }|*8 7697 | 7698 ]]) 7699 end 7700 feed('<Esc>') 7701 7702 command('set rightleft') 7703 if send_mouse_grid then 7704 api.nvim_input_mouse('right', 'press', '', 2, 0, 50 - 45) 7705 else 7706 api.nvim_input_mouse('right', 'press', '', 0, 0, 50 - 45) 7707 end 7708 if multigrid then 7709 screen:expect({ 7710 grid = [[ 7711 ## grid 1 7712 [2:--------------------------------------------------]|*19 7713 [3:--------------------------------------------------]| 7714 ## grid 2 7715 91 8^1 71 61 51 41 31 21 11 01 9 8 7 6 5 4 3 2 1 0| 7716 {1: ~}|*18 7717 ## grid 3 7718 | 7719 ## grid 4 7720 {n: odnU }| 7721 {n: }| 7722 {n: etsaP }| 7723 {n: }| 7724 {n: droW tceleS }| 7725 {n: ecnetneS tceleS }| 7726 {n:hpargaraP tceleS }| 7727 {n: eniL tceleS }| 7728 {n: kcolB tceleS }| 7729 {n: llA tceleS }| 7730 ]], 7731 float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 250, 2, 1, 0 } }, 7732 }) 7733 else 7734 screen:expect([[ 7735 91 8^1 71 61 51 41 31 21 11 01 9 8 7 6 5 4 3 2 1 0| 7736 {n: odnU }{1: ~}| 7737 {n: }{1: ~}| 7738 {n: etsaP }{1: ~}| 7739 {n: }{1: ~}| 7740 {n: droW tceleS }{1: ~}| 7741 {n: ecnetneS tceleS }{1: ~}| 7742 {n:hpargaraP tceleS }{1: ~}| 7743 {n: eniL tceleS }{1: ~}| 7744 {n: kcolB tceleS }{1: ~}| 7745 {n: llA tceleS }{1: ~}| 7746 {1: ~}|*8 7747 | 7748 ]]) 7749 end 7750 feed('<Esc>') 7751 command('set norightleft') 7752 end) 7753 7754 if not multigrid then 7755 describe('"kind" and "menu"', function() 7756 before_each(function() 7757 screen:try_resize(30, 8) 7758 exec([[ 7759 func CompleteFunc( findstart, base ) 7760 if a:findstart 7761 return 0 7762 endif 7763 return { 7764 \ 'words': [ 7765 \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', }, 7766 \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', }, 7767 \ { 'word': 'aword3', 'menu': 'extra text 3', 'kind': 'W', }, 7768 \]} 7769 endfunc 7770 set completeopt=menu 7771 set completefunc=CompleteFunc 7772 ]]) 7773 end) 7774 7775 -- oldtest: Test_pum_highlights_default() 7776 it('default highlight groups', function() 7777 feed('iaw<C-X><C-u>') 7778 screen:expect([[ 7779 aword1^ | 7780 {12:aword1 W extra text 1 }{1: }| 7781 {n:aword2 W extra text 2 }{1: }| 7782 {n:aword3 W extra text 3 }{1: }| 7783 {1:~ }|*3 7784 {5:-- }{6:match 1 of 3} | 7785 ]]) 7786 end) 7787 7788 -- oldtest: Test_pum_highlights_custom() 7789 it('custom highlight groups', function() 7790 exec([[ 7791 hi PmenuKind guifg=Red guibg=Plum1 7792 hi PmenuKindSel guifg=Red guibg=Grey 7793 hi PmenuExtra guifg=White guibg=Plum1 7794 hi PmenuExtraSel guifg=Black guibg=Grey 7795 ]]) 7796 feed('iaw<C-X><C-u>') 7797 screen:expect([[ 7798 aword1^ | 7799 {12:aword1 }{ks:W }{xs:extra text 1 }{1: }| 7800 {n:aword2 }{kn:W }{xn:extra text 2 }{1: }| 7801 {n:aword3 }{kn:W }{xn:extra text 3 }{1: }| 7802 {1:~ }|*3 7803 {5:-- }{6:match 1 of 3} | 7804 ]]) 7805 end) 7806 end) 7807 7808 -- oldtest: Test_pum_highlights_match() 7809 it('can highlight matched text', function() 7810 exec([[ 7811 func Omni_test(findstart, base) 7812 if a:findstart 7813 return col(".") 7814 endif 7815 return { 7816 \ 'words': [ 7817 \ { 'word': 'foo', 'kind': 'fookind' }, 7818 \ { 'word': 'foofoo', 'kind': 'fookind' }, 7819 \ { 'word': 'foobar', 'kind': 'fookind' }, 7820 \ { 'word': 'fooBaz', 'kind': 'fookind' }, 7821 \ { 'word': 'foobala', 'kind': 'fookind' }, 7822 \ { 'word': '你好' }, 7823 \ { 'word': '你好吗' }, 7824 \ { 'word': '你不好吗' }, 7825 \ { 'word': '你可好吗' }, 7826 \]} 7827 endfunc 7828 7829 func Comp() 7830 let col = col('.') 7831 if getline('.') == 'f' 7832 let col -= 1 7833 endif 7834 call complete(col, [ 7835 \ #{word: "foo", icase: 1}, 7836 \ #{word: "Foobar", icase: 1}, 7837 \ #{word: "fooBaz", icase: 1}, 7838 \]) 7839 return '' 7840 endfunc 7841 7842 set omnifunc=Omni_test 7843 set completeopt=menu,noinsert,fuzzy 7844 hi PmenuMatchSel guifg=Blue guibg=Grey 7845 hi PmenuMatch guifg=Blue guibg=Plum1 7846 ]]) 7847 feed('i<C-X><C-O>') 7848 local pum_start = [[ 7849 ^ | 7850 {12:foo fookind }{1: }| 7851 {n:foofoo fookind }{1: }| 7852 {n:foobar fookind }{1: }| 7853 {n:fooBaz fookind }{1: }| 7854 {n:foobala fookind }{1: }| 7855 {n:你好 }{1: }| 7856 {n:你好吗 }{1: }| 7857 {n:你不好吗 }{1: }| 7858 {n:你可好吗 }{1: }| 7859 {1:~ }|*9 7860 {5:-- }{6:match 1 of 9} | 7861 ]] 7862 screen:expect(pum_start) 7863 feed('fo') 7864 screen:expect([[ 7865 fo^ | 7866 {ms:fo}{12:o fookind }{1: }| 7867 {mn:fo}{n:ofoo fookind }{1: }| 7868 {mn:fo}{n:obar fookind }{1: }| 7869 {mn:fo}{n:oBaz fookind }{1: }| 7870 {mn:fo}{n:obala fookind }{1: }| 7871 {1:~ }|*13 7872 {5:-- }{6:match 1 of 9} | 7873 ]]) 7874 feed('<Esc>S<C-X><C-O>') 7875 screen:expect(pum_start) 7876 feed('你') 7877 screen:expect([[ 7878 你^ | 7879 {ms:你}{12:好 }{1: }| 7880 {mn:你}{n:好吗 }{1: }| 7881 {mn:你}{n:不好吗 }{1: }| 7882 {mn:你}{n:可好吗 }{1: }| 7883 {1:~ }|*14 7884 {5:-- }{6:match 1 of 9} | 7885 ]]) 7886 feed('吗') 7887 screen:expect([[ 7888 你吗^ | 7889 {ms:你}{12:好}{ms:吗}{12: }{1: }| 7890 {mn:你}{n:不好}{mn:吗}{n: }{1: }| 7891 {mn:你}{n:可好}{mn:吗}{n: }{1: }| 7892 {1:~ }|*15 7893 {5:-- }{6:match 1 of 9} | 7894 ]]) 7895 feed('<C-E><Esc>') 7896 7897 command('set rightleft') 7898 feed('S<C-X><C-O>') 7899 local pum_start_rl = [[ 7900 ^ | 7901 {1: }{12: dnikoof oof}| 7902 {1: }{n: dnikoof oofoof}| 7903 {1: }{n: dnikoof raboof}| 7904 {1: }{n: dnikoof zaBoof}| 7905 {1: }{n: dnikoof alaboof}| 7906 {1: }{n: 好你}| 7907 {1: }{n: 吗好你}| 7908 {1: }{n: 吗好不你}| 7909 {1: }{n: 吗好可你}| 7910 {1: ~}|*9 7911 {5:-- }{6:match 1 of 9} | 7912 ]] 7913 screen:expect(pum_start_rl) 7914 feed('fo') 7915 screen:expect([[ 7916 ^ of| 7917 {1: }{12: dnikoof o}{ms:of}| 7918 {1: }{n: dnikoof oofo}{mn:of}| 7919 {1: }{n: dnikoof rabo}{mn:of}| 7920 {1: }{n: dnikoof zaBo}{mn:of}| 7921 {1: }{n: dnikoof alabo}{mn:of}| 7922 {1: ~}|*13 7923 {5:-- }{6:match 1 of 9} | 7924 ]]) 7925 feed('<Esc>S<C-X><C-O>') 7926 screen:expect(pum_start_rl) 7927 feed('你') 7928 screen:expect([[ 7929 ^ 你| 7930 {1: }{12: 好}{ms:你}| 7931 {1: }{n: 吗好}{mn:你}| 7932 {1: }{n: 吗好不}{mn:你}| 7933 {1: }{n: 吗好可}{mn:你}| 7934 {1: ~}|*14 7935 {5:-- }{6:match 1 of 9} | 7936 ]]) 7937 feed('吗') 7938 screen:expect([[ 7939 ^ 吗你| 7940 {1: }{12: }{ms:吗}{12:好}{ms:你}| 7941 {1: }{n: }{mn:吗}{n:好不}{mn:你}| 7942 {1: }{n: }{mn:吗}{n:好可}{mn:你}| 7943 {1: ~}|*15 7944 {5:-- }{6:match 1 of 9} | 7945 ]]) 7946 feed('<C-E><Esc>') 7947 command('set norightleft') 7948 7949 command('set completeopt-=fuzzy') 7950 feed('S<C-X><C-O>') 7951 screen:expect(pum_start) 7952 feed('fo') 7953 screen:expect([[ 7954 fo^ | 7955 {ms:fo}{12:o fookind }{1: }| 7956 {mn:fo}{n:ofoo fookind }{1: }| 7957 {mn:fo}{n:obar fookind }{1: }| 7958 {mn:fo}{n:oBaz fookind }{1: }| 7959 {mn:fo}{n:obala fookind }{1: }| 7960 {1:~ }|*13 7961 {5:-- }{6:match 1 of 9} | 7962 ]]) 7963 feed('<C-E><Esc>') 7964 7965 command('set rightleft') 7966 feed('S<C-X><C-O>') 7967 screen:expect(pum_start_rl) 7968 feed('fo') 7969 screen:expect([[ 7970 ^ of| 7971 {1: }{12: dnikoof o}{ms:of}| 7972 {1: }{n: dnikoof oofo}{mn:of}| 7973 {1: }{n: dnikoof rabo}{mn:of}| 7974 {1: }{n: dnikoof zaBo}{mn:of}| 7975 {1: }{n: dnikoof alabo}{mn:of}| 7976 {1: ~}|*13 7977 {5:-- }{6:match 1 of 9} | 7978 ]]) 7979 feed('<C-E><Esc>') 7980 command('set norightleft') 7981 7982 feed('S<C-R>=Comp()<CR>f') 7983 screen:expect([[ 7984 f^ | 7985 {ms:f}{12:oo }{1: }| 7986 {mn:F}{n:oobar }{1: }| 7987 {mn:f}{n:ooBaz }{1: }| 7988 {1:~ }|*15 7989 {5:-- INSERT --} | 7990 ]]) 7991 feed('o<BS><C-R>=Comp()<CR>') 7992 screen:expect_unchanged(true) 7993 feed('<C-E><Esc>') 7994 7995 command('hi PmenuMatchSel guibg=NONE') 7996 command('hi PmenuMatch guibg=NONE') 7997 command('set cot=menu,noinsert,fuzzy') 7998 feed('S<C-X><C-O>') 7999 screen:expect(pum_start) 8000 feed('fb') 8001 screen:expect([[ 8002 fb^ | 8003 {ms:f}{12:oo}{ms:B}{12:az fookind }{1: }| 8004 {mn:f}{n:oo}{mn:b}{n:ar fookind }{1: }| 8005 {mn:f}{n:oo}{mn:b}{n:ala fookind }{1: }| 8006 {1:~ }|*15 8007 {5:-- }{6:match 1 of 9} | 8008 ]]) 8009 8010 feed('<C-E><Esc>') 8011 end) 8012 8013 -- oldtest: Test_pum_completefuzzycollect() 8014 it('fuzzy completion', function() 8015 exec([[ 8016 set pumwidth=13 8017 set completeopt=menu,menuone,fuzzy 8018 ]]) 8019 8020 feed('S hello helio hero h<C-X><C-P>') 8021 screen:expect([[ 8022 hello helio hero hello^ | 8023 {1:~ }{n: hero }{1: }| 8024 {1:~ }{n: helio }{1: }| 8025 {1:~ }{12: hello }{1: }| 8026 {1:~ }|*15 8027 {5:-- }{6:match 1 of 3} | 8028 ]]) 8029 8030 feed('<Esc>S hello helio hero h<C-X><C-P><C-P>') 8031 screen:expect([[ 8032 hello helio hero helio^ | 8033 {1:~ }{n: hero }{1: }| 8034 {1:~ }{12: helio }{1: }| 8035 {1:~ }{n: hello }{1: }| 8036 {1:~ }|*15 8037 {5:-- }{6:match 2 of 3} | 8038 ]]) 8039 8040 feed('<Esc>S/non_existing_folder<C-X><C-F>') 8041 screen:expect([[ 8042 /non_existing_folder^ | 8043 {1:~ }|*18 8044 {5:-- }{9:Pattern not found} | 8045 ]]) 8046 feed('<C-E><Esc>') 8047 end) 8048 8049 -- oldtest: Test_pum_highlights_match_with_abbr() 8050 it('can highlight matched text with abbr', function() 8051 exec([[ 8052 func Omni_test(findstart, base) 8053 if a:findstart 8054 return col(".") 8055 endif 8056 return { 8057 \ 'words': [ 8058 \ { 'word': 'foobar', 'abbr': "foobar\t\t!" }, 8059 \ { 'word': 'foobaz', 'abbr': "foobaz\t\t!" }, 8060 \]} 8061 endfunc 8062 8063 set omnifunc=Omni_test 8064 set completeopt=menuone,noinsert 8065 hi PmenuMatchSel guifg=Blue guibg=Grey 8066 hi PmenuMatch guifg=Blue guibg=Plum1 8067 ]]) 8068 feed('i<C-X><C-O>') 8069 screen:expect([[ 8070 ^ | 8071 {12:foobar ! }{1: }| 8072 {n:foobaz ! }{1: }| 8073 {1:~ }|*16 8074 {5:-- }{6:match 1 of 2} | 8075 ]]) 8076 feed('foo') 8077 screen:expect([[ 8078 foo^ | 8079 {ms:foo}{12:bar ! }{1: }| 8080 {mn:foo}{n:baz ! }{1: }| 8081 {1:~ }|*16 8082 {5:-- }{6:match 1 of 2} | 8083 ]]) 8084 8085 feed('<C-E><Esc>') 8086 end) 8087 8088 -- oldtest: Test_pum_user_abbr_hlgroup() 8089 it('custom abbr_hlgroup override', function() 8090 exec([[ 8091 let s:var = 0 8092 func CompleteFunc(findstart, base) 8093 if a:findstart 8094 return 0 8095 endif 8096 if s:var == 1 8097 return { 8098 \ 'words': [ 8099 \ { 'word': 'aword1', 'abbr_hlgroup': 'StrikeFake' }, 8100 \ { 'word': '你好', 'abbr_hlgroup': 'StrikeFake' }, 8101 \]} 8102 endif 8103 return { 8104 \ 'words': [ 8105 \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' }, 8106 \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', }, 8107 \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' }, 8108 \]} 8109 endfunc 8110 func ChangeVar() 8111 let s:var = 1 8112 endfunc 8113 set completeopt=menu 8114 set completefunc=CompleteFunc 8115 8116 hi StrikeFake guifg=DarkRed 8117 func HlMatch() 8118 hi PmenuMatchSel guifg=Blue guibg=Grey gui=underline 8119 hi PmenuMatch guifg=Blue guibg=Plum1 gui=underline 8120 endfunc 8121 ]]) 8122 8123 feed('Saw<C-X><C-U>') 8124 screen:expect([[ 8125 aword1^ | 8126 {ds:aword1}{12: W extra text 1 }{1: }| 8127 {n:aword2 W extra text 2 }{1: }| 8128 {dn:你好}{n: W extra text 3 }{1: }| 8129 {1:~ }|*15 8130 {5:-- }{6:match 1 of 3} | 8131 ]]) 8132 feed('<C-E><Esc>') 8133 8134 command('call HlMatch()') 8135 8136 feed('Saw<C-X><C-U>') 8137 screen:expect([[ 8138 aword1^ | 8139 {uds:aw}{ds:ord1}{12: W extra text 1 }{1: }| 8140 {umn:aw}{n:ord2 W extra text 2 }{1: }| 8141 {dn:你好}{n: W extra text 3 }{1: }| 8142 {1:~ }|*15 8143 {5:-- }{6:match 1 of 3} | 8144 ]]) 8145 feed('<C-N>') 8146 screen:expect([[ 8147 aword2^ | 8148 {udn:aw}{dn:ord1}{n: W extra text 1 }{1: }| 8149 {ums:aw}{12:ord2 W extra text 2 }{1: }| 8150 {dn:你好}{n: W extra text 3 }{1: }| 8151 {1:~ }|*15 8152 {5:-- }{6:match 2 of 3} | 8153 ]]) 8154 feed('<C-E><Esc>') 8155 8156 command('call ChangeVar()') 8157 feed('S<C-X><C-U>') 8158 screen:expect([[ 8159 aword1^ | 8160 {ds:aword1}{12: }{1: }| 8161 {dn:你好}{n: }{1: }| 8162 {1:~ }|*16 8163 {5:-- }{6:match 1 of 2} | 8164 ]]) 8165 feed('<C-E><Esc>') 8166 end) 8167 8168 -- oldtest: Test_pum_user_kind_hlgroup() 8169 it('custom kind_hlgroup override', function() 8170 exec([[ 8171 func CompleteFunc( findstart, base ) 8172 if a:findstart 8173 return 0 8174 endif 8175 return { 8176 \ 'words': [ 8177 \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'variable', 'kind_hlgroup': 'KindVar', 'abbr_hlgroup': 'StrikeFake' }, 8178 \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'function', 'kind_hlgroup': 'KindFunc' }, 8179 \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'class', 'kind_hlgroup': 'KindClass' }, 8180 \]} 8181 endfunc 8182 set completeopt=menu 8183 set completefunc=CompleteFunc 8184 8185 hi StrikeFake guifg=DarkRed 8186 hi KindVar guifg=DarkYellow 8187 hi KindFunc guifg=DarkBlue 8188 hi KindClass guifg=DarkGreen 8189 ]]) 8190 8191 feed('S<C-X><C-U>') 8192 screen:expect([[ 8193 aword1^ | 8194 {ds:aword1}{12: }{110:variable}{12: extra text 1 }{1: }| 8195 {n:aword2 }{111:function}{n: extra text 2 }{1: }| 8196 {n:你好 }{112:class}{n: extra text 3 }{1: }| 8197 {1:~ }|*15 8198 {5:-- }{6:match 1 of 3} | 8199 ]]) 8200 feed('<C-E><Esc>') 8201 end) 8202 8203 -- oldtest: Test_pum_completeitemalign() 8204 it('completeitemalign option', function() 8205 screen:try_resize(30, 15) 8206 exec([[ 8207 func Omni_test(findstart, base) 8208 if a:findstart 8209 return col(".") 8210 endif 8211 return { 8212 \ 'words': [ 8213 \ { 'word': 'foo', 'kind': 'S', 'menu': 'menu' }, 8214 \ { 'word': 'bar', 'kind': 'T', 'menu': 'menu' }, 8215 \ { 'word': '你好', 'kind': 'C', 'menu': '中文' }, 8216 \]} 8217 endfunc 8218 8219 func Omni_long(findstart, base) 8220 if a:findstart 8221 return col(".") 8222 endif 8223 return { 8224 \ 'words': [ 8225 \ { 'word': 'loooong_foo', 'kind': 'S', 'menu': 'menu' }, 8226 \ { 'word': 'loooong_bar', 'kind': 'T', 'menu': 'menu' }, 8227 \]} 8228 endfunc 8229 set omnifunc=Omni_test 8230 ]]) 8231 -- T1 8232 command('set cia=abbr,kind,menu') 8233 feed('S<C-X><C-O>') 8234 screen:expect([[ 8235 foo^ | 8236 {12:foo S menu }{1: }| 8237 {n:bar T menu }{1: }| 8238 {n:你好 C 中文 }{1: }| 8239 {1:~ }|*10 8240 {5:-- }{6:match 1 of 3} | 8241 ]]) 8242 feed('<C-E><ESC>') 8243 -- T2 8244 command('set cia=abbr,menu,kind') 8245 feed('S<C-X><C-O>') 8246 screen:expect([[ 8247 foo^ | 8248 {12:foo menu S }{1: }| 8249 {n:bar menu T }{1: }| 8250 {n:你好 中文 C }{1: }| 8251 {1:~ }|*10 8252 {5:-- }{6:match 1 of 3} | 8253 ]]) 8254 feed('<C-E><ESC>') 8255 -- T3 8256 command('set cia=kind,abbr,menu') 8257 feed('S<C-X><C-O>') 8258 screen:expect([[ 8259 foo^ | 8260 {12:S foo menu }{1: }| 8261 {n:T bar menu }{1: }| 8262 {n:C 你好 中文 }{1: }| 8263 {1:~ }|*10 8264 {5:-- }{6:match 1 of 3} | 8265 ]]) 8266 feed('<C-E><ESC>') 8267 -- T4 8268 command('set cia=kind,menu,abbr') 8269 feed('S<C-X><C-O>') 8270 screen:expect([[ 8271 foo^ | 8272 {12:S menu foo }{1: }| 8273 {n:T menu bar }{1: }| 8274 {n:C 中文 你好 }{1: }| 8275 {1:~ }|*10 8276 {5:-- }{6:match 1 of 3} | 8277 ]]) 8278 feed('<C-E><ESC>') 8279 -- T5 8280 command('set cia=menu,abbr,kind') 8281 feed('S<C-X><C-O>') 8282 screen:expect([[ 8283 foo^ | 8284 {12:menu foo S }{1: }| 8285 {n:menu bar T }{1: }| 8286 {n:中文 你好 C }{1: }| 8287 {1:~ }|*10 8288 {5:-- }{6:match 1 of 3} | 8289 ]]) 8290 feed('<C-E><ESC>') 8291 -- T6 8292 command('set cia=menu,kind,abbr') 8293 feed('S<C-X><C-O>') 8294 screen:expect([[ 8295 foo^ | 8296 {12:menu S foo }{1: }| 8297 {n:menu T bar }{1: }| 8298 {n:中文 C 你好 }{1: }| 8299 {1:~ }|*10 8300 {5:-- }{6:match 1 of 3} | 8301 ]]) 8302 feed('<C-E><ESC>') 8303 -- T7 8304 command('set cia&') 8305 feed('S<C-X><C-O>') 8306 screen:expect([[ 8307 foo^ | 8308 {12:foo S menu }{1: }| 8309 {n:bar T menu }{1: }| 8310 {n:你好 C 中文 }{1: }| 8311 {1:~ }|*10 8312 {5:-- }{6:match 1 of 3} | 8313 ]]) 8314 feed('<C-E><ESC>') 8315 8316 -- Test_pum_completeitemalign_07 8317 command('set cia=menu,kind,abbr columns=12 cmdheight=2 omnifunc=Omni_long') 8318 feed('S<C-X><C-O>') 8319 screen:expect([[ 8320 loooong_foo^ | 8321 {12:menu S looo>}| 8322 {n:menu T looo>}| 8323 {1:~ }|*10 8324 | 8325 {5:--} | 8326 ]]) 8327 feed('<C-E><ESC>') 8328 end) 8329 8330 -- oldtest: Test_pum_matchins_highlight() 8331 it('with ComplMatchIns highlight', function() 8332 exec([[ 8333 let g:change = 0 8334 func Omni_test(findstart, base) 8335 if a:findstart 8336 return col(".") 8337 endif 8338 if g:change == 0 8339 return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}] 8340 endif 8341 return [#{word: "foo", info: "info"}, #{word: "bar"}, #{word: "你好"}] 8342 endfunc 8343 set completeopt-=popup completeopt+=preview 8344 set omnifunc=Omni_test 8345 hi ComplMatchIns guifg=red 8346 ]]) 8347 8348 feed('Sαβγ <C-X><C-O>') 8349 screen:expect([[ 8350 αβγ {19:foo}^ | 8351 {1:~ }{12: foo }{1: }| 8352 {1:~ }{n: bar }{1: }| 8353 {1:~ }{n: 你好 }{1: }| 8354 {1:~ }|*15 8355 {5:-- }{6:match 1 of 3} | 8356 ]]) 8357 feed('<C-E><Esc>') 8358 8359 feed('Sαβγ <C-X><C-O><C-N>') 8360 screen:expect([[ 8361 αβγ {19:bar}^ | 8362 {1:~ }{n: foo }{1: }| 8363 {1:~ }{12: bar }{1: }| 8364 {1:~ }{n: 你好 }{1: }| 8365 {1:~ }|*15 8366 {5:-- }{6:match 2 of 3} | 8367 ]]) 8368 feed('<C-E><Esc>') 8369 8370 feed('Sαβγ <C-X><C-O><C-N><C-N>') 8371 screen:expect([[ 8372 αβγ {19:你好}^ | 8373 {1:~ }{n: foo }{1: }| 8374 {1:~ }{n: bar }{1: }| 8375 {1:~ }{12: 你好 }{1: }| 8376 {1:~ }|*15 8377 {5:-- }{6:match 3 of 3} | 8378 ]]) 8379 feed('<C-E><Esc>') 8380 8381 -- restore after accept 8382 feed('Sαβγ <C-X><C-O><C-Y>') 8383 screen:expect([[ 8384 αβγ foo^ | 8385 {1:~ }|*18 8386 {5:-- INSERT --} | 8387 ]]) 8388 feed('<Esc>') 8389 8390 -- restore after cancel completion 8391 feed('Sαβγ <C-X><C-O><Space>') 8392 screen:expect([[ 8393 αβγ foo ^ | 8394 {1:~ }|*18 8395 {5:-- INSERT --} | 8396 ]]) 8397 feed('<Esc>') 8398 8399 -- text after the inserted text shouldn't be highlighted 8400 feed('0ea <C-X><C-O>') 8401 screen:expect([[ 8402 αβγ {19:foo}^ foo | 8403 {1:~ }{12: foo }{1: }| 8404 {1:~ }{n: bar }{1: }| 8405 {1:~ }{n: 你好 }{1: }| 8406 {1:~ }|*15 8407 {5:-- }{6:match 1 of 3} | 8408 ]]) 8409 feed('<C-P>') 8410 screen:expect([[ 8411 αβγ ^ foo | 8412 {1:~ }{n: foo }{1: }| 8413 {1:~ }{n: bar }{1: }| 8414 {1:~ }{n: 你好 }{1: }| 8415 {1:~ }|*15 8416 {5:-- }{19:Back at original} | 8417 ]]) 8418 feed('<C-P>') 8419 screen:expect([[ 8420 αβγ {19:你好}^ foo | 8421 {1:~ }{n: foo }{1: }| 8422 {1:~ }{n: bar }{1: }| 8423 {1:~ }{12: 你好 }{1: }| 8424 {1:~ }|*15 8425 {5:-- }{6:match 3 of 3} | 8426 ]]) 8427 feed('<C-Y>') 8428 screen:expect([[ 8429 αβγ 你好^ foo | 8430 {1:~ }|*18 8431 {5:-- INSERT --} | 8432 ]]) 8433 feed('<Esc>') 8434 8435 feed(':let g:change=1<CR>S<C-X><C-O>') 8436 screen:expect([[ 8437 info | 8438 {1:~ }|*2 8439 {2:[Scratch] [Preview][-] }| 8440 {19:foo}^ | 8441 {12:foo }{1: }| 8442 {n:bar }{1: }| 8443 {n:你好 }{1: }| 8444 {1:~ }|*10 8445 {3:[No Name] [+] }| 8446 {5:-- }{6:match 1 of 3} | 8447 ]]) 8448 feed('<Esc>') 8449 end) 8450 8451 -- oldtest: Test_pum_matchins_highlight_combine() 8452 it('with ComplMatchIns, Normal and CursorLine highlights', function() 8453 exec([[ 8454 func Omni_test(findstart, base) 8455 if a:findstart 8456 return col(".") 8457 endif 8458 return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}] 8459 endfunc 8460 set completeopt-=popup completeopt+=preview 8461 " Avoid unwanted results in case local workspace has a "tags" file. 8462 set complete-=t 8463 set omnifunc=Omni_test 8464 hi Normal guibg=blue 8465 hi CursorLine guibg=green guifg=white 8466 set cursorline 8467 call setline(1, 'aaa bbb') 8468 ]]) 8469 8470 -- when ComplMatchIns is not set, CursorLine applies normally 8471 feed('0ea <C-X><C-O>') 8472 screen:expect([[ 8473 {101:aaa foo^ bbb }| 8474 {1:~ }{12: foo }{1: }| 8475 {1:~ }{n: bar }{1: }| 8476 {1:~ }{n: 你好 }{1: }| 8477 {1:~ }|*15 8478 {5:-- }{6:match 1 of 3} | 8479 ]]) 8480 feed('<C-E>') 8481 screen:expect([[ 8482 {101:aaa ^ bbb }| 8483 {1:~ }|*18 8484 {5:-- INSERT --} | 8485 ]]) 8486 feed('<BS><Esc>') 8487 8488 -- when ComplMatchIns is set, it is applied over CursorLine 8489 command('hi ComplMatchIns guifg=Yellow') 8490 feed('0ea <C-X><C-O>') 8491 screen:expect([[ 8492 {101:aaa }{100:foo}{101:^ bbb }| 8493 {1:~ }{12: foo }{1: }| 8494 {1:~ }{n: bar }{1: }| 8495 {1:~ }{n: 你好 }{1: }| 8496 {1:~ }|*15 8497 {5:-- }{6:match 1 of 3} | 8498 ]]) 8499 feed('<C-P>') 8500 screen:expect([[ 8501 {101:aaa ^ bbb }| 8502 {1:~ }{n: foo }{1: }| 8503 {1:~ }{n: bar }{1: }| 8504 {1:~ }{n: 你好 }{1: }| 8505 {1:~ }|*15 8506 {5:-- }{19:Back at original} | 8507 ]]) 8508 feed('<C-P>') 8509 screen:expect([[ 8510 {101:aaa }{100:你好}{101:^ bbb }| 8511 {1:~ }{n: foo }{1: }| 8512 {1:~ }{n: bar }{1: }| 8513 {1:~ }{12: 你好 }{1: }| 8514 {1:~ }|*15 8515 {5:-- }{6:match 3 of 3} | 8516 ]]) 8517 feed('<C-E>') 8518 screen:expect([[ 8519 {101:aaa ^ bbb }| 8520 {1:~ }|*18 8521 {5:-- INSERT --} | 8522 ]]) 8523 feed('<Esc>') 8524 8525 -- Does not highlight the compl leader 8526 command('set completeopt+=menuone,noselect') 8527 feed('S<C-X><C-O>') 8528 local pum_start = [[ 8529 {101:^ }| 8530 {n:foo }{1: }| 8531 {n:bar }{1: }| 8532 {n:你好 }{1: }| 8533 {1:~ }|*15 8534 {5:-- }{19:Back at original} | 8535 ]] 8536 screen:expect(pum_start) 8537 feed('f<C-N>') 8538 screen:expect([[ 8539 {101:f}{100:oo}{101:^ }| 8540 {12:foo }{1: }| 8541 {1:~ }|*17 8542 {5:-- }{6:match 1 of 3} | 8543 ]]) 8544 feed('<C-E><ESC>') 8545 8546 command('set completeopt+=fuzzy') 8547 feed('S<C-X><C-O>') 8548 screen:expect(pum_start) 8549 feed('f<C-N>') 8550 screen:expect([[ 8551 {101:foo^ }| 8552 {12:foo }{1: }| 8553 {1:~ }|*17 8554 {5:-- }{6:match 1 of 3} | 8555 ]]) 8556 feed('<C-E><Esc>') 8557 8558 command('set completeopt-=fuzzy') 8559 feed('Sf<C-N>') 8560 screen:expect([[ 8561 {101:f^ }| 8562 {1:~ }|*18 8563 {5:-- }{9:Pattern not found} | 8564 ]]) 8565 feed('<C-E><Esc>') 8566 end) 8567 8568 -- oldtest: Test_pum_complete_with_special_characters() 8569 it('multi-line completion', function() 8570 exec([[ 8571 func Omni_test(findstart, base) 8572 if a:findstart 8573 return col(".") 8574 endif 8575 return [#{word: "func ()\n\t\nend", abbr: "function ()",}, #{word: "foobar"}, #{word: "你好\n\t\n我好"}] 8576 endfunc 8577 set omnifunc=Omni_test 8578 inoremap <F5> <Cmd>call complete(col('.'), [ "my\n\tmulti\nline", "my\n\t\tmulti\nline" ])<CR> 8579 ]]) 8580 8581 feed('S<C-X><C-O>') 8582 screen:expect([[ 8583 func () | 8584 | 8585 end^ | 8586 {12:function () }{1: }| 8587 {n:foobar }{1: }| 8588 {n:你好^@ ^@我好 }{1: }| 8589 {1:~ }|*13 8590 {5:-- }{6:match 1 of 3} | 8591 ]]) 8592 8593 feed('<C-N>') 8594 screen:expect([[ 8595 foobar^ | 8596 {n:function () }{1: }| 8597 {12:foobar }{1: }| 8598 {n:你好^@ ^@我好 }{1: }| 8599 {1:~ }|*15 8600 {5:-- }{6:match 2 of 3} | 8601 ]]) 8602 feed('<C-E><ESC>') 8603 8604 feed('Shello hero<ESC>hhhhha<C-X><C-O>') 8605 screen:expect([[ 8606 hello func () | 8607 | 8608 end^ hero | 8609 {1:~ }{12: function () }{1: }| 8610 {1:~ }{n: foobar }{1: }| 8611 {1:~ }{n: 你好^@ ^@我好 }{1: }| 8612 {1:~ }|*13 8613 {5:-- }{6:match 1 of 3} | 8614 ]]) 8615 8616 feed('<C-N>') 8617 screen:expect([[ 8618 hello foobar^ hero | 8619 {1:~ }{n: function () }{1: }| 8620 {1:~ }{12: foobar }{1: }| 8621 {1:~ }{n: 你好^@ ^@我好 }{1: }| 8622 {1:~ }|*15 8623 {5:-- }{6:match 2 of 3} | 8624 ]]) 8625 8626 feed('<C-N>') 8627 screen:expect([[ 8628 hello 你好 | 8629 | 8630 我好^ hero | 8631 {1:~ }{n: function () }{1: }| 8632 {1:~ }{n: foobar }{1: }| 8633 {1:~ }{12: 你好^@ ^@我好 }{1: }| 8634 {1:~ }|*13 8635 {5:-- }{6:match 3 of 3} | 8636 ]]) 8637 8638 feed('<C-N>') 8639 screen:expect([[ 8640 hello ^ hero | 8641 {1:~ }{n: function () }{1: }| 8642 {1:~ }{n: foobar }{1: }| 8643 {1:~ }{n: 你好^@ ^@我好 }{1: }| 8644 {1:~ }|*15 8645 {5:-- }{19:Back at original} | 8646 ]]) 8647 feed('<C-E><ESC>') 8648 8649 command(':hi ComplMatchIns guifg=red') 8650 feed('S<C-X><C-O>') 8651 screen:expect([[ 8652 {19:func ()} | 8653 {19: } | 8654 {19:end}^ | 8655 {12:function () }{1: }| 8656 {n:foobar }{1: }| 8657 {n:你好^@ ^@我好 }{1: }| 8658 {1:~ }|*13 8659 {5:-- }{6:match 1 of 3} | 8660 ]]) 8661 feed('<C-E><ESC>') 8662 8663 feed('Shello hero<ESC>hhhhha<C-X><C-O>') 8664 screen:expect([[ 8665 hello {19:func ()} | 8666 {19: } | 8667 {19:end^ }hero | 8668 {1:~ }{12: function () }{1: }| 8669 {1:~ }{n: foobar }{1: }| 8670 {1:~ }{n: 你好^@ ^@我好 }{1: }| 8671 {1:~ }|*13 8672 {5:-- }{6:match 1 of 3} | 8673 ]]) 8674 feed('<C-E><ESC>') 8675 8676 command('setlocal autoindent shiftwidth=2 tabstop=2') 8677 feed('Slocal a = <C-X><C-O>') 8678 screen:expect([[ 8679 local a = {19:func ()} | 8680 {19: } | 8681 {19:end}^ | 8682 {1:~ }{12: function () }{1: }| 8683 {1:~ }{n: foobar }{1: }| 8684 {1:~ }{n: 你好^@ ^@我好 }{1: }| 8685 {1:~ }|*13 8686 {5:-- }{6:match 1 of 3} | 8687 ]]) 8688 8689 feed('<C-Y>') 8690 screen:expect([[ 8691 local a = {19:func ()} | 8692 {19: } | 8693 end^ | 8694 {1:~ }|*16 8695 {5:-- INSERT --} | 8696 ]]) 8697 8698 feed('<ESC>kAlocal b = <C-X><C-O>') 8699 screen:expect([[ 8700 local a = {19:func ()} | 8701 local b = {19:func ()} | 8702 {19: } | 8703 {19: end}^ | 8704 end {12: function () } | 8705 {1:~ }{n: foobar }{1: }| 8706 {1:~ }{n: 你好^@ ^@我好 }{1: }| 8707 {1:~ }|*12 8708 {5:-- }{6:match 1 of 3} | 8709 ]]) 8710 8711 feed('<C-Y>') 8712 screen:expect([[ 8713 local a = {19:func ()} | 8714 local b = {19:func ()} | 8715 {19: } | 8716 end^ | 8717 end | 8718 {1:~ }|*14 8719 {5:-- INSERT --} | 8720 ]]) 8721 8722 feed('<Esc>ggVGd') 8723 command('filetype indent on') 8724 command('setlocal noautoindent shiftwidth& tabstop&') 8725 command('setlocal ft=lua') 8726 feed('S<F5>') 8727 screen:expect([[ 8728 {19:my} | 8729 {19: multi} | 8730 {19:line}^ | 8731 {12:my^@ multi^@line }{1: }| 8732 {n:my^@ multi^@line }{1: }| 8733 {1:~ }|*14 8734 {5:-- INSERT --} | 8735 ]]) 8736 end) 8737 8738 -- oldtest: Test_pum_clear_when_switch_tab_or_win() 8739 it('is cleared when switching tab or win', function() 8740 screen:try_resize(55, 20) 8741 exec([[ 8742 inoremap <F4> <Cmd>wincmd w<CR> 8743 inoremap <F5> <Cmd>tabnext<CR> 8744 ]]) 8745 8746 command('tabe') 8747 feed('Aaa aaa <C-X><C-N>') 8748 screen:expect([[ 8749 {24: [No Name] }{5: + [No Name] }{2: }{24:X}| 8750 aa aaa aa^ | 8751 {1:~ }{12: aa }{1: }| 8752 {1:~ }{n: aaa }{1: }| 8753 {1:~ }|*15 8754 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 8755 ]]) 8756 feed('<F5>') 8757 screen:expect([[ 8758 {5: [No Name] }{24: + [No Name] }{2: }{24:X}| 8759 ^ | 8760 {1:~ }|*17 8761 {5:-- INSERT --} | 8762 ]]) 8763 feed('<Esc>') 8764 command('tabclose!') 8765 8766 command('vnew win_b') 8767 feed('Abb bbb <C-X><C-N>') 8768 screen:expect([[ 8769 bb bbb bb^ │aa aaa aa | 8770 {1:~ }{12: bb }{1: }│{1:~ }| 8771 {1:~ }{n: bbb }{1: }│{1:~ }| 8772 {1:~ }│{1:~ }|*15 8773 {3:win_b [+] }{2:[No Name] [+] }| 8774 {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 8775 ]]) 8776 feed('<F4>') 8777 screen:expect([[ 8778 bb bbb bb │aa aaa a^a | 8779 {1:~ }│{1:~ }|*17 8780 {2:win_b [+] }{3:[No Name] [+] }| 8781 {5:-- INSERT --} | 8782 ]]) 8783 end) 8784 end 8785 8786 describe("'pumborder'", function() 8787 before_each(function() 8788 screen:try_resize(30, 11) 8789 exec([[ 8790 let g:list = [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}] 8791 funct Omni_test(findstart, base) 8792 if a:findstart 8793 return col(".") - 1 8794 endif 8795 return g:list 8796 endfunc 8797 hi link PmenuBorder FloatBorder 8798 set omnifunc=Omni_test 8799 set completeopt-=preview 8800 set pumborder=rounded 8801 ]]) 8802 end) 8803 8804 it('can set border', function() 8805 feed('Gi<C-x><C-o>') 8806 if multigrid then 8807 screen:expect({ 8808 grid = [[ 8809 ## grid 1 8810 [2:------------------------------]|*10 8811 [3:------------------------------]| 8812 ## grid 2 8813 one^ | 8814 {1:~ }|*9 8815 ## grid 3 8816 {5:-- }{6:match 1 of 3} | 8817 ## grid 4 8818 {n:1info}| 8819 ## grid 5 8820 ╭───────────────╮| 8821 │{12:one }│| 8822 │{n:two }│| 8823 │{n:three }│| 8824 ╰───────────────╯| 8825 ]], 8826 win_pos = { 8827 [2] = { 8828 height = 10, 8829 startcol = 0, 8830 startrow = 0, 8831 width = 30, 8832 win = 1000, 8833 }, 8834 }, 8835 float_pos = { 8836 [5] = { -1, 'NW', 2, 1, 0, false, 100, 2, 1, 0 }, 8837 [4] = { 1001, 'NW', 1, 1, 17, false, 50, 1, 1, 17 }, 8838 }, 8839 win_viewport = { 8840 [2] = { 8841 win = 1000, 8842 topline = 0, 8843 botline = 2, 8844 curline = 0, 8845 curcol = 3, 8846 linecount = 1, 8847 sum_scroll_delta = 0, 8848 }, 8849 [4] = { 8850 win = 1001, 8851 topline = 0, 8852 botline = 1, 8853 curline = 0, 8854 curcol = 0, 8855 linecount = 1, 8856 sum_scroll_delta = 0, 8857 }, 8858 }, 8859 win_viewport_margins = { 8860 [2] = { 8861 bottom = 0, 8862 left = 0, 8863 right = 0, 8864 top = 0, 8865 win = 1000, 8866 }, 8867 [4] = { 8868 bottom = 0, 8869 left = 0, 8870 right = 0, 8871 top = 0, 8872 win = 1001, 8873 }, 8874 }, 8875 }) 8876 else 8877 screen:expect([[ 8878 one^ | 8879 ╭───────────────╮{n:1info}{1: }| 8880 │{12:one }│{1: }| 8881 │{n:two }│{1: }| 8882 │{n:three }│{1: }| 8883 ╰───────────────╯{1: }| 8884 {1:~ }|*4 8885 {5:-- }{6:match 1 of 3} | 8886 ]]) 8887 end 8888 8889 -- avoid out of screen 8890 feed(('a'):rep(25) .. '<C-x><C-o>') 8891 if multigrid then 8892 screen:expect({ 8893 grid = [[ 8894 ## grid 1 8895 [2:------------------------------]|*10 8896 [3:------------------------------]| 8897 ## grid 2 8898 oneaaaaaaaaaaaaaaaaaaaaaaaaaon| 8899 e^ | 8900 {1:~ }|*8 8901 ## grid 3 8902 {5:-- }{6:match 1 of 3} | 8903 ## grid 4 8904 {n:1info}| 8905 ## grid 5 8906 ╭─────────────────╮| 8907 │{12: one }│| 8908 │{n: two }│| 8909 │{n: three }│| 8910 ╰─────────────────╯| 8911 ]], 8912 win_pos = { 8913 [2] = { 8914 height = 10, 8915 startcol = 0, 8916 startrow = 0, 8917 width = 30, 8918 win = 1000, 8919 }, 8920 }, 8921 float_pos = { 8922 [5] = { -1, 'NW', 2, 2, 11, false, 100, 2, 2, 11 }, 8923 [4] = { 1001, 'NW', 1, 2, 6, false, 50, 1, 2, 6 }, 8924 }, 8925 win_viewport = { 8926 [2] = { 8927 win = 1000, 8928 topline = 0, 8929 botline = 2, 8930 curline = 0, 8931 curcol = 31, 8932 linecount = 1, 8933 sum_scroll_delta = 0, 8934 }, 8935 [4] = { 8936 win = 1001, 8937 topline = 0, 8938 botline = 1, 8939 curline = 0, 8940 curcol = 0, 8941 linecount = 1, 8942 sum_scroll_delta = 0, 8943 }, 8944 }, 8945 win_viewport_margins = { 8946 [2] = { 8947 bottom = 0, 8948 left = 0, 8949 right = 0, 8950 top = 0, 8951 win = 1000, 8952 }, 8953 [4] = { 8954 bottom = 0, 8955 left = 0, 8956 right = 0, 8957 top = 0, 8958 win = 1001, 8959 }, 8960 }, 8961 }) 8962 else 8963 screen:expect([[ 8964 oneaaaaaaaaaaaaaaaaaaaaaaaaaon| 8965 e^ | 8966 {1:~ }{n:1info}╭─────────────────╮| 8967 {1:~ }│{12: one }│| 8968 {1:~ }│{n: two }│| 8969 {1:~ }│{n: three }│| 8970 {1:~ }╰─────────────────╯| 8971 {1:~ }|*3 8972 {5:-- }{6:match 1 of 3} | 8973 ]]) 8974 end 8975 end) 8976 8977 it('adjust to above when the below row + border out of win height', function() 8978 command('set completeopt+=menuone,noselect') 8979 feed('<ESC>Stwo' .. ('<CR>'):rep(6) .. 'tw<C-N>') 8980 if multigrid then 8981 screen:expect({ 8982 grid = [[ 8983 ## grid 1 8984 [2:------------------------------]|*10 8985 [3:------------------------------]| 8986 ## grid 2 8987 two | 8988 |*5 8989 tw^ | 8990 {1:~ }|*3 8991 ## grid 3 8992 {5:-- }{19:Back at original} | 8993 ## grid 4 8994 ╭───────────────╮| 8995 │{n:two }│| 8996 ╰───────────────╯| 8997 ]], 8998 win_pos = { 8999 [2] = { 9000 height = 10, 9001 startcol = 0, 9002 startrow = 0, 9003 width = 30, 9004 win = 1000, 9005 }, 9006 }, 9007 float_pos = { 9008 [4] = { -1, 'SW', 2, 4, 0, false, 100, 1, 3, 0 }, 9009 }, 9010 win_viewport = { 9011 [2] = { 9012 win = 1000, 9013 topline = 0, 9014 botline = 8, 9015 curline = 6, 9016 curcol = 2, 9017 linecount = 7, 9018 sum_scroll_delta = 0, 9019 }, 9020 }, 9021 win_viewport_margins = { 9022 [2] = { 9023 bottom = 0, 9024 left = 0, 9025 right = 0, 9026 top = 0, 9027 win = 1000, 9028 }, 9029 }, 9030 }) 9031 else 9032 screen:expect([[ 9033 two | 9034 |*2 9035 ╭───────────────╮ | 9036 │{n:two }│ | 9037 ╰───────────────╯ | 9038 tw^ | 9039 {1:~ }|*3 9040 {5:-- }{19:Back at original} | 9041 ]]) 9042 end 9043 end) 9044 9045 it("'pumborder' on cmdline and scrollbar rendering", function() 9046 command('set wildoptions=pum') 9047 feed(':t<TAB>') 9048 if multigrid then 9049 screen:expect({ 9050 grid = [[ 9051 ## grid 1 9052 [2:------------------------------]|*10 9053 [3:------------------------------]| 9054 ## grid 2 9055 | 9056 {1:~ }|*9 9057 ## grid 3 9058 :t^ | 9059 ## grid 4 9060 ╭────────────────╮| 9061 │{12: t }{c: }| 9062 │{n: tNext }│| 9063 │{n: tab }│| 9064 │{n: tabNext }│| 9065 │{n: tabclose }│| 9066 │{n: tabdo }│| 9067 │{n: tabedit }│| 9068 │{n: tabfind }│| 9069 ╰────────────────╯| 9070 ]], 9071 win_pos = { 9072 [2] = { 9073 height = 10, 9074 startcol = 0, 9075 startrow = 0, 9076 width = 30, 9077 win = 1000, 9078 }, 9079 }, 9080 float_pos = { 9081 [4] = { -1, 'SW', 1, 8, 0, false, 250, 2, 0, 0 }, 9082 }, 9083 win_viewport = { 9084 [2] = { 9085 win = 1000, 9086 topline = 0, 9087 botline = 2, 9088 curline = 0, 9089 curcol = 0, 9090 linecount = 1, 9091 sum_scroll_delta = 0, 9092 }, 9093 }, 9094 win_viewport_margins = { 9095 [2] = { 9096 bottom = 0, 9097 left = 0, 9098 right = 0, 9099 top = 0, 9100 win = 1000, 9101 }, 9102 }, 9103 }) 9104 else 9105 screen:expect([[ 9106 ╭────────────────╮ | 9107 │{12: t }{c: }{1: }| 9108 │{n: tNext }│{1: }| 9109 │{n: tab }│{1: }| 9110 │{n: tabNext }│{1: }| 9111 │{n: tabclose }│{1: }| 9112 │{n: tabdo }│{1: }| 9113 │{n: tabedit }│{1: }| 9114 │{n: tabfind }│{1: }| 9115 ╰────────────────╯{1: }| 9116 :t^ | 9117 ]]) 9118 end 9119 9120 feed(('<C-N>'):rep(20)) 9121 if not multigrid then 9122 screen:expect([[ 9123 ╭────────────────╮ | 9124 │{n: tabs }│{1: }| 9125 │{n: tag }│{1: }| 9126 │{n: tags }│{1: }| 9127 │{n: tcd }{c: }{1: }| 9128 │{12: tchdir }│{1: }| 9129 │{n: tcl }│{1: }| 9130 │{n: tcldo }│{1: }| 9131 │{n: tclfile }│{1: }| 9132 ╰────────────────╯{1: }| 9133 :tchdir^ | 9134 ]]) 9135 end 9136 feed(('<C-P>'):rep(20)) 9137 if not multigrid then 9138 screen:expect([[ 9139 ╭────────────────╮ | 9140 │{12: t }{c: }{1: }| 9141 │{n: tNext }│{1: }| 9142 │{n: tab }│{1: }| 9143 │{n: tabNext }│{1: }| 9144 │{n: tabclose }│{1: }| 9145 │{n: tabdo }│{1: }| 9146 │{n: tabedit }│{1: }| 9147 │{n: tabfind }│{1: }| 9148 ╰────────────────╯{1: }| 9149 :t^ | 9150 ]]) 9151 end 9152 end) 9153 9154 it('reduce pum height when height is not enough', function() 9155 command('set lines=7 laststatus=2') 9156 feed('S<C-x><C-o>') 9157 if multigrid then 9158 screen:expect({ 9159 grid = [[ 9160 ## grid 1 9161 [2:------------------------------]|*5 9162 {3:[No Name] [+] }| 9163 [3:------------------------------]| 9164 ## grid 2 9165 one^ | 9166 {1:~ }|*4 9167 ## grid 3 9168 {5:-- }{6:match 1 of 3} | 9169 ## grid 4 9170 ╭───────────────╮| 9171 │{12:one }{c: }| 9172 ╰───────────────╯| 9173 ]], 9174 win_pos = { 9175 [2] = { 9176 height = 5, 9177 startcol = 0, 9178 startrow = 0, 9179 width = 30, 9180 win = 1000, 9181 }, 9182 }, 9183 float_pos = { 9184 [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 }, 9185 }, 9186 win_viewport = { 9187 [2] = { 9188 win = 1000, 9189 topline = 0, 9190 botline = 2, 9191 curline = 0, 9192 curcol = 3, 9193 linecount = 1, 9194 sum_scroll_delta = 0, 9195 }, 9196 }, 9197 win_viewport_margins = { 9198 [2] = { 9199 bottom = 0, 9200 left = 0, 9201 right = 0, 9202 top = 0, 9203 win = 1000, 9204 }, 9205 }, 9206 }) 9207 else 9208 screen:expect([[ 9209 one^ | 9210 ╭───────────────╮{1: }| 9211 │{12:one }{c: }{1: }| 9212 ╰───────────────╯{1: }| 9213 {1:~ }| 9214 {3:[No Name] [+] }| 9215 {5:-- }{6:match 1 of 3} | 9216 ]]) 9217 end 9218 end) 9219 it('custom pumborder characters', function() 9220 command('set pumborder=+,+,=,+,+,-,+,+') 9221 feed('S<C-x><C-o>') 9222 if not multigrid then 9223 screen:expect([[ 9224 one^ | 9225 ++++++++++++++++={n:1info}{1: }| 9226 +{12:one }+{1: }| 9227 +{n:two }+{1: }| 9228 +{n:three }+{1: }| 9229 +---------------+{1: }| 9230 {1:~ }|*4 9231 {5:-- }{6:match 1 of 3} | 9232 ]]) 9233 end 9234 end) 9235 it("'pumborder' with shadow", function() 9236 command('set pumborder=shadow') 9237 insert('line1\nline2line2line2line2\nline3\nline4line4line4\nline5line5') 9238 feed('ggO<C-x><C-o>') 9239 if multigrid then 9240 screen:expect({ 9241 grid = [[ 9242 ## grid 1 9243 [2:------------------------------]|*10 9244 [3:------------------------------]| 9245 ## grid 2 9246 one^ | 9247 line1 | 9248 line2line2line2line2 | 9249 line3 | 9250 line4line4line4 | 9251 line5line5 | 9252 {1:~ }|*4 9253 ## grid 3 9254 {5:-- }{6:match 1 of 3} | 9255 ## grid 4 9256 {n:1info}| 9257 ## grid 5 9258 {12:one }{114: }| 9259 {n:two }{115: }| 9260 {n:three }{115: }| 9261 {114: }{115: }| 9262 ]], 9263 win_pos = { 9264 [2] = { 9265 height = 10, 9266 startcol = 0, 9267 startrow = 0, 9268 width = 30, 9269 win = 1000, 9270 }, 9271 }, 9272 float_pos = { 9273 [5] = { -1, 'NW', 2, 1, 0, false, 100, 2, 1, 0 }, 9274 [4] = { 1001, 'NW', 1, 1, 16, false, 50, 1, 1, 16 }, 9275 }, 9276 }) 9277 else 9278 screen:expect([[ 9279 one^ | 9280 {12:one }{116: }{n:1info} | 9281 {n:two }{117:l}ine2 | 9282 {n:three }{117: } | 9283 {116:l}{117:ine4line4line4 } | 9284 line5line5 | 9285 {1:~ }|*4 9286 {5:-- }{6:match 1 of 3} | 9287 ]]) 9288 end 9289 command('set pumheight=2') 9290 feed('<C-x><C-O>') 9291 if multigrid then 9292 screen:expect({ 9293 grid = [[ 9294 ## grid 1 9295 [2:------------------------------]|*10 9296 [3:------------------------------]| 9297 ## grid 2 9298 oneone^ | 9299 line1 | 9300 line2line2line2line2 | 9301 line3 | 9302 line4line4line4 | 9303 line5line5 | 9304 {1:~ }|*4 9305 ## grid 3 9306 {5:-- }{6:match 1 of 3} | 9307 ## grid 4 9308 {n:1info}| 9309 ## grid 5 9310 {12: one }{c: }{114: }| 9311 {n: two }{12: }{115: }| 9312 {114: }{115: }| 9313 ]], 9314 win_pos = { 9315 [2] = { 9316 height = 10, 9317 startcol = 0, 9318 startrow = 0, 9319 width = 30, 9320 win = 1000, 9321 }, 9322 }, 9323 float_pos = { 9324 [5] = { -1, 'NW', 2, 1, 2, false, 100, 2, 1, 2 }, 9325 [4] = { 1001, 'NW', 1, 1, 19, false, 50, 1, 1, 19 }, 9326 }, 9327 }) 9328 else 9329 screen:expect([[ 9330 oneone^ | 9331 li{12: one }{c: }{116: }{n:info} | 9332 li{n: two }{12: }{117:2} | 9333 li{116:n}{117:e3 } | 9334 line4line4line4 | 9335 line5line5 | 9336 {1:~ }|*4 9337 {5:-- }{6:match 1 of 3} | 9338 ]]) 9339 end 9340 end) 9341 it("'pumborder' with none #36207", function() 9342 command('set wildoptions=pum pumborder=none') 9343 feed(':<TAB>') 9344 if multigrid then 9345 screen:expect({ 9346 grid = [[ 9347 ## grid 1 9348 [2:------------------------------]|*10 9349 [3:------------------------------]| 9350 ## grid 2 9351 | 9352 {1:~ }|*9 9353 ## grid 3 9354 :!^ | 9355 ## grid 4 9356 {12: ! }{c: }| 9357 {n: # }{12: }| 9358 {n: & }{12: }| 9359 {n: < }{12: }| 9360 {n: = }{12: }| 9361 {n: > }{12: }| 9362 {n: @ }{12: }| 9363 {n: Next }{12: }| 9364 {n: abbreviate }{12: }| 9365 {n: abclear }{12: }| 9366 ]], 9367 win_pos = { 9368 [2] = { 9369 height = 10, 9370 startcol = 0, 9371 startrow = 0, 9372 width = 30, 9373 win = 1000, 9374 }, 9375 }, 9376 float_pos = { 9377 [4] = { -1, 'SW', 1, 10, 0, false, 250, 2, 0, 0 }, 9378 }, 9379 win_viewport = { 9380 [2] = { 9381 win = 1000, 9382 topline = 0, 9383 botline = 2, 9384 curline = 0, 9385 curcol = 0, 9386 linecount = 1, 9387 sum_scroll_delta = 0, 9388 }, 9389 }, 9390 win_viewport_margins = { 9391 [2] = { 9392 bottom = 0, 9393 left = 0, 9394 right = 0, 9395 top = 0, 9396 win = 1000, 9397 }, 9398 }, 9399 }) 9400 else 9401 screen:expect([[ 9402 {12: ! }{c: } | 9403 {n: # }{12: }{1: }| 9404 {n: & }{12: }{1: }| 9405 {n: < }{12: }{1: }| 9406 {n: = }{12: }{1: }| 9407 {n: > }{12: }{1: }| 9408 {n: @ }{12: }{1: }| 9409 {n: Next }{12: }{1: }| 9410 {n: abbreviate }{12: }{1: }| 9411 {n: abclear }{12: }{1: }| 9412 :!^ | 9413 ]]) 9414 end 9415 feed('<ESC>:set pumheight=2<CR>Gi<C-X><C-O>') 9416 if not multigrid then 9417 screen:expect([[ 9418 one^ | 9419 {12:one }{c: }{n:1info}{1: }| 9420 {n:two }{12: }{1: }| 9421 {1:~ }|*7 9422 {5:-- }{6:match 1 of 3} | 9423 ]]) 9424 end 9425 end) 9426 it("no crash when 'pumborder' set #36337", function() 9427 command('set autocomplete pumborder=rounded complete=o cot=popup,menuone,noinsert') 9428 command('set columns=50 lines=20') 9429 exec_lua(function() 9430 local list1 = { 9431 { abbr = 'array: ', info = '', kind = 'Field', word = 'array: ' }, 9432 { abbr = 'arrays: ', info = '', kind = 'Field', word = 'arrays: ' }, 9433 } 9434 local list2 = { 9435 { abbr = 'match ', info = '', kind = 'Keyword', word = 'match ' }, 9436 { abbr = 'throw ', info = '', kind = 'Keyword', word = 'throw ' }, 9437 { abbr = 'array: ', info = '', kind = 'Field', word = 'array: ' }, 9438 { abbr = 'arrays: ', info = '', kind = 'Field', word = 'arrays: ' }, 9439 } 9440 _G.fake_omni = function(_, _) 9441 local line = vim.api.nvim_get_current_line() 9442 if line:find('%s%)$') then 9443 vim.schedule(function() 9444 vim.fn.complete(25, list1) 9445 vim.fn.complete(25, list2) 9446 end) 9447 end 9448 return -2 9449 end 9450 vim.opt.omnifunc = 'v:lua.fake_omni' 9451 vim.api.nvim_buf_set_lines(0, 0, -1, true, { '<?php', 'array_intersect_key($x)' }) 9452 vim.cmd.normal('G$') 9453 end) 9454 feed('i, ') 9455 poke_eventloop() 9456 assert_alive() 9457 eq({ 4, 1 }, { #fn.complete_info({ 'items' }).items, fn.pumvisible() }) 9458 end) 9459 9460 it("works with 'pummaxwidth' #test", function() 9461 exec([[ 9462 set pummaxwidth=10 9463 set cot+=menuone 9464 let g:list = [#{word: repeat('fo', 10)}] 9465 ]]) 9466 feed('S<C-x><C-o>') 9467 if multigrid then 9468 screen:expect({ 9469 grid = [[ 9470 ## grid 1 9471 [2:------------------------------]|*10 9472 [3:------------------------------]| 9473 ## grid 2 9474 fofofofofofofofofofo^ | 9475 {1:~ }|*9 9476 ## grid 3 9477 {5:-- The only match} | 9478 ## grid 4 9479 ╭──────────╮| 9480 │{12:fofofofof>}│| 9481 ╰──────────╯| 9482 ]], 9483 float_pos = { 9484 [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 }, 9485 }, 9486 }) 9487 else 9488 screen:expect([[ 9489 fofofofofofofofofofo^ | 9490 ╭──────────╮{1: }| 9491 │{12:fofofofof>}│{1: }| 9492 ╰──────────╯{1: }| 9493 {1:~ }|*6 9494 {5:-- The only match} | 9495 ]]) 9496 end 9497 end) 9498 end) 9499 end 9500 9501 describe('with ext_multigrid and actual mouse grid', function() 9502 with_ext_multigrid(true, true) 9503 end) 9504 9505 describe('with ext_multigrid and mouse grid 0', function() 9506 with_ext_multigrid(true, false) 9507 end) 9508 9509 describe('without ext_multigrid', function() 9510 with_ext_multigrid(false, false) 9511 end) 9512 end)