From 96b28b93a144aa7c4fad4d3ea75fe685ccebf693 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sun, 5 Jan 2014 12:16:53 -0800 Subject: [PATCH] Optimizing overlap correction for common case Most of the time there's nothing after the cursor. --- python/ycm/base.py | 2 ++ python/ycm/tests/base_test.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/python/ycm/base.py b/python/ycm/base.py index 05314dd5..2e172d98 100644 --- a/python/ycm/base.py +++ b/python/ycm/base.py @@ -131,6 +131,8 @@ def AdjustCandidateInsertionText( candidates ): new_candidates = [] text_after_cursor = vimsupport.TextAfterCursor() + if not text_after_cursor: + return candidates for candidate in candidates: if type( candidate ) is dict: new_candidate = candidate.copy() diff --git a/python/ycm/tests/base_test.py b/python/ycm/tests/base_test.py index f022486a..bebc930f 100644 --- a/python/ycm/tests/base_test.py +++ b/python/ycm/tests/base_test.py @@ -67,8 +67,8 @@ def AdjustCandidateInsertionText_NotSuffix_test(): def AdjustCandidateInsertionText_NothingAfterCursor_test(): vimsupport.TextAfterCursor = MagicMock( return_value = '' ) - eq_( [ { 'abbr': 'foofoo', 'word': 'foofoo' }, - { 'abbr': 'zobar', 'word': 'zobar' }, ], + eq_( [ 'foofoo', + 'zobar' ], base.AdjustCandidateInsertionText( [ 'foofoo', 'zobar' ] ) )