Auto merge of #1899 - oblitum:empty-insertion-text, r=oblitum

Allows empty insertion text.

This is useful for hints for example, whose purpose is information
display solely.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1899)
<!-- Reviewable:end -->
This commit is contained in:
Homu 2016-01-13 11:24:41 +09:00
commit ea3e207643
2 changed files with 80 additions and 31 deletions

View File

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

View File

@ -52,12 +52,13 @@ class ConvertCompletionResponseToVimDatas_test:
'doc_string': 'DOC STRING', 'doc_string': 'DOC STRING',
}, },
}, { }, {
'word': 'INSERTION TEXT', 'word' : 'INSERTION TEXT',
'abbr': 'MENU TEXT', 'abbr' : 'MENU TEXT',
'menu': 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind': 'k', 'kind' : 'k',
'info': 'DETAILED INFO\nDOC STRING', 'info' : 'DETAILED INFO\nDOC STRING',
'dup' : 1, 'dup' : 1,
'empty': 1,
} ) } )
@ -69,12 +70,13 @@ class ConvertCompletionResponseToVimDatas_test:
'kind': 'K', 'kind': 'K',
'detailed_info': 'DETAILED INFO', 'detailed_info': 'DETAILED INFO',
}, { }, {
'word': 'INSERTION TEXT', 'word' : 'INSERTION TEXT',
'abbr': 'MENU TEXT', 'abbr' : 'MENU TEXT',
'menu': 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind': 'k', 'kind' : 'k',
'info': 'DETAILED INFO', 'info' : 'DETAILED INFO',
'dup' : 1, 'dup' : 1,
'empty': 1,
} ) } )
@ -88,12 +90,13 @@ class ConvertCompletionResponseToVimDatas_test:
'doc_string': 'DOC STRING', 'doc_string': 'DOC STRING',
}, },
}, { }, {
'word': 'INSERTION TEXT', 'word' : 'INSERTION TEXT',
'abbr': 'MENU TEXT', 'abbr' : 'MENU TEXT',
'menu': 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind': 'k', 'kind' : 'k',
'info': 'DOC STRING', 'info' : 'DOC STRING',
'dup' : 1, 'dup' : 1,
'empty': 1,
} ) } )
@ -106,11 +109,12 @@ class ConvertCompletionResponseToVimDatas_test:
'extra_data': { 'extra_data': {
}, },
}, { }, {
'word': 'INSERTION TEXT', 'word' : 'INSERTION TEXT',
'abbr': 'MENU TEXT', 'abbr' : 'MENU TEXT',
'menu': 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind': 'k', 'kind' : 'k',
'dup' : 1, 'dup' : 1,
'empty': 1,
} ) } )
@ -124,10 +128,52 @@ class ConvertCompletionResponseToVimDatas_test:
'extra_data': { 'extra_data': {
}, },
}, { }, {
'word': 'INSERTION TEXT', 'word' : 'INSERTION TEXT',
'abbr': 'MENU TEXT', 'abbr' : 'MENU TEXT',
'menu': 'EXTRA MENU INFO', 'menu' : 'EXTRA MENU INFO',
'kind': 'k', 'kind' : 'k',
'info': 'DETAILED INFO', 'info' : 'DETAILED INFO',
'dup' : 1, '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,
} ) } )