Improve completed snippet behavior
This commit is contained in:
parent
3e6f927854
commit
50a25a35a2
@ -324,10 +324,12 @@ function! neosnippet#parser#_get_completed_snippet(completed_item) "{{{
|
|||||||
for arg in split(substitute(
|
for arg in split(substitute(
|
||||||
\ neosnippet#parser#_get_in_paren('<', '>', abbr),
|
\ neosnippet#parser#_get_in_paren('<', '>', abbr),
|
||||||
\ '<\zs.\{-}\ze>', '', 'g'), '[^[]\zs\s*,\s*')
|
\ '<\zs.\{-}\ze>', '', 'g'), '[^[]\zs\s*,\s*')
|
||||||
if args != ''
|
if args != '' && arg !=# '...'
|
||||||
let args .= ', '
|
let args .= ', '
|
||||||
endif
|
endif
|
||||||
let args .= printf('${%d:#:%s}', cnt, escape(arg, '{}'))
|
let args .= printf('${%d:#:%s%s}',
|
||||||
|
\ cnt, ((args != '' && arg ==# '...') ? ', ' : ''),
|
||||||
|
\ escape(arg, '{}'))
|
||||||
let cnt += 1
|
let cnt += 1
|
||||||
endfor
|
endfor
|
||||||
let snippet .= args
|
let snippet .= args
|
||||||
@ -343,10 +345,12 @@ function! neosnippet#parser#_get_completed_snippet(completed_item) "{{{
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if args != ''
|
if args != '' && arg !=# '...'
|
||||||
let args .= ', '
|
let args .= ', '
|
||||||
endif
|
endif
|
||||||
let args .= printf('${%d:#:%s}', cnt, escape(arg, '{}'))
|
let args .= printf('${%d:#:%s%s}',
|
||||||
|
\ cnt, ((args != '' && arg ==# '...') ? ', ' : ''),
|
||||||
|
\ escape(arg, '{}'))
|
||||||
let cnt += 1
|
let cnt += 1
|
||||||
endfor
|
endfor
|
||||||
let snippet .= args
|
let snippet .= args
|
||||||
|
@ -58,6 +58,21 @@ function! s:suite.get_completed_snippet()
|
|||||||
\ 'menu' : '', 'info' : ''
|
\ 'menu' : '', 'info' : ''
|
||||||
\ }), '${1:#:hoge}, ${2:#:piyo()})${3}')
|
\ }), '${1:#:hoge}, ${2:#:piyo()})${3}')
|
||||||
|
|
||||||
|
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
|
||||||
|
\ 'word' : 'foo(', 'abbr' : 'foo(hoge[, abc])',
|
||||||
|
\ 'menu' : '', 'info' : ''
|
||||||
|
\ }), '${1:#:hoge[, abc]})${2}')
|
||||||
|
|
||||||
|
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
|
||||||
|
\ 'word' : 'foo(', 'abbr' : 'foo(...)',
|
||||||
|
\ 'menu' : '', 'info' : ''
|
||||||
|
\ }), '${1:#:...})${2}')
|
||||||
|
|
||||||
|
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
|
||||||
|
\ 'word' : 'foo(', 'abbr' : 'foo(hoge, ...)',
|
||||||
|
\ 'menu' : '', 'info' : ''
|
||||||
|
\ }), '${1:#:hoge}${2:#:, ...})${3}')
|
||||||
|
|
||||||
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
|
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
|
||||||
\ 'word' : 'foo{', 'abbr' : 'foo{}',
|
\ 'word' : 'foo{', 'abbr' : 'foo{}',
|
||||||
\ 'menu' : '', 'info' : ''
|
\ 'menu' : '', 'info' : ''
|
||||||
|
Loading…
Reference in New Issue
Block a user