- Fixed substitute marker.

This commit is contained in:
Shougo Matsushita 2012-03-19 00:56:24 +09:00
parent f741685f9e
commit 809060696c
2 changed files with 17 additions and 12 deletions

View File

@ -804,20 +804,21 @@ endfunction"}}}
function! s:substitute_placeholder_marker(start, end, snippet_holder_cnt)"{{{ function! s:substitute_placeholder_marker(start, end, snippet_holder_cnt)"{{{
if a:snippet_holder_cnt > 1 if a:snippet_holder_cnt > 1
let cnt = a:snippet_holder_cnt-1 let cnt = a:snippet_holder_cnt-1
let marker = substitute(s:get_sync_placeholder_marker_pattern(), let sync_marker = substitute(s:get_sync_placeholder_marker_pattern(),
\ '\\d\\+', cnt, '')
let mirror_marker = substitute(
\ s:get_mirror_placeholder_marker_pattern(),
\ '\\d\\+', cnt, '') \ '\\d\\+', cnt, '')
let line = a:start let line = a:start
for line in range(a:start, a:end) for line in range(a:start, a:end)
if getline(line) =~ marker if getline(line) =~ sync_marker
let sub = escape(matchstr(getline(line), let sub = escape(matchstr(getline(line),
\ substitute(s:get_sync_placeholder_marker_default_pattern(), \ substitute(s:get_sync_placeholder_marker_default_pattern(),
\ '\\d\\+', cnt, '')), '/\') \ '\\d\\+', cnt, '')), '/\')
silent execute printf('%d,%ds/' . substitute( silent execute printf('%d,%ds/' . mirror_marker . '/%s/'
\ s:get_mirror_placeholder_marker_pattern(),
\ '\\d\\+', cnt, '') . '/%s/'
\ . (&gdefault ? '' : 'g'), a:start, a:end, sub) \ . (&gdefault ? '' : 'g'), a:start, a:end, sub)
call setline(line, substitute(getline('.'), marker, sub, 'g')) call setline(line, substitute(getline(line), sync_marker, sub, ''))
endif endif
endfor endfor
elseif search(s:get_sync_placeholder_marker_pattern(), 'wb') > 0 elseif search(s:get_sync_placeholder_marker_pattern(), 'wb') > 0
@ -826,13 +827,14 @@ function! s:substitute_placeholder_marker(start, end, snippet_holder_cnt)"{{{
let cnt = matchstr(getline('.'), let cnt = matchstr(getline('.'),
\ substitute(s:get_sync_placeholder_marker_pattern(), \ substitute(s:get_sync_placeholder_marker_pattern(),
\ '\\d\\+', '\\zs\\d\\+\\ze', '')) \ '\\d\\+', '\\zs\\d\\+\\ze', ''))
silent execute printf('%%s/' . substitute( silent execute printf('%%s/' . mirror_marker . '/%s/'
\ s:get_mirror_placeholder_marker_pattern(),
\ '\\d\\+', cnt, '') . '/%s/'
\ . (&gdefault ? 'g' : ''), sub) \ . (&gdefault ? 'g' : ''), sub)
let marker = substitute(s:get_sync_placeholder_marker_pattern(), let sync_marker = substitute(s:get_sync_placeholder_marker_pattern(),
\ '\\d\\+', cnt, '') \ '\\d\\+', cnt, '')
call setline('.', substitute(getline('.'), marker, sub, 'g')) let mirror_marker = substitute(
\ s:get_mirror_placeholder_marker_pattern(),
\ '\\d\\+', cnt, '')
call setline('.', substitute(getline('.'), sync_marker, sub, ''))
endif endif
endfunction"}}} endfunction"}}}
function! s:trigger(function)"{{{ function! s:trigger(function)"{{{

View File

@ -295,6 +295,9 @@ snippet *neocomplcache-snippets-complete-unite-action-snippet*
============================================================================== ==============================================================================
CHANGELOG *neocomplcache-snippets-complete-changelog* CHANGELOG *neocomplcache-snippets-complete-changelog*
2012-03-19
- Fixed substitute marker.
2012-03-18 2012-03-18
- Fixed for expandtab. - Fixed for expandtab.