瀏覽代碼

Optimizing overlap correction for common case

Most of the time there's nothing after the cursor.
Strahinja Val Markovic 11 年之前
父節點
當前提交
96b28b93a1
共有 2 個文件被更改,包括 4 次插入2 次删除
  1. 2 0
      python/ycm/base.py
  2. 2 2
      python/ycm/tests/base_test.py

+ 2 - 0
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()

+ 2 - 2
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' ] ) )