- Improved expand behavior.

This commit is contained in:
Shougo Matsushita 2012-10-28 18:58:55 +09:00
parent 77375e8fd3
commit 6f2f181cb3
3 changed files with 42 additions and 28 deletions

View File

@ -575,39 +575,42 @@ function! neosnippet#expand(cur_text, col, trigger_name)"{{{
let &l:foldmethod = 'manual' let &l:foldmethod = 'manual'
endif endif
call setline('.', snippet_lines[0]) try
if len(snippet_lines) > 1 call setline('.', snippet_lines[0])
call append('.', snippet_lines[1:]) if len(snippet_lines) > 1
endif call append('.', snippet_lines[1:])
endif
call s:indent_snippet(begin_line, end_line) call s:indent_snippet(begin_line, end_line)
let begin_patterns = (begin_line > 1) ? let begin_patterns = (begin_line > 1) ?
\ [getline(begin_line - 1)] : [] \ [getline(begin_line - 1)] : []
let end_patterns = (end_line < line('$')) ? let end_patterns = (end_line < line('$')) ?
\ [getline(end_line + 1)] : [] \ [getline(end_line + 1)] : []
call add(s:snippets_expand_stack, { call add(s:snippets_expand_stack, {
\ 'begin_line' : begin_line, \ 'begin_line' : begin_line,
\ 'begin_patterns' : begin_patterns, \ 'begin_patterns' : begin_patterns,
\ 'end_line' : end_line, \ 'end_line' : end_line,
\ 'end_patterns' : end_patterns, \ 'end_patterns' : end_patterns,
\ 'holder_cnt' : 1, \ 'holder_cnt' : 1,
\ }) \ })
if next_col < col('$') if next_col < col('$')
startinsert startinsert
else else
startinsert! startinsert!
endif endif
if snip_word =~ s:get_placeholder_marker_pattern() if snip_word =~ s:get_placeholder_marker_pattern()
call s:snippets_jump(a:cur_text, a:col) call s:snippets_jump(a:cur_text, a:col)
endif endif
finally
if has('folding')
let &l:foldmethod = foldmethod
silent! execute begin_line . ',' . end_line . 'foldopen!'
endif
endtry
if has('folding')
let &l:foldmethod = foldmethod
silent! execute begin_line . ',' . end_line . 'foldopen!'
endif
let &l:iminsert = 0 let &l:iminsert = 0
let &l:imsearch = 0 let &l:imsearch = 0
endfunction"}}} endfunction"}}}

View File

@ -50,6 +50,16 @@ options head
${3} ${3}
endtry endtry
snippet tryfinally
abbr try ... finally ... endtry
alias tryf
options head
try
${1}
finally
${2}
endtry
snippet catch snippet catch
options head options head
catch ${1:/${2:pattern: empty, E484, Vim(cmdname):{errmsg\\}\}/} catch ${1:/${2:pattern: empty, E484, Vim(cmdname):{errmsg\\}\}/}

View File

@ -456,6 +456,7 @@ CHANGELOG *neosnippet-changelog*
2012-10-28 2012-10-28
- Improved snipMate compatibility. - Improved snipMate compatibility.
- Improved expand behavior.
2012-10-27 2012-10-27
- Fixed for :SnippetEdit. - Fixed for :SnippetEdit.