diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 2528f89b..5521f940 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -96,7 +96,7 @@ endfunction function! s:AddIdentifierIfNeeded() py vim.command( "let should_add_identifier = '" + - \ str( ycm.ShouldAddIdentifier() ) + "'" ) + \ str( int( ycm.ShouldAddIdentifier() ) ) + "'" ) if should_add_identifier != 1 return endif diff --git a/python/ycm.py b/python/ycm.py index c379abfe..dc075dd2 100644 --- a/python/ycm.py +++ b/python/ycm.py @@ -174,26 +174,22 @@ def ShouldAddIdentifier(): current_column = CurrentColumn() previous_char_index = current_column - 1 if previous_char_index < 0: - return 1 - + return True line = vim.current.line try: previous_char = line[ previous_char_index ] except IndexError: - return 0 + return False if IsIdentifierChar( previous_char ): - return 0 + return False if ( not IsIdentifierChar( previous_char ) and previous_char_index > 0 and IsIdentifierChar( line[ previous_char_index - 1 ] ) ): - return 1 + return True else: - if line[ : current_column ].strip(): - return 0 - else: - return 1 + return line[ : current_column ].isspace() def SanitizeQuery( query ):