1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783
|
let s:timer_interval = 2000
function! s:WaitForSigHelpAvailable( filetype )
let tries = 0
call WaitFor( {-> s:_CheckSignatureHelpAvailable( a:filetype ) } )
while py3eval(
\ 'ycm_state._signature_help_available_requests[ '
\ . 'vim.eval( "a:filetype" ) ].Response() == "PENDING"' ) &&
\ tries < 10
" Force sending another request
py3 ycm_state._signature_help_available_requests[
\ vim.eval( 'a:filetype' ) ].Start( vim.eval( 'a:filetype' ) )
call WaitFor( {-> s:_CheckSignatureHelpAvailable( a:filetype ) } )
let tries += 1
endwhile
call ch_log( "Signature help is avaialble now for " . a:filetype )
endfunction
function! s:_ClearSigHelp()
pythonx _sh_state = sh.UpdateSignatureHelp( _sh_state, {} )
call assert_true( pyxeval( '_sh_state.popup_win_id is None' ),
\ 'win id none with emtpy' )
unlet! s:popup_win_id
endfunction
function! s:_CheckSignatureHelpAvailable( filetype )
return pyxeval(
\ 'ycm_state.SignatureHelpAvailableRequestComplete('
\ . ' vim.eval( "a:filetype" ), False )' )
endfunction
function s:_GetSigHelpWinID()
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ 'ycm_state.SignatureHelpRequestReady()'
\ ),
\ 'sig help request reqdy'
\ )
\ } )
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ 'ycm_state._signature_help_state.popup_win_id is not None'
\ ),
\ 'popup_win_id'
\ )
\ } )
let s:popup_win_id = pyxeval( 'ycm_state._signature_help_state.popup_win_id' )
return s:popup_win_id
endfunction
function! s:_CheckSigHelpAtPos( sh, cursor, pos )
call setpos( '.', [ 0 ] + a:cursor )
redraw
pythonx _sh_state = sh.UpdateSignatureHelp( _sh_state,
\ vim.eval( 'a:sh' ) )
redraw
let winid = pyxeval( '_sh_state.popup_win_id' )
call youcompleteme#test#popup#CheckPopupPosition( winid, a:pos )
endfunction
function! SetUp()
let g:ycm_use_clangd = 1
let g:ycm_confirm_extra_conf = 0
let g:ycm_auto_trigger = 1
let g:ycm_keep_logfiles = 1
let g:ycm_log_level = 'DEBUG'
call youcompleteme#test#setup#SetUp()
pythonx from ycm import signature_help as sh
pythonx _sh_state = sh.SignatureHelpState()
endfunction
function! TearDown()
call s:_ClearSigHelp()
call youcompleteme#test#setup#CleanUp()
endfunction
" This is how we might do screen dump tests
" function! Test_Compl()
" let setup =<< trim END
" edit ../third_party/ycmd/ycmd/tests/clangd/testdata/general_fallback/make_drink.cc
" call setpos( '.', [ 0, 7, 27 ] )
" END
" call writefile( setup, 'Xtest_Compl' )
" let vim = RunVimInTerminal( '-Nu vimrc -S Xtest_Compl', {} )
"
" function! Test() closure
" " Wait for Vim to be ready
" call term_sendkeys( vim, "cl:" )
" call term_wait( vim )
" call VerifyScreenDump( vim, "signature_help_Test_Compl_01", {} )
" endfunction
"
" call WaitForAssert( {-> Test()} )
"
" " clean up
" call StopVimInTerminal(vim)
" call delete('XtestPopup')
" endfunction
function! Test_Enough_Screen_Space()
call assert_true( &lines >= 25,
\ &lines . " is not enough rows. need 25." )
call assert_true( &columns >= 80,
\ &columns . " is not enough columns. need 80." )
endfunction
function! Test_Signatures_After_Trigger()
call youcompleteme#test#setup#OpenFile(
\ '/test/testdata/vim/mixed_filetype.vim',
\ { 'native_ft': 0, 'force_delay': v:true } )
call WaitFor( {-> s:_CheckSignatureHelpAvailable( 'vim' ) } )
call s:WaitForSigHelpAvailable( 'python' )
call setpos( '.', [ 0, 3, 17 ] )
" Required to trigger TextChangedI
" https://github.com/vim/vim/issues/4665#event-2480928194
call test_override( 'char_avail', 1 )
" Must do the checks in a timer callback because we need to stay in insert
" mode until done. Use a func because it's big enough (a lambda is a little
" neater in many contexts).
function! Check( id ) closure
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ 'ycm_state.SignatureHelpRequestReady()'
\ ),
\ 'sig help request ready'
\ )
\ } )
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ "bool( ycm_state.GetSignatureHelpResponse()[ 'signatures' ] )"
\ ),
\ 'sig help request has signatures'
\ )
\ } )
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ 'ycm_state._signature_help_state.popup_win_id is not None'
\ ),
\ 'popup_win_id'
\ )
\ } )
let popup_win_id = pyxeval( 'ycm_state._signature_help_state.popup_win_id' )
let pos = win_screenpos( popup_win_id )
call assert_false( pos == [ 0, 0 ] )
" Exit insert mode to ensure the test continues
call test_override( 'ALL', 0 )
call feedkeys( "\<ESC>" )
endfunction
call assert_false( pyxeval( 'ycm_state.SignatureHelpRequestReady()' ) )
call timer_start( s:timer_interval, funcref( 'Check' ) )
call feedkeys( 'cl(', 'ntx!' )
call assert_false( pumvisible(), 'pumvisible()' )
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ 'ycm_state._signature_help_state.popup_win_id is None'
\ ),
\ 'popup_win_id'
\ )
\ } )
call test_override( 'ALL', 0 )
delfunc! Check
endfunction
function! Test_Signatures_With_PUM_NoSigns()
call youcompleteme#test#setup#OpenFile(
\ '/third_party/ycmd/ycmd/tests/clangd/testdata/general_fallback'
\ . '/make_drink.cc', {} )
call s:WaitForSigHelpAvailable( 'cpp' )
" Make sure that error signs don't shift the window
setlocal signcolumn=no
call setpos( '.', [ 0, 7, 13 ] )
" Required to trigger TextChangedI
" https://github.com/vim/vim/issues/4665#event-2480928194
call test_override( 'char_avail', 1 )
function! Check2( id ) closure
call WaitForAssert( {-> assert_true( pumvisible() ) } )
call WaitForAssert( {-> assert_notequal( [], complete_info().items ) } )
call assert_equal( 7, pum_getpos().row )
redraw
" NOTE: anchor is 0-based
call assert_equal( 6,
\ pyxeval( 'ycm_state._signature_help_state.anchor[0]' ) )
call assert_equal( 13,
\ pyxeval( 'ycm_state._signature_help_state.anchor[1]' ) )
" Popup is shifted due to 80 column screen
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 5, 'col': 5 } )
call test_override( 'ALL', 0 )
call feedkeys( "\<ESC>", 't' )
endfunction
" Must do the checks in a timer callback because we need to stay in insert
" mode until done.
function! Check( id ) closure
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ 'ycm_state._signature_help_state.popup_win_id is not None'
\ ),
\ 'popup_win_id'
\ )
\ } )
" Popup is shifted left due to 80 char screen
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 5, 'col': 5 } )
call timer_start( s:timer_interval, funcref( 'Check2' ) )
call feedkeys( ' TypeOfD', 't' )
endfunction
call assert_false( pyxeval( 'ycm_state.SignatureHelpRequestReady()' ) )
call timer_start( s:timer_interval, funcref( 'Check' ) )
call feedkeys( 'C(', 'ntx!' )
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ 'ycm_state._signature_help_state.popup_win_id is None'
\ ),
\ 'popup_win_id'
\ )
\ } )
call test_override( 'ALL', 0 )
delfunc! Check
delfunc! Check2
endfunction
function! Test_Signatures_With_PUM_Signs()
call youcompleteme#test#setup#OpenFile(
\ '/third_party/ycmd/ycmd/tests/clangd/testdata/general_fallback'
\ . '/make_drink.cc', {} )
call s:WaitForSigHelpAvailable( 'cpp' )
" Make sure that sign causes the popup to shift
setlocal signcolumn=auto
call setpos( '.', [ 0, 7, 13 ] )
" Required to trigger TextChangedI
" https://github.com/vim/vim/issues/4665#event-2480928194
call test_override( 'char_avail', 1 )
function Check2( id ) closure
call WaitForAssert( {-> assert_true( pumvisible() ) } )
call WaitForAssert( {-> assert_notequal( [], complete_info().items ) } )
call assert_equal( 7, pum_getpos().row )
redraw
" NOTE: anchor is 0-based
call assert_equal( 6,
\ pyxeval( 'ycm_state._signature_help_state.anchor[0]' ) )
call assert_equal( 13,
\ pyxeval( 'ycm_state._signature_help_state.anchor[1]' ) )
" Sign column is shown, popup shifts to the right 2 screen columns
" Then shifts back due to 80 character screen width
" FIXME: This test was supposed to show the shifting right. Write another
" one which uses a much smaller popup to do that.
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 5, 'col': 5 } )
call test_override( 'ALL', 0 )
call feedkeys( "\<ESC>", 't' )
endfunction
" Must do the checks in a timer callback because we need to stay in insert
" mode until done.
function! Check( id ) closure
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ 'ycm_state._signature_help_state.popup_win_id is not None'
\ ),
\ 'popup_win_id'
\ )
\ } )
" Popup is shifted left due to 80 char screen
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 5, 'col': 5 } )
call timer_start( s:timer_interval, funcref( 'Check2' ) )
call feedkeys( ' TypeOfD', 't' )
endfunction
call assert_false( pyxeval( 'ycm_state.SignatureHelpRequestReady()' ) )
call timer_start( s:timer_interval, funcref( 'Check' ) )
call feedkeys( 'C(', 'ntx!' )
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ 'ycm_state._signature_help_state.popup_win_id is None'
\ ),
\ 'popup_win_id'
\ )
\ } )
call test_override( 'ALL', 0 )
delfunc! Check
delfunc! Check2
endfunction
function! Test_Placement_Simple()
call assert_true( &lines >= 25, "Enough rows" )
call assert_true( &columns >= 25, "Enough columns" )
let X = join( map( range( 0, &columns - 1 ), {->'X'} ), '' )
for i in range( 0, &lines )
call append( line('$'), X )
endfor
" Delete the blank line that is always added to a buffer
0delete
call s:_ClearSigHelp()
let v_sh = {
\ 'activeSignature': 0,
\ 'activeParameter': 0,
\ 'signatures': [
\ { 'label': 'test function', 'parameters': [] }
\ ]
\ }
" When displayed in the middle with plenty of space
call s:_CheckSigHelpAtPos( v_sh, [ 10, 3 ], {
\ 'line': 9,
\ 'col': 1
\ } )
" Confirm that anchoring works (i.e. it doesn't move!)
call s:_CheckSigHelpAtPos( v_sh, [ 20, 10 ], {
\ 'line': 9,
\ 'col': 1
\ } )
call s:_ClearSigHelp()
" Window slides from left of screen
call s:_CheckSigHelpAtPos( v_sh, [ 10, 2 ], {
\ 'line': 9,
\ 'col': 1,
\ } )
call s:_ClearSigHelp()
" Window slides from left of screen
call s:_CheckSigHelpAtPos( v_sh, [ 10, 1 ], {
\ 'line': 9,
\ 'col': 1,
\ } )
call s:_ClearSigHelp()
" Cursor at top-left of window
call s:_CheckSigHelpAtPos( v_sh, [ 1, 1 ], {
\ 'line': 2,
\ 'col': 1,
\ } )
call s:_ClearSigHelp()
" Cursor at top-right of window
call s:_CheckSigHelpAtPos( v_sh, [ 1, &columns ], {
\ 'line': 2,
\ 'col': &columns - len( "test function" ) - 1,
\ } )
call s:_ClearSigHelp()
" Bottom-left of window
call s:_CheckSigHelpAtPos( v_sh, [ &lines + 1, 1 ], {
\ 'line': &lines - 2,
\ 'col': 1,
\ } )
call s:_ClearSigHelp()
" Bottom-right of window
call s:_CheckSigHelpAtPos( v_sh, [ &lines + 1, &columns ], {
\ 'line': &lines - 2,
\ 'col': &columns - len( "test function" ) - 1,
\ } )
call s:_ClearSigHelp()
call popup_clear()
endfunction
function! Test_Placement_MultiLine()
call assert_true( &lines >= 25, "Enough rows" )
call assert_true( &columns >= 25, "Enough columns" )
let X = join( map( range( 0, &columns - 1 ), {->'X'} ), '' )
for i in range( 0, &lines )
call append( line('$'), X )
endfor
" Delete the blank line that is always added to a buffer
0delete
call s:_ClearSigHelp()
let v_sh = {
\ 'activeSignature': 0,
\ 'activeParameter': 0,
\ 'signatures': [
\ { 'label': 'test function', 'parameters': [] },
\ { 'label': 'toast function', 'parameters': [
\ { 'label': [ 0, 5 ] }
\ ] },
\ ]
\ }
" When displayed in the middle with plenty of space
call s:_CheckSigHelpAtPos( v_sh, [ 10, 3 ], {
\ 'line': 8,
\ 'col': 1
\ } )
" Confirm that anchoring works (i.e. it doesn't move!)
call s:_CheckSigHelpAtPos( v_sh, [ 20, 10 ], {
\ 'line': 8,
\ 'col': 1
\ } )
call s:_ClearSigHelp()
" Window slides from left of screen
call s:_CheckSigHelpAtPos( v_sh, [ 10, 2 ], {
\ 'line': 8,
\ 'col': 1,
\ } )
call s:_ClearSigHelp()
" Window slides from left of screen
call s:_CheckSigHelpAtPos( v_sh, [ 10, 1 ], {
\ 'line': 8,
\ 'col': 1,
\ } )
call s:_ClearSigHelp()
" Cursor at top-left of window
call s:_CheckSigHelpAtPos( v_sh, [ 1, 1 ], {
\ 'line': 2,
\ 'col': 1,
\ } )
call s:_ClearSigHelp()
" Cursor at top-right of window
call s:_CheckSigHelpAtPos( v_sh, [ 1, &columns ], {
\ 'line': 2,
\ 'col': &columns - len( "toast function" ) - 1,
\ } )
call s:_ClearSigHelp()
" Bottom-left of window
call s:_CheckSigHelpAtPos( v_sh, [ &lines + 1, 1 ], {
\ 'line': &lines - 3,
\ 'col': 1,
\ } )
call s:_ClearSigHelp()
" Bottom-right of window
call s:_CheckSigHelpAtPos( v_sh, [ &lines + 1, &columns ], {
\ 'line': &lines - 3,
\ 'col': &columns - len( "toast function" ) - 1,
\ } )
call s:_ClearSigHelp()
call popup_clear()
endfunction
function! Test_Signatures_TopLine()
call youcompleteme#test#setup#OpenFile( 'test/testdata/python/test.py', {} )
call s:WaitForSigHelpAvailable( 'python' )
call setpos( '.', [ 0, 1, 24 ] )
call test_override( 'char_avail', 1 )
function! Check( id ) closure
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 2, 'col': 23 } )
call test_override( 'ALL', 0 )
call feedkeys( "\<ESC>" )
endfunction
call timer_start( s:timer_interval, funcref( 'Check' ) )
call feedkeys( 'cl(', 'ntx!' )
call test_override( 'ALL', 0 )
delfun! Check
endfunction
function! Test_Signatures_TopLineWithPUM()
call youcompleteme#test#setup#OpenFile( 'test/testdata/python/test.py', {} )
call s:WaitForSigHelpAvailable( 'python' )
call setpos( '.', [ 0, 1, 24 ] )
call test_override( 'char_avail', 1 )
function! CheckSigHelpAndTriggerCompletion( id ) closure
" Popup placed below the cursor
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 2, 'col': 23 } )
" Push more characters into the typeahead buffer to trigger insert mode
" completion.
"
" Nte for some reason the first semantic response can take quite some time,
" and if our timer fires before then, the test just fails. so we take 2
" seconds here.
call timer_start( s:timer_interval,
\ funcref( 'CheckCompletionVisibleAndSigHelpHidden' ) )
call feedkeys( " os.", 't' )
endfunction
function! CheckCompletionVisibleAndSigHelpHidden( id ) closure
" Completion popup now visible, overlapping where the sig help popup was
redraw
call WaitForAssert( {-> assert_true( pumvisible() ) } )
call assert_equal( 1, get( pum_getpos(), 'row', -1 ) )
call assert_equal( 28, get( pum_getpos(), 'col', -1 ) )
" so we hide the sig help popup.
call WaitForAssert( {->
\ assert_true(
\ pyxeval(
\ 'ycm_state._signature_help_state.popup_win_id is None'
\ ),
\ 'popup_win_id'
\ )
\ } )
call youcompleteme#test#popup#CheckPopupPosition( s:popup_win_id, {} )
" We're done in insert mode now.
call test_override( 'ALL', 0 )
call feedkeys( "\<ESC>", 't' )
endfunction
" Edit the line and trigger signature help
call timer_start( s:timer_interval,
\ funcref( 'CheckSigHelpAndTriggerCompletion' ) )
call feedkeys( 'C(', 'ntx!' )
call test_override( 'ALL', 0 )
delfunc! CheckSigHelpAndTriggerCompletion
delfunc! CheckCompletionVisibleAndSigHelpHidden
endfunction
function! SetUp_Test_Semantic_Completion_Popup_With_Sig_Help()
set signcolumn=no
call youcompleteme#test#setup#PushGlobal( 'ycm_add_preview_to_completeopt',
\ 'popup' )
endfunction
function! Test_Semantic_Completion_Popup_With_Sig_Help()
call youcompleteme#test#setup#OpenFile(
\ 'test/testdata/cpp/complete_with_sig_help.cc', {} )
call s:WaitForSigHelpAvailable( 'cpp' )
call setpos( '.', [ 0, 10, 1 ] )
" Required to trigger TextChangedI
" https://github.com/vim/vim/issues/4665#event-2480928194
call test_override( 'char_avail', 1 )
function! Check( ... )
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 9, 'col': 6, 'visible': 1 } )
call FeedAndCheckAgain( '"", t.', funcref( 'Check2' ) )
endfunction
function! Check2( ... )
call WaitForCompletion()
call CheckCompletionItems( [ 'that_is_a_thing', 'this_is_a_thing' ] )
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 9, 'col': 6, 'visible': 1 } )
call CheckCurrentLine( 'printf("", t.' )
call FeedAndCheckAgain( "\<Tab>", funcref( 'Check3' ) )
endfunction
function! Check3( ... )
" Ensure that we didn't make an error?
call WaitForCompletion()
call CheckCompletionItems( [ 'that_is_a_thing', 'this_is_a_thing' ] )
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 9, 'col': 6, 'visible': 1 } )
let compl = complete_info()
let selected = compl.items[ compl.selected ]
call assert_equal( 'that_is_a_thing', selected.word )
call WaitFor( {->
\ popup_findinfo() > 0 &&
\ has_key( popup_getpos( popup_findinfo() ), 'visible' ) } )
let info_popup_id = popup_findinfo()
call assert_true( popup_getpos( info_popup_id )[ 'visible' ] )
call CheckCurrentLine( 'printf("", t.that_is_a_thing' )
call FeedAndCheckAgain( "\<Tab>", funcref( 'Check4' ) )
endfunction
function! Check4( ... )
" Ensure that we didn't make an error?
call WaitForCompletion()
call CheckCompletionItems( [ 'that_is_a_thing', 'this_is_a_thing' ] )
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 9, 'col': 6, 'visible': 1 } )
let info_popup_id = popup_findinfo()
let compl = complete_info()
let selected = compl.items[ compl.selected ]
call assert_equal( 'this_is_a_thing', selected.word )
call assert_true( popup_getpos( info_popup_id )[ 'visible' ] )
call CheckCurrentLine( 'printf("", t.this_is_a_thing' )
call feedkeys( "\<Esc>" )
endfunction
call FeedAndCheckMain( 'iprintf(', funcref( 'Check' ) )
call test_override( 'ALL', 0 )
delfunc! Check
delfunc! Check2
delfunc! Check3
delfunc! Check4
endfunction
function! TearDown_Test_Semantic_Completion_Popup_With_Sig_Help()
set signcolumn&
call youcompleteme#test#setup#PopGlobal( 'ycm_add_preview_to_completeopt' )
endfunction
function! SetUp_Test_Semantic_Completion_Popup_With_Sig_Help_EmptyBuf()
set signcolumn=no
call youcompleteme#test#setup#PushGlobal( 'ycm_filetype_whitelist', {
\ '*': 1,
\ 'ycm_nofiletype': 1
\ } )
call youcompleteme#test#setup#PushGlobal( 'ycm_filetype_blacklist', {} )
call youcompleteme#test#setup#PushGlobal( 'ycm_add_preview_to_completeopt',
\ 'popup' )
endfunction
function! Test_Semantic_Completion_Popup_With_Sig_Help_EmptyBuf()
call youcompleteme#test#setup#OpenFile(
\ 'test/testdata/cpp/complete_with_sig_help.cc', {} )
call s:WaitForSigHelpAvailable( 'cpp' )
call setpos( '.', [ 0, 10, 1 ] )
" Required to trigger TextChangedI
" https://github.com/vim/vim/issues/4665#event-2480928194
call test_override( 'char_avail', 1 )
function! Check( ... )
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 9, 'col': 6, 'visible': 1 } )
call FeedAndCheckAgain( '"", t.', funcref( 'Check2' ) )
endfunction
function! Check2( ... )
call WaitForCompletion()
call CheckCompletionItems( [ 'that_is_a_thing', 'this_is_a_thing' ] )
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 9, 'col': 6, 'visible': 1 } )
call CheckCurrentLine( 'printf("", t.' )
call FeedAndCheckAgain( "\<Tab>", funcref( 'Check3' ) )
endfunction
function! Check3( ... )
" Ensure that we didn't make an error?
call WaitForCompletion()
call CheckCompletionItems( [ 'that_is_a_thing', 'this_is_a_thing' ] )
" XFAIL: Currently the test fails here because the signature help popup
" disappears when the info_popup is displayed. This seems to be because we
" end up triggering a FileReadyToParse event inside the info popup (or the
" signature popup) due to what appears to be a vim bug - the `buftype` of
" the buffer inside the popup starts off as `popup` but shimers to `""` at
" some point, making us think it's ok to parse it with ycm_nofiletype is
" whitelisted.
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 9, 'col': 6, 'visible': 1 } )
let compl = complete_info()
let selected = compl.items[ compl.selected ]
call assert_equal( 'that_is_a_thing', selected.word )
call WaitFor( {->
\ popup_findinfo() > 0 &&
\ has_key( popup_getpos( popup_findinfo() ), 'visible' ) } )
let info_popup_id = popup_findinfo()
call assert_true( popup_getpos( info_popup_id )[ 'visible' ] )
call CheckCurrentLine( 'printf("", t.that_is_a_thing' )
call FeedAndCheckAgain( "\<Tab>", funcref( 'Check4' ) )
endfunction
function! Check4( ... )
" Ensure that we didn't make an error?
call WaitForCompletion()
call CheckCompletionItems( [ 'that_is_a_thing', 'this_is_a_thing' ] )
call youcompleteme#test#popup#CheckPopupPosition(
\ s:_GetSigHelpWinID(),
\ { 'line': 9, 'col': 6, 'visible': 1 } )
let info_popup_id = popup_findinfo()
let compl = complete_info()
let selected = compl.items[ compl.selected ]
call assert_equal( 'this_is_a_thing', selected.word )
call assert_true( popup_getpos( info_popup_id )[ 'visible' ] )
call CheckCurrentLine( 'printf("", t.this_is_a_thing' )
call feedkeys( "\<Esc>" )
endfunction
call FeedAndCheckMain( 'iprintf(', funcref( 'Check' ) )
call test_override( 'ALL', 0 )
delfunc! Check
delfunc! Check2
delfunc! Check3
delfunc! Check4
throw 'SKIPPED: XFAIL: This test is expected to fail due to '
\ .. 'https://github.com/ycm-core/YouCompleteMe/issues/3781'
endfunction
function! TearDown_Test_Semantic_Completion_Popup_With_Sig_Help_EmptyBuf()
set signcolumn&
call youcompleteme#test#setup#PopGlobal( 'ycm_filetype_whitelist' )
call youcompleteme#test#setup#PopGlobal( 'ycm_filetype_blacklist' )
call youcompleteme#test#setup#PopGlobal( 'ycm_add_preview_to_completeopt' )
endfunction
|