Skip to content

Commit

Permalink
Fix #322 completed snippet error for < Foo,Fee> in ()
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jan 18, 2016
1 parent 3db55f3 commit 58fa466
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion autoload/neosnippet.vim
Expand Up @@ -47,7 +47,10 @@ call neosnippet#util#set_default(
call neosnippet#util#set_default(
\ 'g:neosnippet#enable_auto_clear_markers', 1)
call neosnippet#util#set_default(
\ 'g:neosnippet#completed_pairs',{'_':{ '(' : ')', '{' : '}', '"' : '"' }})
\ 'g:neosnippet#completed_pairs', {})
call neosnippet#util#set_default(
\ 'g:neosnippet#_completed_pairs',
\ {'_':{ '(' : ')', '{' : '}', '"' : '"' }})
"}}}

function! neosnippet#expandable_or_jumpable() "{{{
Expand Down
11 changes: 5 additions & 6 deletions autoload/neosnippet/parser.vim
Expand Up @@ -304,11 +304,9 @@ function! neosnippet#parser#_get_completed_snippet(completed_item, next_text) "{
if item.info != ''
let abbr = split(item.info, '\n')[0]
endif
if index(keys(g:neosnippet#completed_pairs),expand(&ft)) < 0
let pairs = g:neosnippet#completed_pairs._
else
let pairs = g:neosnippet#completed_pairs[expand(&ft)]
endif
let pairs = neosnippet#util#get_buffer_config(
\ &filetype, '',
\ 'g:neosnippet#completed_pairs', 'g:neosnippet#_completed_pairs', {})
let word_pattern = neosnippet#util#escape_pattern(item.word)
let angle_pattern = word_pattern . '<.\+>(.*)'
let no_key = index(keys(pairs), item.word[-1:]) < 0
Expand Down Expand Up @@ -366,7 +364,8 @@ function! neosnippet#parser#_get_completed_snippet(completed_item, next_text) "{
let args = ''
for arg in split(substitute(
\ neosnippet#parser#_get_in_paren(key, pair, abbr),
\ key.'\zs.\{-}\ze'.pair, '', 'g'), '[^[]\zs\s*,\s*')
\ key.'\zs.\{-}\ze'.pair . '\|<\zs.\{-}\ze>', '', 'g'),
\ '[^[]\zs\s*,\s*')
if key ==# '(' && arg ==# 'self' && &filetype ==# 'python'
" Ignore self argument
continue
Expand Down
5 changes: 5 additions & 0 deletions test/functions.vim
Expand Up @@ -123,5 +123,10 @@ function! s:suite.get_completed_snippet()
\ 'word' : 'Dictionary', 'abbr' : 'Dictionary(foo)',
\ 'menu' : '', 'info' : ''
\ }, ''), '(${1:#:foo})${2}')

call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'forEach', 'abbr' : 'forEach(BiConsumer<Object, Object>)',
\ 'menu' : '', 'info' : ''
\ }, ''), '(${1:#:BiConsumer<>})${2}')
endfunction

0 comments on commit 58fa466

Please sign in to comment.