diff --git a/autoload/neosnippet/handlers.vim b/autoload/neosnippet/handlers.vim index 507e732..ef0c72d 100644 --- a/autoload/neosnippet/handlers.vim +++ b/autoload/neosnippet/handlers.vim @@ -107,7 +107,7 @@ function! neosnippet#handlers#_get_in_paren(str) abort "{{{ continue endif elseif c == ')' - if level == 1 + if level == 1 && s != '' return s else let level -= 1 diff --git a/test/functions.vim b/test/functions.vim index 9ebf8b8..29797aa 100644 --- a/test/functions.vim +++ b/test/functions.vim @@ -2,15 +2,26 @@ let s:suite = themis#suite('toml') let s:assert = themis#helper('assert') function! s:suite.get_in_paren() - call s:assert.equals(neosnippet#handlers#_get_in_paren('(foobar)'), + call s:assert.equals(neosnippet#handlers#_get_in_paren( + \ '(foobar)'), \ 'foobar') - call s:assert.equals(neosnippet#handlers#_get_in_paren('(foobar, baz)'), + call s:assert.equals(neosnippet#handlers#_get_in_paren( + \ '(foobar, baz)'), \ 'foobar, baz') - call s:assert.equals(neosnippet#handlers#_get_in_paren('(foobar, (baz))'), + call s:assert.equals(neosnippet#handlers#_get_in_paren( + \ '(foobar, (baz))'), \ 'foobar, (baz)') - call s:assert.equals(neosnippet#handlers#_get_in_paren('foobar('), + call s:assert.equals(neosnippet#handlers#_get_in_paren( + \ 'foobar('), \ '') - call s:assert.equals(neosnippet#handlers#_get_in_paren('foobar(fname)'), + call s:assert.equals(neosnippet#handlers#_get_in_paren( + \ 'foobar()'), + \ '') + call s:assert.equals(neosnippet#handlers#_get_in_paren( + \ 'foobar(fname)'), \ 'fname') + call s:assert.equals(neosnippet#handlers#_get_in_paren( + \ 'wait() wait(long, int)'), + \ 'long, int') endfunction