Modifying autocomplete to handle values which haven't been specified
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
UltiSnips |
Fix Committed
|
Medium
|
Unassigned |
Bug Description
This is the snippet that I have
snippet '^#?inc' "#include <>" !r
#include <$1`!p snip.rv = complete(t[1], ['cassert', 'cstdio', 'cstdlib', 'cstring', 'fstream', 'iostream', 'sstream'])`>
endsnippet
and the global complete function
global !p
def complete(t, opts):
if t:
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
if len(opts) == 1:
return opts[0]
elif len(opts) > 1:
return "(" + "|".join(opts) + ")"
else:
return ""
endglobal
which I'm trying to modify to return an empty string when there's no match.
But the problem is when I try to input something which hasn't been specified ( for eg. 'vector' ), the cursor jumps from the tabstop to the start of the line.
Cannot reproduce, seems to work good for me:
inc<tab>v -> #include <v>
inc<tab>f -> #include <fstream>
cursor is not jumping for me. Please provide Ultisnips version, vim
version, OS and a minimal .vim an vimrc to reproduce the problem.
status incomplete