Skip to content
This repository has been archived by the owner on Jul 25, 2020. It is now read-only.

Commit

Permalink
Fix #45. Restrict placeholder search to snippet body
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyorst committed Jun 26, 2018
1 parent a414579 commit c84c65e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion autoload/SimpleSnippets.vim
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ function! SimpleSnippets#expand()
normal! "sp
let @" = l:save_quote
let @s = l:save_s
let s:snip_start = line(".")
let s:snip_end = s:snip_start + s:snip_line_count - 1
silent call SimpleSnippets#parseAndInit()
else
echo '[ERROR] Snippet body is empty'
Expand All @@ -97,6 +99,8 @@ function! SimpleSnippets#expandFlashSnippet(snip)
let @s = s:flash_snippets[a:snip]
let s:snip_line_count = len(substitute(s:flash_snippets[a:snip], '[^\n]', '', 'g')) + 1
normal! "sp
let s:snip_start = line(".")
let s:snip_end = s:snip_start + s:snip_line_count - 1
let @s = l:save_s
if s:snip_line_count != 1
let l:indent_lines = s:snip_line_count - 1
Expand Down Expand Up @@ -887,7 +891,7 @@ function! SimpleSnippets#initChoice(current)
endfunction

function! SimpleSnippets#countPlaceholders(pattern)
let l:cnt = SimpleSnippets#execute('%s/' . a:pattern . '//gn', "silent!")
let l:cnt = SimpleSnippets#execute(s:snip_start.','.s:snip_end.'s/' . a:pattern . '//gn', "silent!")
call histdel("/", -1)
if match(l:cnt, 'not found') >= 0
return 0
Expand Down

0 comments on commit c84c65e

Please sign in to comment.