Fixed a bug that could happen when a whole snippet was deleted.
This commit is contained in:
parent
634fdeb282
commit
8c9bf502f2
@ -16,8 +16,11 @@ def is_complete_edit(initial_line, a, b, cmds):
|
||||
if char != '\n':
|
||||
buf[line] = buf[line][:col] + buf[line][col+len(char):]
|
||||
else:
|
||||
buf[line] = buf[line] + buf[line+1]
|
||||
del buf[line+1]
|
||||
if len(buf) > 1:
|
||||
buf[line] = buf[line] + buf[line+1]
|
||||
del buf[line+1]
|
||||
else:
|
||||
del buf[line]
|
||||
elif ctype == "I":
|
||||
buf[line] = buf[line][:col] + char + buf[line][col:]
|
||||
buf = '\n'.join(buf).split('\n')
|
||||
@ -34,11 +37,11 @@ def guess_edit(initial_line, lt, ct, vs):
|
||||
ppos = vs.ppos
|
||||
if len(lt) and (not ct or (len(ct) == 1 and not ct[0])): # All text deleted?
|
||||
es = []
|
||||
if not ct: ct = ['']
|
||||
for i in lt:
|
||||
es.append(("D", initial_line, 0, i))
|
||||
es.append(("D", initial_line, 0, "\n"))
|
||||
if ct:
|
||||
es.pop() # Remove final \n because it is not really removed
|
||||
es.pop() # Remove final \n because it is not really removed
|
||||
if is_complete_edit(initial_line, lt, ct, es): return True, es
|
||||
if ppos.mode == 'v': # Maybe selectmode?
|
||||
sv = list(map(int, _vim.eval("""getpos("'<")"""))); sv = Position(sv[1]-1,sv[2]-1)
|
||||
|
4
test.py
4
test.py
@ -2520,6 +2520,10 @@ class JumpForward_DefSnippet(_VimTest):
|
||||
snippets = ("test", "${1}\n`!p snip.rv = '\\n'.join(t[1].split())`\n\n${0:pass}")
|
||||
keys = "test" + EX + "a b c" + JF + "shallnot" + JF + "end"
|
||||
wanted = "a b c\na\nb\nc\n\nshallnotend"
|
||||
class DeleteSnippetInsertion(_VimTest):
|
||||
snippets = ("test", "${1:hello} $1")
|
||||
keys = "test" + EX + ESC + "Vkx" + "i\nworld\n"
|
||||
wanted = "world"
|
||||
|
||||
# End: Undo of Snippet insertion #}}}
|
||||
# Tab Completion of Words {{{#
|
||||
|
Loading…
Reference in New Issue
Block a user