Fix #413 parse problem

This commit is contained in:
Shougo Matsushita 2018-02-04 18:11:52 +09:00
parent 770ed583cf
commit b500600c56
2 changed files with 10 additions and 12 deletions

View File

@ -295,15 +295,18 @@ function! neosnippet#parser#_get_completed_snippet(completed_item, cur_text, nex
endif endif
" Set abbr " Set abbr
let abbr = (item.abbr != '') ? item.abbr : item.word let abbr = ''
if len(item.menu) > 5 if get(item, 'info', '') =~# '^.\+('
" Combine menu. let abbr = matchstr(item.info, '^\_s*\zs.*')
let abbr .= ' ' . item.menu elseif get(item, 'abbr', '') =~# '^.\+('
endif let abbr = item.abbr
if item.info != '' elseif get(item, 'menu', '') =~# '^.\+('
let abbr .= split(item.info, '\n')[0] let abbr = item.menu
elseif item.word =~# '^.\+(' || get(item, 'kind', '') == 'f'
let abbr = item.word
endif endif
let abbr = escape(abbr, '\') let abbr = escape(abbr, '\')
let pairs = neosnippet#util#get_buffer_config( let pairs = neosnippet#util#get_buffer_config(
\ &filetype, '', \ &filetype, '',
\ 'g:neosnippet#completed_pairs', 'g:neosnippet#_completed_pairs', {}) \ 'g:neosnippet#completed_pairs', 'g:neosnippet#_completed_pairs', {})

View File

@ -92,11 +92,6 @@ function! s:suite.get_completed_snippet() abort
\ 'menu' : '', 'info' : '' \ 'menu' : '', 'info' : ''
\ }, 'foo{', ''), '${1}}${2}') \ }, 'foo{', ''), '${1}}${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo{', 'abbr' : 'foo{piyo}',
\ 'menu' : '', 'info' : ''
\ }, 'foo{', ''), '${1:#:piyo}}${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({ call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'Dictionary', 'abbr' : 'Dictionary<Key, Value>(foo)', \ 'word' : 'Dictionary', 'abbr' : 'Dictionary<Key, Value>(foo)',
\ 'menu' : '', 'info' : '' \ 'menu' : '', 'info' : ''