- Improved targetted placeholder behavior.

This commit is contained in:
Shougo Matsushita 2012-10-30 10:47:52 +09:00
parent bee141782a
commit 6ec0f14a87

View File

@ -580,9 +580,11 @@ function! neosnippet#expand(cur_text, col, trigger_name)"{{{
call append('.', snippet_lines[1:]) call append('.', snippet_lines[1:])
endif endif
if begin_line != end_line let neosnippet = neosnippet#get_current_neosnippet()
call s:indent_snippet(begin_line, end_line)
endif call s:indent_snippet(
\ (neosnippet.target == '' ? begin_line : begin_line + 1),
\ end_line)
let begin_patterns = (begin_line > 1) ? let begin_patterns = (begin_line > 1) ?
\ [getline(begin_line - 1)] : [] \ [getline(begin_line - 1)] : []
@ -624,7 +626,13 @@ function! neosnippet#expand_target()"{{{
\ neosnippet#get_selected_text(visualmode(), 1), '\n$', '', '') \ neosnippet#get_selected_text(visualmode(), 1), '\n$', '', '')
call neosnippet#delete_selected_text(visualmode(), 1) call neosnippet#delete_selected_text(visualmode(), 1)
call setline('.', matchstr(neosnippet.target, '^\s*') . trigger) let base_indent = matchstr(neosnippet.target, '^\s*')
" Delete base_indent.
let neosnippet.target = substitute(neosnippet.target,
\'^' . base_indent, '', 'g')
call setline('.', base_indent . trigger)
startinsert! startinsert!
call neosnippet#expand(getline('.'), col('$'), trigger) call neosnippet#expand(getline('.'), col('$'), trigger)
@ -837,17 +845,15 @@ function! s:expand_target_placeholder(line, col)"{{{
endif endif
try try
let base_indent = matchstr(cur_text, '^\s\+')
call setline(a:line, target_lines[0]) call setline(a:line, target_lines[0])
if len(target_lines) > 1 if len(target_lines) > 1
call append(a:line, target_lines[1:]) call append(a:line, map(target_lines[1:],
\ 'base_indent . v:val'))
endif endif
call cursor(end_line, 0) call cursor(end_line, 0)
if begin_line != end_line
call s:indent_snippet(begin_line, end_line)
endif
if next_line != '' if next_line != ''
startinsert startinsert
else else