Skip to content

Commit

Permalink
Merge pull request #4208 from bstaletic/id_semantic_switch_mess
Browse files Browse the repository at this point in the history
Make switching to semantic completer work after select ID completer candidate
  • Loading branch information
mergify[bot] authored Dec 30, 2023
2 parents ad9fe2e + 430ae85 commit 71166ea
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions autoload/youcompleteme.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ function! s:RequestSemanticCompletion() abort

if get( b:, 'ycm_completing' )
let s:force_semantic = 1
let s:current_cursor_position = getpos( '.' )
call s:StopPoller( s:pollers.completion )
py3 ycm_state.SendCompletionRequest( True )

Expand Down
44 changes: 44 additions & 0 deletions test/completion_info.test.vim
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,47 @@ function! Test_DontResolveCompletion_AlreadyResolved()

call test_override( 'ALL', 0 )
endfunction

function! Test_SwitchingToSemanticCompletionAfterSelectingIdentifierCandidate()
call youcompleteme#test#setup#OpenFile( '/test/testdata/cpp/identifier_semantic_switch.cpp', {} )
call setpos( '.', [ 0, 3, 0 ] )
call test_override( 'char_avail', 1 )

function! Check1( id )
call WaitForCompletion()
call CheckCompletionItemsContainsExactly( [ 'ZbCdE' ], 'word' )
let compl = complete_info()
call assert_equal( -1, compl.selected )
call assert_equal( 1, len( compl.items ) )
let ZbCdE = compl.items[ 0 ]
call assert_equal( 'ZbCdE', ZbCdE.word )
call assert_equal( '[ID]', ZbCdE.menu )
call assert_equal( '', ZbCdE.kind )
call FeedAndCheckAgain( "\<Tab>", funcref( 'Check2' ) )
endfunction

function! Check2( id )
call WaitForCompletion()
call assert_match( 'ZbCdE', getline( '.' ) )
call FeedAndCheckAgain( "\<C-Space>", funcref( 'Check3' ) )
endfunction

function! Check3( id )
call WaitForCompletion()
call CheckCompletionItemsContainsExactly( [ 'ZbCdE' ], 'word' )
let compl = complete_info()
call assert_equal( -1, compl.selected )
call assert_match( 'ZbCdE', getline( '.' ) )
call assert_equal( 1, len( compl.items ) )
let ZbCdE = compl.items[ 0 ]
call assert_equal( 'ZbCdE', ZbCdE.word )
call assert_equal( 'void', ZbCdE.menu )
call assert_equal( 'f', ZbCdE.kind )
call feedkeys( "\<Esc>" )
endfunction


call FeedAndCheckMain( 'ZCE', funcref( 'Check1' ) )
call assert_false( pumvisible(), 'pumvisible()' )
call test_override( 'ALL', 0 )
endfunction

0 comments on commit 71166ea

Please sign in to comment.