Allows empty insertion text.

This is useful for hints for example, whose purpose is information
display solely.
This commit is contained in:
Francisco Lopes 2016-01-02 20:55:49 -02:00
parent f25e1c9a48
commit 9fdd465c26
2 changed files with 80 additions and 31 deletions

View File

@ -64,8 +64,9 @@ class CompletionRequest( BaseRequest ):
def ConvertCompletionDataToVimData( completion_data ):
# see :h complete-items for a description of the dictionary fields
vim_data = {
'word' : ToUtf8IfNeeded( completion_data[ 'insertion_text' ] ),
'dup' : 1,
'word' : '',
'dup' : 1,
'empty' : 1,
}
if ( 'extra_data' in completion_data and
@ -75,6 +76,8 @@ def ConvertCompletionDataToVimData( completion_data ):
else:
doc_string = ""
if 'insertion_text' in completion_data:
vim_data[ 'word' ] = ToUtf8IfNeeded( completion_data[ 'insertion_text' ] )
if 'menu_text' in completion_data:
vim_data[ 'abbr' ] = ToUtf8IfNeeded( completion_data[ 'menu_text' ] )
if 'extra_menu_info' in completion_data:

View File

@ -52,12 +52,13 @@ class ConvertCompletionResponseToVimDatas_test:
'doc_string': 'DOC STRING',
},
}, {
'word': 'INSERTION TEXT',
'abbr': 'MENU TEXT',
'menu': 'EXTRA MENU INFO',
'kind': 'k',
'info': 'DETAILED INFO\nDOC STRING',
'dup' : 1,
'word' : 'INSERTION TEXT',
'abbr' : 'MENU TEXT',
'menu' : 'EXTRA MENU INFO',
'kind' : 'k',
'info' : 'DETAILED INFO\nDOC STRING',
'dup' : 1,
'empty': 1,
} )
@ -69,12 +70,13 @@ class ConvertCompletionResponseToVimDatas_test:
'kind': 'K',
'detailed_info': 'DETAILED INFO',
}, {
'word': 'INSERTION TEXT',
'abbr': 'MENU TEXT',
'menu': 'EXTRA MENU INFO',
'kind': 'k',
'info': 'DETAILED INFO',
'dup' : 1,
'word' : 'INSERTION TEXT',
'abbr' : 'MENU TEXT',
'menu' : 'EXTRA MENU INFO',
'kind' : 'k',
'info' : 'DETAILED INFO',
'dup' : 1,
'empty': 1,
} )
@ -88,12 +90,13 @@ class ConvertCompletionResponseToVimDatas_test:
'doc_string': 'DOC STRING',
},
}, {
'word': 'INSERTION TEXT',
'abbr': 'MENU TEXT',
'menu': 'EXTRA MENU INFO',
'kind': 'k',
'info': 'DOC STRING',
'dup' : 1,
'word' : 'INSERTION TEXT',
'abbr' : 'MENU TEXT',
'menu' : 'EXTRA MENU INFO',
'kind' : 'k',
'info' : 'DOC STRING',
'dup' : 1,
'empty': 1,
} )
@ -106,11 +109,12 @@ class ConvertCompletionResponseToVimDatas_test:
'extra_data': {
},
}, {
'word': 'INSERTION TEXT',
'abbr': 'MENU TEXT',
'menu': 'EXTRA MENU INFO',
'kind': 'k',
'dup' : 1,
'word' : 'INSERTION TEXT',
'abbr' : 'MENU TEXT',
'menu' : 'EXTRA MENU INFO',
'kind' : 'k',
'dup' : 1,
'empty': 1,
} )
@ -124,10 +128,52 @@ class ConvertCompletionResponseToVimDatas_test:
'extra_data': {
},
}, {
'word': 'INSERTION TEXT',
'abbr': 'MENU TEXT',
'menu': 'EXTRA MENU INFO',
'kind': 'k',
'info': 'DETAILED INFO',
'dup' : 1,
'word' : 'INSERTION TEXT',
'abbr' : 'MENU TEXT',
'menu' : 'EXTRA MENU INFO',
'kind' : 'k',
'info' : 'DETAILED INFO',
'dup' : 1,
'empty': 1,
} )
def Empty_Insertion_Text_test( self ):
self._Check( {
'insertion_text': '',
'menu_text': 'MENU TEXT',
'extra_menu_info': 'EXTRA MENU INFO',
'kind': 'K',
'detailed_info': 'DETAILED INFO',
'extra_data': {
'doc_string': 'DOC STRING',
},
}, {
'word' : '',
'abbr' : 'MENU TEXT',
'menu' : 'EXTRA MENU INFO',
'kind' : 'k',
'info' : 'DETAILED INFO\nDOC STRING',
'dup' : 1,
'empty': 1,
} )
def No_Insertion_Text_test( self ):
self._Check( {
'menu_text': 'MENU TEXT',
'extra_menu_info': 'EXTRA MENU INFO',
'kind': 'K',
'detailed_info': 'DETAILED INFO',
'extra_data': {
'doc_string': 'DOC STRING',
},
}, {
'word' : '',
'abbr' : 'MENU TEXT',
'menu' : 'EXTRA MENU INFO',
'kind' : 'k',
'info' : 'DETAILED INFO\nDOC STRING',
'dup' : 1,
'empty': 1,
} )