Disable Vim filtering

Disable Vim filtering by setting the 'equal' field of completions to 1.
This should speed up completion and reduce flickering.
This commit is contained in:
micbou 2019-04-08 13:38:03 +02:00
parent 151fa5765a
commit 93fd392ea2
No known key found for this signature in database
GPG Key ID: C7E8FD1F3BDA1E05
5 changed files with 121 additions and 92 deletions

View File

@ -1,4 +1,4 @@
# Copyright (C) 2013-2018 YouCompleteMe contributors # Copyright (C) 2013-2019 YouCompleteMe contributors
# #
# This file is part of YouCompleteMe. # This file is part of YouCompleteMe.
# #
@ -201,6 +201,8 @@ def _ConvertCompletionDataToVimData( completion_identifier, completion_data ):
'menu' : completion_data.get( 'extra_menu_info', '' ), 'menu' : completion_data.get( 'extra_menu_info', '' ),
'info' : _GetCompletionInfoField( completion_data ), 'info' : _GetCompletionInfoField( completion_data ),
'kind' : ToUnicode( completion_data.get( 'kind', '' ) )[ :1 ].lower(), 'kind' : ToUnicode( completion_data.get( 'kind', '' ) )[ :1 ].lower(),
# Disable Vim filtering.
'equal' : 1,
'dup' : 1, 'dup' : 1,
'empty' : 1, 'empty' : 1,
# We store the completion item index as a string in the completion # We store the completion item index as a string in the completion

View File

@ -1,4 +1,4 @@
# Copyright (C) 2011, 2012, 2013 Google Inc. # Copyright (C) 2011-2019 ycmd contributors
# #
# This file is part of YouCompleteMe. # This file is part of YouCompleteMe.
# #
@ -127,8 +127,14 @@ class OmniCompleter( Completer ):
# but ycmd only supports lists where items are all strings or all # but ycmd only supports lists where items are all strings or all
# dictionaries. Convert all strings into dictionaries. # dictionaries. Convert all strings into dictionaries.
for index, item in enumerate( items ): for index, item in enumerate( items ):
# Set the 'equal' field to 1 to disable Vim filtering.
if not isinstance( item, dict ): if not isinstance( item, dict ):
items[ index ] = { 'word': item } items[ index ] = {
'word': item,
'equal': 1
}
else:
item[ 'equal' ] = 1
return items return items

View File

@ -1,4 +1,4 @@
# Copyright (C) 2015-2016 YouCompleteMe Contributors # Copyright (C) 2015-2019 YouCompleteMe Contributors
# #
# This file is part of YouCompleteMe. # This file is part of YouCompleteMe.
# #
@ -41,7 +41,7 @@ class ConvertCompletionResponseToVimDatas_test( object ):
try: try:
eq_( expected_vim_data, vim_data ) eq_( expected_vim_data, vim_data )
except Exception: except Exception:
print( "Expected:\n'{0}'\nwhen parsing:\n'{1}'\nBut found:\n'{2}'".format( print( "Expected:\n'{}'\nwhen parsing:\n'{}'\nBut found:\n'{}'".format(
expected_vim_data, expected_vim_data,
completion_data, completion_data,
vim_data ) ) vim_data ) )
@ -64,6 +64,7 @@ class ConvertCompletionResponseToVimDatas_test( object ):
'menu' : 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind' : 'k', 'kind' : 'k',
'info' : 'DETAILED INFO\nDOC STRING', 'info' : 'DETAILED INFO\nDOC STRING',
'equal' : 1,
'dup' : 1, 'dup' : 1,
'empty' : 1, 'empty' : 1,
'user_data': '0', 'user_data': '0',
@ -79,6 +80,7 @@ class ConvertCompletionResponseToVimDatas_test( object ):
'menu' : '', 'menu' : '',
'kind' : '', 'kind' : '',
'info' : '', 'info' : '',
'equal' : 1,
'dup' : 1, 'dup' : 1,
'empty' : 1, 'empty' : 1,
'user_data': '17', 'user_data': '17',
@ -98,6 +100,7 @@ class ConvertCompletionResponseToVimDatas_test( object ):
'menu' : 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind' : 'k', 'kind' : 'k',
'info' : 'DETAILED INFO', 'info' : 'DETAILED INFO',
'equal' : 1,
'dup' : 1, 'dup' : 1,
'empty' : 1, 'empty' : 1,
'user_data': '9999999999', 'user_data': '9999999999',
@ -119,6 +122,7 @@ class ConvertCompletionResponseToVimDatas_test( object ):
'menu' : 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind' : 'k', 'kind' : 'k',
'info' : 'DOC STRING', 'info' : 'DOC STRING',
'equal' : 1,
'dup' : 1, 'dup' : 1,
'empty' : 1, 'empty' : 1,
'user_data': 'not_an_int', 'user_data': 'not_an_int',
@ -139,6 +143,7 @@ class ConvertCompletionResponseToVimDatas_test( object ):
'menu' : 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind' : 'k', 'kind' : 'k',
'info' : '', 'info' : '',
'equal' : 1,
'dup' : 1, 'dup' : 1,
'empty' : 1, 'empty' : 1,
'user_data': '0', 'user_data': '0',
@ -161,6 +166,7 @@ class ConvertCompletionResponseToVimDatas_test( object ):
'menu' : 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind' : 'k', 'kind' : 'k',
'info' : 'DETAILEDINFO\nDOCSTRING', 'info' : 'DETAILEDINFO\nDOCSTRING',
'equal' : 1,
'dup' : 1, 'dup' : 1,
'empty' : 1, 'empty' : 1,
'user_data': '0', 'user_data': '0',
@ -182,6 +188,7 @@ class ConvertCompletionResponseToVimDatas_test( object ):
'menu' : 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind' : 'k', 'kind' : 'k',
'info' : 'DETAILED INFO', 'info' : 'DETAILED INFO',
'equal' : 1,
'dup' : 1, 'dup' : 1,
'empty' : 1, 'empty' : 1,
'user_data': '0', 'user_data': '0',
@ -204,6 +211,7 @@ class ConvertCompletionResponseToVimDatas_test( object ):
'menu' : 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind' : 'k', 'kind' : 'k',
'info' : 'DETAILED INFO\nDOC STRING', 'info' : 'DETAILED INFO\nDOC STRING',
'equal' : 1,
'dup' : 1, 'dup' : 1,
'empty' : 1, 'empty' : 1,
'user_data': '0', 'user_data': '0',

View File

@ -1,6 +1,6 @@
# encoding: utf-8 # encoding: utf-8
# #
# Copyright (C) 2016-2018 YouCompleteMe contributors # Copyright (C) 2016-2019 YouCompleteMe contributors
# #
# This file is part of YouCompleteMe. # This file is part of YouCompleteMe.
# #
@ -58,9 +58,9 @@ def OmniCompleter_GetCompletions_Cache_List_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ 'completions': ToBytesOnPY2( [
{ 'word': 'a' }, { 'word': 'a', 'equal': 1 },
{ 'word': 'b' }, { 'word': 'b', 'equal': 1 },
{ 'word': 'cdef' } { 'word': 'cdef', 'equal': 1 }
] ), ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
@ -110,9 +110,9 @@ def OmniCompleter_GetCompletions_NoCache_List_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ 'completions': ToBytesOnPY2( [
{ 'word': 'a' }, { 'word': 'a', 'equal': 1 },
{ 'word': 'b' }, { 'word': 'b', 'equal': 1 },
{ 'word': 'cdef' } { 'word': 'cdef', 'equal': 1 }
] ), ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
@ -140,9 +140,9 @@ def OmniCompleter_GetCompletions_NoCache_ListFilter_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ 'completions': ToBytesOnPY2( [
{ 'word': 'a' }, { 'word': 'a', 'equal': 1 },
{ 'word': 'b' }, { 'word': 'b', 'equal': 1 },
{ 'word': 'cdef' } { 'word': 'cdef', 'equal': 1 }
] ), ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
@ -170,9 +170,9 @@ def OmniCompleter_GetCompletions_NoCache_UseFindStart_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ 'completions': ToBytesOnPY2( [
{ 'word': 'a' }, { 'word': 'a', 'equal': 1 },
{ 'word': 'b' }, { 'word': 'b', 'equal': 1 },
{ 'word': 'cdef' } { 'word': 'cdef', 'equal': 1 }
] ), ] ),
'completion_start_column': 1 'completion_start_column': 1
} ) } )
@ -223,7 +223,7 @@ def OmniCompleter_GetCompletions_Cache_Object_test( ycm ):
assert_that( assert_that(
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': [ { 'word': 'CDtEF' } ], 'completions': [ { 'word': 'CDtEF', 'equal': 1 } ],
'completion_start_column': 6 'completion_start_column': 6
} ) } )
) )
@ -263,11 +263,12 @@ def OmniCompleter_GetCompletions_Cache_ObjectList_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': contains( { 'completions': contains( {
'word': 'test', 'word' : 'test',
'abbr': 'ABBRTEST', 'abbr' : 'ABBRTEST',
'menu': 'MENUTEST', 'menu' : 'MENUTEST',
'info': 'INFOTEST', 'info' : 'INFOTEST',
'kind': 'T' 'kind' : 'T',
'equal': 1
} ), } ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
@ -310,17 +311,19 @@ def OmniCompleter_GetCompletions_NoCache_ObjectList_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ { 'completions': ToBytesOnPY2( [ {
'word': 'a', 'word' : 'a',
'abbr': 'ABBR', 'abbr' : 'ABBR',
'menu': 'MENU', 'menu' : 'MENU',
'info': 'INFO', 'info' : 'INFO',
'kind': 'K' 'kind' : 'K',
'equal': 1
}, { }, {
'word': 'test', 'word' : 'test',
'abbr': 'ABBRTEST', 'abbr' : 'ABBRTEST',
'menu': 'MENUTEST', 'menu' : 'MENUTEST',
'info': 'INFOTEST', 'info' : 'INFOTEST',
'kind': 'T' 'kind' : 'T',
'equal': 1
} ] ), } ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
@ -361,11 +364,12 @@ def OmniCompleter_GetCompletions_Cache_ObjectListObject_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ { 'completions': ToBytesOnPY2( [ {
'word': 'test', 'word' : 'test',
'abbr': 'ABBRTEST', 'abbr' : 'ABBRTEST',
'menu': 'MENUTEST', 'menu' : 'MENUTEST',
'info': 'INFOTEST', 'info' : 'INFOTEST',
'kind': 'T' 'kind' : 'T',
'equal': 1
} ] ), } ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
@ -408,17 +412,19 @@ def OmniCompleter_GetCompletions_NoCache_ObjectListObject_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ { 'completions': ToBytesOnPY2( [ {
'word': 'a', 'word' : 'a',
'abbr': 'ABBR', 'abbr' : 'ABBR',
'menu': 'MENU', 'menu' : 'MENU',
'info': 'INFO', 'info' : 'INFO',
'kind': 'K' 'kind' : 'K',
'equal': 1
}, { }, {
'word': 'test', 'word' : 'test',
'abbr': 'ABBRTEST', 'abbr' : 'ABBRTEST',
'menu': 'MENUTEST', 'menu' : 'MENUTEST',
'info': 'INFOTEST', 'info' : 'INFOTEST',
'kind': 'T' 'kind' : 'T',
'equal': 1
} ] ), } ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
@ -444,9 +450,9 @@ def OmniCompleter_GetCompletions_Cache_List_Unicode_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': [ 'completions': [
{ 'word': 'å_unicode_identifier' }, { 'word': 'å_unicode_identifier', 'equal': 1 },
{ 'word': 'πππππππ yummy πie' }, { 'word': 'πππππππ yummy πie', 'equal': 1 },
{ 'word': '†est' } { 'word': '†est', 'equal': 1 }
], ],
'completion_start_column': 13 'completion_start_column': 13
} ) } )
@ -472,9 +478,9 @@ def OmniCompleter_GetCompletions_NoCache_List_Unicode_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ 'completions': ToBytesOnPY2( [
{ 'word': '†est' }, { 'word': '†est', 'equal': 1 },
{ 'word': 'å_unicode_identifier' }, { 'word': 'å_unicode_identifier', 'equal': 1 },
{ 'word': 'πππππππ yummy πie' } { 'word': 'πππππππ yummy πie', 'equal': 1 }
] ), ] ),
'completion_start_column': 13 'completion_start_column': 13
} ) } )
@ -499,7 +505,7 @@ def OmniCompleter_GetCompletions_Cache_List_Filter_Unicode_test( ycm ):
assert_that( assert_that(
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': [ { 'word': 'πππππππ yummy πie' } ], 'completions': [ { 'word': 'πππππππ yummy πie', 'equal': 1 } ],
'completion_start_column': 13 'completion_start_column': 13
} ) } )
) )
@ -523,7 +529,9 @@ def OmniCompleter_GetCompletions_NoCache_List_Filter_Unicode_test( ycm ):
assert_that( assert_that(
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ { 'word': 'πππππππ yummy πie' } ] ), 'completions': ToBytesOnPY2(
[ { 'word': 'πππππππ yummy πie', 'equal': 1 } ]
),
'completion_start_column': 13 'completion_start_column': 13
} ) } )
) )
@ -563,11 +571,12 @@ def OmniCompleter_GetCompletions_Cache_ObjectList_Unicode_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': [ { 'completions': [ {
'word': 'π†´ß†π', 'word' : 'π†´ß†π',
'abbr': 'ÅııÂʉÍÊ', 'abbr' : 'ÅııÂʉÍÊ',
'menu': '˜‰ˆËʉÍÊ', 'menu' : '˜‰ˆËʉÍÊ',
'info': 'ȈÏØʉÍÊ', 'info' : 'ȈÏØʉÍÊ',
'kind': 'Ê' 'kind' : 'Ê',
'equal': 1
} ], } ],
'completion_start_column': 13 'completion_start_column': 13
} ) } )
@ -617,17 +626,19 @@ def OmniCompleter_GetCompletions_Cache_ObjectListObject_Unicode_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': contains( { 'completions': contains( {
'word': 'test', 'word' : 'test',
'abbr': 'ÅııÂʉÍÊ', 'abbr' : 'ÅııÂʉÍÊ',
'menu': '˜‰ˆËʉÍÊ', 'menu' : '˜‰ˆËʉÍÊ',
'info': 'ȈÏØʉÍÊ', 'info' : 'ȈÏØʉÍÊ',
'kind': 'Ê' 'kind' : 'Ê',
'equal': 1
}, { }, {
'word': 'ålpha∫et', 'word' : 'ålpha∫et',
'abbr': 'å∫∫®', 'abbr' : 'å∫∫®',
'menu': 'µ´~¨á', 'menu' : 'µ´~¨á',
'info': '^~fo', 'info' : '^~fo',
'kind': '˚' 'kind' : '˚',
'equal': 1
} ), } ),
'completion_start_column': 13 'completion_start_column': 13
} ) } )
@ -663,7 +674,7 @@ def OmniCompleter_GetCompletions_RestoreCursorPositionAfterOmnifuncCall_test(
assert_that( assert_that(
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ { 'word': 'length' } ] ), 'completions': ToBytesOnPY2( [ { 'word': 'length', 'equal': 1 } ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
) )
@ -698,7 +709,7 @@ def OmniCompleter_GetCompletions_MoveCursorPositionAtStartColumn_test( ycm ):
assert_that( assert_that(
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ { 'word': 'length' } ] ), 'completions': ToBytesOnPY2( [ { 'word': 'length', 'equal': 1 } ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
) )
@ -731,14 +742,14 @@ def StartColumnCompliance( ycm,
def OmniCompleter_GetCompletions_StartColumnCompliance_test(): def OmniCompleter_GetCompletions_StartColumnCompliance_test():
yield StartColumnCompliance, -4, [ { 'word': 'foo' } ], 3 yield StartColumnCompliance, -4, [ { 'word': 'foo', 'equal': 1 } ], 3
yield StartColumnCompliance, -3, [], 1 yield StartColumnCompliance, -3, [], 1
yield StartColumnCompliance, -2, [], 1 yield StartColumnCompliance, -2, [], 1
yield StartColumnCompliance, -1, [ { 'word': 'foo' } ], 3 yield StartColumnCompliance, -1, [ { 'word': 'foo', 'equal': 1 } ], 3
yield StartColumnCompliance, 0, [ { 'word': 'foo' } ], 1 yield StartColumnCompliance, 0, [ { 'word': 'foo', 'equal': 1 } ], 1
yield StartColumnCompliance, 1, [ { 'word': 'foo' } ], 2 yield StartColumnCompliance, 1, [ { 'word': 'foo', 'equal': 1 } ], 2
yield StartColumnCompliance, 2, [ { 'word': 'foo' } ], 3 yield StartColumnCompliance, 2, [ { 'word': 'foo', 'equal': 1 } ], 3
yield StartColumnCompliance, 3, [ { 'word': 'foo' } ], 3 yield StartColumnCompliance, 3, [ { 'word': 'foo', 'equal': 1 } ], 3
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0, @YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0,
@ -783,7 +794,7 @@ def OmniCompleter_GetCompletions_NoCache_ForceSemantic_test( ycm ):
assert_that( assert_that(
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ { 'word': 'test' } ] ), 'completions': ToBytesOnPY2( [ { 'word': 'test', 'equal': 1 } ] ),
'completion_start_column': 1 'completion_start_column': 1
} ) } )
) )
@ -811,8 +822,8 @@ def OmniCompleter_GetCompletions_ConvertStringsToDictionaries_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ 'completions': ToBytesOnPY2( [
{ 'word': 'a' }, { 'word': 'a', 'equal': 1 },
{ 'word': 'b' } { 'word': 'b', 'equal': 1 }
] ), ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
@ -894,9 +905,9 @@ def OmniCompleter_GetCompletions_FiletypeDisabled_ForceSemantic_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ 'completions': ToBytesOnPY2( [
{ 'word': 'a' }, { 'word': 'a', 'equal': 1 },
{ 'word': 'b' }, { 'word': 'b', 'equal': 1 },
{ 'word': 'cdef' } { 'word': 'cdef', 'equal': 1 }
] ), ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )
@ -924,9 +935,9 @@ def OmniCompleter_GetCompletions_AllFiletypesDisabled_ForceSemantic_test( ycm ):
ycm.GetCompletionResponse(), ycm.GetCompletionResponse(),
has_entries( { has_entries( {
'completions': ToBytesOnPY2( [ 'completions': ToBytesOnPY2( [
{ 'word': 'a' }, { 'word': 'a', 'equal': 1 },
{ 'word': 'b' }, { 'word': 'b', 'equal': 1 },
{ 'word': 'cdef' } { 'word': 'cdef', 'equal': 1 }
] ), ] ),
'completion_start_column': 6 'completion_start_column': 6
} ) } )

View File

@ -1,4 +1,4 @@
# Copyright (C) 2011-2018 YouCompleteMe contributors # Copyright (C) 2011-2019 YouCompleteMe contributors
# #
# This file is part of YouCompleteMe. # This file is part of YouCompleteMe.
# #
@ -707,6 +707,8 @@ def ToBytesOnPY2( data ):
if not PY2: if not PY2:
return data return data
if isinstance( data, int ):
return data
if isinstance( data, list ): if isinstance( data, list ):
return [ ToBytesOnPY2( item ) for item in data ] return [ ToBytesOnPY2( item ) for item in data ]
if isinstance( data, dict ): if isinstance( data, dict ):