123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894 |
- 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 CheckCompletionItemsContainsExactly( [ '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 CheckCompletionItemsContainsExactly( [ '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 CheckCompletionItemsContainsExactly( [ '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 CheckCompletionItemsContainsExactly( [ '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 CheckCompletionItemsContainsExactly( [ '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 CheckCompletionItemsContainsExactly( [ '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
- function! SetUp_Test_Signature_Help_Manual_HideShow()
- imap <silent> kjkj <Plug>(YCMToggleSignatureHelp)
- endfunction
- function! Test_Signature_Help_Manual_HideShow()
- call youcompleteme#test#setup#OpenFile(
- \ 'test/testdata/cpp/complete_with_sig_help.cc', {} )
- call s:WaitForSigHelpAvailable( 'cpp' )
- call setpos( '.', [ 0, 10, 1 ] )
- call test_override( 'char_avail', 1 )
- function! Check( ... )
- call youcompleteme#test#popup#CheckPopupPosition(
- \ s:_GetSigHelpWinID(),
- \ { 'line': 9, 'col': 8, 'visible': 1 } )
- call FeedAndCheckAgain( 'kjkj', funcref( 'Check2' ) )
- endfunction
- function! Check2( ... )
- call youcompleteme#test#popup#CheckPopupPosition(
- \ s:_GetSigHelpWinID(),
- \ { 'line': 9, 'col': 8, 'visible': 0 } )
- call FeedAndCheckAgain( 'kjkj', funcref( 'Check3' ) )
- endfunction
- function! Check3( ... )
- call youcompleteme#test#popup#CheckPopupPosition(
- \ s:_GetSigHelpWinID(),
- \ { 'line': 9, 'col': 8, 'visible': 1 } )
- call feedkeys( "\<Esc>" )
- endfunction
- call FeedAndCheckMain( 'iprintf(', funcref( 'Check' ) )
- call test_override( 'ALL', 0 )
- delfunc! Check
- delfunc! Check2
- delfunc! Check3
- endfunction
- function! TearDown_Test_Signature_Help_Manual_HideShow()
- silent! iunmap kjkj
- endfunction
- function! SetUp_Test_Signature_Help_Manual_NoSigs()
- imap <silent> kjkj <Plug>(YCMToggleSignatureHelp)
- endfunction
- function! Test_Signature_Help_Manual_NoSigs()
- call youcompleteme#test#setup#OpenFile(
- \ 'test/testdata/cpp/complete_with_sig_help.cc', {} )
- call s:WaitForSigHelpAvailable( 'cpp' )
- call setpos( '.', [ 0, 10, 1 ] )
- call test_override( 'char_avail', 1 )
- let popup_id = 0
- function! CheckSigs( ... ) closure
- let popup_id = s:_GetSigHelpWinID()
- call youcompleteme#test#popup#CheckPopupPosition(
- \ s:_GetSigHelpWinID(),
- \ { 'line': 9, 'col': 8, 'visible': 1 } )
- call FeedAndCheckAgain( ')', funcref( 'CheckSigsClosed' ) )
- endfunction
- function! CheckSigsClosed( ... ) closure
- call youcompleteme#test#popup#CheckPopupPosition(
- \ popup_id,
- \ {} )
- call FeedAndCheckAgain( 'kjkj', funcref( 'CheckStillOK' ) )
- endfunction
- function! CheckStillOK( ... ) closure
- call youcompleteme#test#popup#CheckPopupPosition(
- \ popup_id,
- \ {} )
- call feedkeys( "\<Esc>" )
- endfunction
- call FeedAndCheckMain( 'iprintf(', funcref( 'CheckSigs' ) )
- call test_override( 'ALL', 0 )
- delfunc! CheckSigs
- delfunc! CheckSigsClosed
- delfunc! CheckStillOK
- endfunction
- function! TearDown_Test_Signature_Help_Manual_NoSigs()
- silent! iunmap kjkj
- endfunction
|