From 57301f8a5d405c6c793c3b4d1a86f198dcdc81a9 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Fri, 1 Jan 2016 20:53:21 +0900 Subject: [PATCH] Fix #317 completed snippet problem --- autoload/neosnippet/parser.vim | 6 ++++++ test/functions.vim | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/autoload/neosnippet/parser.vim b/autoload/neosnippet/parser.vim index f2da984..1313dfe 100644 --- a/autoload/neosnippet/parser.vim +++ b/autoload/neosnippet/parser.vim @@ -316,6 +316,12 @@ function! neosnippet#parser#_get_completed_snippet(completed_item) "{{{ let cnt = 1 let snippet = '' + if empty(filter(values(pairs), 'stridx(abbr, v:val) > 0')) + " Pairs not found pattern + let snippet .= '${' . cnt . '}' + let cnt += 1 + endif + if abbr =~ '<.\+>(.*)' " Add angle analysis let snippet .= '<' diff --git a/test/functions.vim b/test/functions.vim index b350724..d39a5b6 100644 --- a/test/functions.vim +++ b/test/functions.vim @@ -38,6 +38,11 @@ function! s:suite.get_completed_snippet() \ 'menu' : '', 'info' : '' \ }), ')${1}') + call s:assert.equals(neosnippet#parser#_get_completed_snippet({ + \ 'word' : 'foo(', 'abbr' : '', + \ 'menu' : '', 'info' : '' + \ }), '${1})${2}') + call s:assert.equals(neosnippet#parser#_get_completed_snippet({ \ 'word' : 'foo(', 'abbr' : 'foo(hoge)', \ 'menu' : '', 'info' : '' @@ -78,6 +83,11 @@ function! s:suite.get_completed_snippet() \ 'menu' : '', 'info' : '' \ }), '}${1}') + 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{piyo}', \ 'menu' : '', 'info' : ''