ShouldUseNow for IdentifierCompleter done and used

This commit is contained in:
Strahinja Val Markovic 2012-08-05 13:12:10 -07:00
parent df260ed2a8
commit ea30cb046e
3 changed files with 14 additions and 19 deletions

View File

@ -205,12 +205,6 @@ endfunction
function! s:CompletionsForQuery( query, use_filetype_completer )
" TODO: needed?
if !a:use_filetype_completer &&
\ strlen( a:query ) < g:ycm_min_num_of_chars_for_completion
return []
endif
if a:use_filetype_completer
py completer = ycm_state.GetFiletypeCompleterForCurrentFile()
else
@ -250,16 +244,12 @@ function! youcompleteme#Complete( findstart, base )
\ pyeval( 'ycm_state.ShouldUseFiletypeCompleter(' .
\ s:completion_start_column . ')' )
" TODO: use ShouldUseIdentifierCompleter() which checks query length
if ( !s:should_use_filetype_completion )
let l:current_column = col('.') - 1
let l:query_length = current_column - s:completion_start_column
if ( query_length < g:ycm_min_num_of_chars_for_completion )
" for vim, -2 means not found but don't trigger an error message
" see :h complete-functions
return -2
endif
if !s:should_use_filetype_completion &&
\ !pyeval( 'ycm_state.ShouldUseIdentifierCompleter(' .
\ s:completion_start_column . ')' )
" for vim, -2 means not found but don't trigger an error message
" see :h complete-functions
return -2
endif
return s:completion_start_column
else

View File

@ -24,7 +24,8 @@ import ycm_core
import utils
MAX_IDENTIFIER_COMPLETIONS_RETURNED = 10
MIN_NUM_CHARS = int( vim.eval( "g:ycm_min_num_of_chars_for_completion" ) )
MIN_NUM_CHARS = int( vimsupport.GetVariableValue(
"g:ycm_min_num_of_chars_for_completion" ) )
def GetCompleter():
@ -42,9 +43,9 @@ class IdentifierCompleter( Completer ):
return set( [ 'ycm_all' ] )
# TODO: implement this
def ShouldUseNow( self, start_column ):
return True
query_length = vimsupport.CurrentColumn() - start_column
return query_length >= MIN_NUM_CHARS
def CandidatesForQueryAsync( self, query ):

View File

@ -64,3 +64,7 @@ def EscapeForVim( text ):
def CurrentFiletype():
return vim.eval( "&filetype" )
def GetVariableValue( variable ):
return vim.eval( variable )