Optimizing overlap correction for common case

Most of the time there's nothing after the cursor.
This commit is contained in:
Strahinja Val Markovic 2014-01-05 12:16:53 -08:00
parent a18807d31e
commit 96b28b93a1
2 changed files with 4 additions and 2 deletions

View File

@ -131,6 +131,8 @@ def AdjustCandidateInsertionText( candidates ):
new_candidates = [] new_candidates = []
text_after_cursor = vimsupport.TextAfterCursor() text_after_cursor = vimsupport.TextAfterCursor()
if not text_after_cursor:
return candidates
for candidate in candidates: for candidate in candidates:
if type( candidate ) is dict: if type( candidate ) is dict:
new_candidate = candidate.copy() new_candidate = candidate.copy()

View File

@ -67,8 +67,8 @@ def AdjustCandidateInsertionText_NotSuffix_test():
def AdjustCandidateInsertionText_NothingAfterCursor_test(): def AdjustCandidateInsertionText_NothingAfterCursor_test():
vimsupport.TextAfterCursor = MagicMock( return_value = '' ) vimsupport.TextAfterCursor = MagicMock( return_value = '' )
eq_( [ { 'abbr': 'foofoo', 'word': 'foofoo' }, eq_( [ 'foofoo',
{ 'abbr': 'zobar', 'word': 'zobar' }, ], 'zobar' ],
base.AdjustCandidateInsertionText( [ 'foofoo', base.AdjustCandidateInsertionText( [ 'foofoo',
'zobar' ] ) ) 'zobar' ] ) )