Fix #252 improve optional placeholder behavior

This commit is contained in:
Shougo Matsushita 2014-10-14 20:49:56 +09:00
parent 58a8296b2a
commit 4734238921
4 changed files with 8 additions and 3 deletions

View File

@ -188,7 +188,7 @@ function! s:trigger(function) "{{{
" Get selected text.
let neosnippet = neosnippet#variables#current_neosnippet()
let neosnippet.trigger = 1
if mode() ==# 's' && neosnippet.selected_text =~ '^#:'
if mode() ==# 's' && neosnippet.optional_tabstop
let expr .= "\<C-o>\"_d"
endif

View File

@ -33,6 +33,7 @@ function! neosnippet#variables#current_neosnippet() "{{{
\ 'selected_text' : '',
\ 'target' : '',
\ 'trigger' : 0,
\ 'optional_tabstop' : 0,
\}
endif

View File

@ -289,11 +289,15 @@ function! s:expand_placeholder(start, end, holder_cnt, line, ...) "{{{
let default = substitute(
\ matchstr(current_line, default_pattern),
\ '\\\ze[^\\]', '', 'g')
let neosnippet.optional_tabstop = (default =~ '^#:')
if !is_select && default =~ '^#:'
" Delete comments.
let default = ''
endif
" Remove optional marker
let default = substitute(default, '^#:', '', '')
let is_target = (default =~ '^TARGET\>' && neosnippet.target != '')
let default = substitute(default, '^TARGET:\?', neosnippet.target, '')

View File

@ -453,7 +453,7 @@ available providing different functionality.
The structure of a placeholder can be:
- ${number:placeholder text}
- ${number:default placeholder text}
The placeholder starts with a dollar sign "$". The number of a
placeholder and the placeholder text are separated by a colon ":".
@ -472,7 +472,7 @@ The structure of a placeholder can be:
endif
<
- ${number:#:placeholder text}
- ${number:#:optional placeholder text}
In this kind of placeholder the number is followed by the hash
character "#". If you jump over this placeholder and do not insert