From 02a1f8780c1163465a7143b188c8ee05227b0550 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sat, 12 May 2012 20:42:45 -0700 Subject: [PATCH] Small refactoring of the ShouldAddIdentifier func --- autoload/youcompleteme.vim | 2 +- python/ycm.py | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) 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 ):