Skip to content

Commit

Permalink
Add test with omnifunc moving cursor position
Browse files Browse the repository at this point in the history
  • Loading branch information
micbou committed Jul 7, 2017
1 parent 83bb78a commit dec9c0f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions python/ycm/tests/omni_completer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
MockVimModule, ToBytesOnPY2, VimBuffer )
MockVimModule()

from ycm import vimsupport
from ycm.tests import YouCompleteMeInstance


Expand Down Expand Up @@ -621,3 +622,39 @@ def Omnifunc( findstart, base ):
'completion_start_column': 13
} )
)


@YouCompleteMeInstance( { 'cache_omnifunc': 1 } )
def OmniCompleter_GetCompletions_RestoreCursorPositionAfterOmnifuncCall_test(
ycm ):

# This omnifunc moves the cursor to the test definition like
# ccomplete#Complete would.
def Omnifunc( findstart, base ):
if findstart:
return 5
vimsupport.SetCurrentLineAndColumn( 0, 0 )
return [ 'length' ]

current_buffer = VimBuffer( 'buffer',
contents = [ 'String test',
'',
'test.' ],
filetype = 'java',
omnifunc = Omnifunc )

with MockVimBuffers( [ current_buffer ], current_buffer, ( 3, 5 ) ):
# Make sure there is an omnifunc set up.
ycm.OnFileReadyToParse()
ycm.SendCompletionRequest()
assert_that(
vimsupport.CurrentLineAndColumn(),
contains( 2, 5 )
)
assert_that(
ycm.GetCompletionResponse(),
has_entries( {
'completions': ToBytesOnPY2( [ 'length' ] ),
'completion_start_column': 6
} )
)

0 comments on commit dec9c0f

Please sign in to comment.