Skip to content

Commit

Permalink
Fix visual placeholder in legacy parser
Browse files Browse the repository at this point in the history
The fix for #177 only handled the case where a visual placeholder was on
a line with an indent. With this commit, all cases should be handled.
Hopefully.

See #233
  • Loading branch information
ajzafar committed Jun 8, 2016
1 parent a796995 commit 0c20e41
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions autoload/snipmate/legacy.vim
Expand Up @@ -12,8 +12,7 @@ function! snipmate#legacy#process_snippet(snip) abort
else
let visual = ''
endif
let snippet = substitute(snippet, '\n\(\t\+\).\{-\}\zs{VISUAL}',
\ substitute(escape(visual, '%\'), "\n", "\n\\\\1", 'g'), 'g')
let snippet = s:substitute_visual(snippet, visual)

" Evaluate eval (`...`) expressions.
" Backquotes prefixed with a backslash "\" are ignored.
Expand Down Expand Up @@ -118,6 +117,16 @@ function! snipmate#legacy#build_stops(snip, lnum, col, indent) abort
return [stops, i + 1]
endfunction

function! s:substitute_visual(snippet, visual) abort
let lines = []
for line in split(a:snippet, "\n")
let indent = matchstr(line, '^\t\+')
call add(lines, substitute(line, '{VISUAL}',
\ substitute(escape(a:visual, '%\'), "\n", "\n" . indent, 'g'), 'g'))
endfor
return join(lines, "\n")
endfunction

" Counts occurences of haystack in needle
function! s:count(haystack, needle) abort
let counter = 0
Expand Down

0 comments on commit 0c20e41

Please sign in to comment.