feature/docs-improvement-of-is-expandable-func (#975)

To deal with space characters.
This commit is contained in:
Viacheslav Lotsmanov 2018-05-01 01:01:36 +05:00 committed by UltiBot
parent 30e651fb1f
commit 6fdc3647f7

View File

@ -1797,6 +1797,19 @@ A: Yes there is, try
return !empty(UltiSnips#SnippetsInCurrentScope()) return !empty(UltiSnips#SnippetsInCurrentScope())
endfunction endfunction
Consider that UltiSnips#SnippetsInCurrentScope() will return all the
snippets you have if you call it after a space character. If you want
UltiSnips#IsExpandable() to return false when you call it after a space
character use this a bit more complicated implementation:
function UltiSnips#IsExpandable()
return !(
\ col('.') <= 1
\ || !empty(matchstr(getline('.'), '\%' . (col('.') - 1) . 'c\s'))
\ || empty(UltiSnips#SnippetsInCurrentScope())
\ )
endfunction
============================================================================= =============================================================================
7. Helping Out *UltiSnips-helping* 7. Helping Out *UltiSnips-helping*