From de5a7e284d97b1189d01f029feb1b7d88d908a69 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 19 Dec 2015 09:09:19 +0900 Subject: [PATCH] Fix nested snippets behavior --- autoload/neosnippet/variables.vim | 3 +++ autoload/neosnippet/view.vim | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/autoload/neosnippet/variables.vim b/autoload/neosnippet/variables.vim index a09f9d9..795d42b 100644 --- a/autoload/neosnippet/variables.vim +++ b/autoload/neosnippet/variables.vim @@ -46,6 +46,9 @@ function! neosnippet#variables#expand_stack() "{{{ return s:expand_stack endfunction"}}} +function! neosnippet#variables#pop_expand_stack() "{{{ + let s:expand_stack = s:expand_stack[: -2] +endfunction"}}} function! neosnippet#variables#clear_expand_stack() "{{{ let s:expand_stack = [] endfunction"}}} diff --git a/autoload/neosnippet/view.vim b/autoload/neosnippet/view.vim index f4f51af..c7cccc9 100644 --- a/autoload/neosnippet/view.vim +++ b/autoload/neosnippet/view.vim @@ -167,10 +167,9 @@ function! neosnippet#view#_jump(_, col) "{{{ endif " Not found. - let expand_stack = neosnippet#variables#expand_stack() - let expand_stack = expand_stack[: -2] + call neosnippet#variables#pop_expand_stack() - return neosnippet#view#_search_outof_range(a:col) + return neosnippet#view#_jump(a:_, a:col) endfunction"}}} function! s:indent_snippet(begin, end) "{{{ @@ -229,6 +228,10 @@ function! neosnippet#view#_get_snippet_range(begin_line, begin_patterns, end_lin let begin = 1 endif + if a:begin_line == a:end_line + return [begin, begin] + endif + call cursor(a:end_line, 0) if empty(a:end_patterns) let end = line('.') + 50