From 1230648e393f92acb6b7e29e18417e57baddf0bc Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Thu, 1 Nov 2012 11:18:58 +0900 Subject: [PATCH] - Fixed snippet mirror behavior. --- autoload/neosnippet.vim | 18 +++++++----------- doc/neosnippet.txt | 3 +++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index 7417d44..520cf79 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: neosnippet.vim " AUTHOR: Shougo Matsushita -" Last Modified: 31 Oct 2012. +" Last Modified: 01 Nov 2012. " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the @@ -637,10 +637,6 @@ function! neosnippet#expand_target()"{{{ call neosnippet#substitute_selected_text(visualmode(), \ base_indent) - " startinsert! - " let start = getpos("'<") - " call cursor(0, start[2]+len(base_indent . trigger)-1) - call neosnippet#expand(neosnippet#util#get_cur_text(), \ col('.'), trigger) endfunction"}}} @@ -754,10 +750,10 @@ endfunction"}}} function! s:search_snippet_range(start, end, cnt)"{{{ call s:substitute_placeholder_marker(a:start, a:end, a:cnt) - let pattern = substitute( - \ s:get_placeholder_marker_pattern(), '\\d\\+', a:cnt, '') + " Search marker pattern. + let pattern = substitute(s:get_placeholder_marker_pattern(), + \ '\\d\\+', a:cnt, '') - let line = a:start for line in filter(range(a:start, a:end), \ 'getline(v:val) =~ pattern') call s:expand_placeholder(a:start, a:end, a:cnt, line) @@ -780,7 +776,7 @@ function! s:search_outof_range(col)"{{{ let pos[2] = 1 call setpos('.', pos) startinsert - elseif a:col == col('$') + elseif a:col >= col('$') startinsert! else let pos[2] = a:col+1 @@ -831,7 +827,7 @@ function! s:expand_placeholder(start, end, holder_cnt, line)"{{{ let pos[2] = match+1 let cnt = s:search_sync_placeholder(a:start, a:end, a:holder_cnt) - if cnt > 0 + if cnt >= 0 let pattern = substitute(s:get_placeholder_marker_pattern(), \ '\\d\\+', cnt, '') call setline(a:line, substitute(current_line, pattern, @@ -932,7 +928,7 @@ function! s:search_sync_placeholder(start, end, number)"{{{ return 0 endfunction"}}} function! s:substitute_placeholder_marker(start, end, snippet_holder_cnt)"{{{ - if a:snippet_holder_cnt > 1 + if a:snippet_holder_cnt > 0 let cnt = a:snippet_holder_cnt-1 let sync_marker = substitute(s:get_sync_placeholder_marker_pattern(), \ '\\d\\+', cnt, '') diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index 1d98251..1f5a765 100644 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -624,6 +624,9 @@ Note: But you must unmap in select mode mappings manually. ============================================================================== CHANGELOG *neosnippet-changelog* +2012-11-01 +- Fixed snippet mirror behavior. + 2012-10-31 - Improved indent_snippet(). - Added (neosnippet_start_unite_snippet_target).