Mor fixes and refactorings

This commit is contained in:
Holger Rapp 2012-01-16 16:43:34 +01:00
parent 544af97bff
commit b49d5482fa
4 changed files with 282 additions and 247 deletions

View File

@ -163,6 +163,7 @@ class _TOParser(object):
def _replace_initital_texts(self): def _replace_initital_texts(self):
def _do_it(obj): def _do_it(obj):
debug("In _do_it: obj: %r" % (obj))
obj.initial_replace() obj.initial_replace()
for c in obj._childs: # TODO: private parts! for c in obj._childs: # TODO: private parts!
@ -181,7 +182,7 @@ class _TOParser(object):
seen_ts[token.no] = ts seen_ts[token.no] = ts
self._parent_to._add_tabstop(ts) self._parent_to._add_tabstop(ts)
k = _TOParser(ts, ts.current_text, self._indent) k = _TOParser(ts, token.initial_text, self._indent)
k._do_parse(all_tokens, seen_ts) k._do_parse(all_tokens, seen_ts)
elif isinstance(token, EscapeCharToken): elif isinstance(token, EscapeCharToken):
EscapedChar(self._parent_to, token) EscapedChar(self._parent_to, token)
@ -232,7 +233,7 @@ class TextObject(CheapTotalOrdering):
self._end = ct.calc_end(self._start) self._end = ct.calc_end(self._start)
if self.abs_end != old_end: if self.abs_end != old_end:
if self._parent is not None: if self._parent is not None:
self._parent.child_end_moved(self, old_end, self.abs_end) self._parent.child_end_moved(old_end, self.abs_end - old_end, set((self,)))
def __cmp__(self, other): def __cmp__(self, other):
return self._start.__cmp__(other._start) return self._start.__cmp__(other._start)
@ -249,9 +250,9 @@ class TextObject(CheapTotalOrdering):
return as_unicode(buf[abs_span.start.line][abs_span.start.col:abs_span.end.col]) return as_unicode(buf[abs_span.start.line][abs_span.start.col:abs_span.end.col])
else: else:
lines = [] lines = []
lines.append(buf[abs_span.start.line][abs_span.col:]) lines.append(buf[abs_span.start.line][abs_span.start.col:])
lines.extend(buf[abs_span.start.line+1:abs_span.end.line]) lines.extend(buf[abs_span.start.line+1:abs_span.end.line])
line.append(buf[aps_span.end.line][:abs_span.end.col]) lines.append(buf[abs_span.end.line][:abs_span.end.col])
return as_unicode('\n'.join(lines)) return as_unicode('\n'.join(lines))
@property @property
@ -300,43 +301,34 @@ class TextObject(CheapTotalOrdering):
#################### ####################
# Public functions # # Public functions #
#################### ####################
def child_end_moved(self, child, old_end, new_end): # TODO: pretty wasteful, give index def child_end_moved(self, sp, diff, skip): # TODO: pretty wasteful, give index
debug("self: %r, child: %r, old_end: %r, new_end: %r" % (self, child, old_end, new_end)) debug("self: %r, skip: %r, diff: %r" % (self, skip, diff))
delta = new_end - old_end
def _move_col_start(obj): def _move_start(obj):
if obj.abs_start.line == old_end.line and obj.abs_start.col >= old_end.col: if obj.abs_start.line == sp.line and obj.abs_start.col >= sp.col:
obj._start.col += delta.col obj._start.line += diff.line
def _move_col_end(obj): obj._start.col += diff.col
if obj.abs_end.line == old_end.line and obj.abs_end.col >= old_end.col: elif obj.abs_start.line > sp.line:
obj._end.col += delta.col obj._start.line += diff.line
def _move_line_col_start(obj): def _move_end(obj):
if obj.abs_start.line == old_end.line and obj.abs_start.col >= old_end.col: if obj.abs_end.line == sp.line and obj.abs_end.col >= sp.col:
obj._start.line += delta.line obj._end.line += diff.line
obj._start.col += delta.col obj._end.col += diff.col
elif obj.abs_start.line > old_end.line: elif obj.abs_end.line > sp.line:
obj._start.line += delta.line obj._end.line += diff.line
def _move_line_col_end(obj): if self not in skip:
if obj.abs_end.line == old_end.line and obj.abs_end.col >= old_end.col: _move_end(self)
obj._end.line += delta.line for c in self._childs:
obj._end.col += delta.col if c in skip: continue
elif obj.abs_end.line > old_end.line: _move_start(c)
obj._end.line += delta.line _move_end(c)
if delta.line == 0: for c in self._childs: # TODO: is this needed?
_move_col_end(self) if c.abs_start == self.abs_start and (c._start == c._end):
for c in self._childs: debug("Deleting Child: c: %r" % (c))
if c == child: continue self._del_child(c) # TODO: What about mirrors?
_move_col_start(c)
_move_col_end(c)
else:
_move_line_col_end(self)
for c in self._childs:
if c == child: continue
_move_line_col_start(c)
_move_line_col_end(c)
def _do_edit(self, cmd): def _do_edit(self, cmd):
debug("self: %r, cmd: %r" % (self, cmd)) debug("self: %r, cmd: %r" % (self, cmd))
@ -364,11 +356,16 @@ class TextObject(CheapTotalOrdering):
pos = Position(line, col) pos = Position(line, col)
for c in self._childs: for c in self._childs:
if pos in c.abs_span: abs_span = c.abs_span
c._do_edit(cmd) if pos in abs_span:
return if c._do_edit(cmd):
return True
# We have to handle this ourselves # We have to handle this ourselves
if ctype == "D": if ctype == "D":
if self._start == self._end:
self._parent._del_child(self)
return False
oe = self.abs_end oe = self.abs_end
__del_move_col_end(self) __del_move_col_end(self)
@ -380,7 +377,7 @@ class TextObject(CheapTotalOrdering):
ne = self.abs_end ne = self.abs_end
if self._parent and oe != ne: if self._parent and oe != ne:
self._parent.child_end_moved(self, oe, ne) self._parent.child_end_moved(oe, ne - oe, set((self,)))
else: else:
oe = self.abs_end oe = self.abs_end
__ins_move_col_end(self) __ins_move_col_end(self)
@ -393,7 +390,14 @@ class TextObject(CheapTotalOrdering):
ne = self.abs_end ne = self.abs_end
if self._parent and oe != ne: if self._parent and oe != ne:
self._parent.child_end_moved(self, oe, ne) self._parent.child_end_moved(oe, ne - oe, set((self,)))
for c in self._childs: # TODO: Code duplicate
if c.abs_start == self.abs_start and (c._start == c._end):
debug("Deleting Child: c: %r" % (c))
self._del_child(c) # TODO: What about mirrors?
return True
def edited(self, cmds): def edited(self, cmds):
@ -407,19 +411,20 @@ class TextObject(CheapTotalOrdering):
def update(self): def update(self):
def _update_childs(childs): pass # TODO: remove this function
for idx,c in childs: # def _update_childs(childs):
oldend = Position(c.end.line, c.end.col) # for idx,c in childs:
# oldend = Position(c.end.line, c.end.col)
new_end = c.update() # new_end = c.update()
moved_lines = new_end.line - oldend.line # moved_lines = new_end.line - oldend.line
moved_cols = new_end.col - oldend.col # moved_cols = new_end.col - oldend.col
self._current_text.replace_text(c.start, oldend, c._current_text) # self._current_text.replace_text(c.start, oldend, c._current_text)
self._move_textobjects_behind(c.start, oldend, moved_lines, # self._move_textobjects_behind(c.start, oldend, moved_lines,
moved_cols, idx) # moved_cols, idx)
# _update_childs((idx, c) for idx, c in enumerate(self._childs) if isinstance(c, TabStop)) # _update_childs((idx, c) for idx, c in enumerate(self._childs) if isinstance(c, TabStop))
# _update_childs((idx, c) for idx, c in enumerate(self._childs) if not isinstance(c, TabStop)) # _update_childs((idx, c) for idx, c in enumerate(self._childs) if not isinstance(c, TabStop))
@ -485,28 +490,28 @@ class TextObject(CheapTotalOrdering):
def _do_update(self): def _do_update(self):
pass pass
def _move_textobjects_behind(self, start, end, lines, cols, obj_idx): # def _move_textobjects_behind(self, start, end, lines, cols, obj_idx):
if lines == 0 and cols == 0: # if lines == 0 and cols == 0:
return # return
for idx,m in enumerate(self._childs[obj_idx+1:]): # for idx,m in enumerate(self._childs[obj_idx+1:]):
delta_lines = 0 # delta_lines = 0
delta_cols_begin = 0 # delta_cols_begin = 0
delta_cols_end = 0 # delta_cols_end = 0
if m.start.line > end.line: # if m.start.line > end.line:
delta_lines = lines # delta_lines = lines
elif m.start.line == end.line: # elif m.start.line == end.line:
if m.start.col >= end.col: # if m.start.col >= end.col:
if lines: # if lines:
delta_lines = lines # delta_lines = lines
delta_cols_begin = cols # delta_cols_begin = cols
if m.start.line == m.end.line: # if m.start.line == m.end.line:
delta_cols_end = cols # delta_cols_end = cols
m.start.line += delta_lines # m.start.line += delta_lines
m.end.line += delta_lines # m.end.line += delta_lines
m.start.col += delta_cols_begin # m.start.col += delta_cols_begin
m.end.col += delta_cols_end # m.end.col += delta_cols_end
def _get_tabstop(self, requester, no): def _get_tabstop(self, requester, no):
if no in self._tabstops: if no in self._tabstops:
@ -525,6 +530,12 @@ class TextObject(CheapTotalOrdering):
self._childs.append(c) self._childs.append(c)
self._childs.sort() self._childs.sort()
def _del_child(self,c):
self._childs.remove(c)
if isinstance(c, TabStop):
del self._tabstops[c.no]
def _add_tabstop(self, ts): def _add_tabstop(self, ts):
self._tabstops[ts.no] = ts self._tabstops[ts.no] = ts

View File

@ -788,6 +788,9 @@ class SnippetManager(object):
if len(self._csnippets): if len(self._csnippets):
debug("self._lvb: %r, cb: %r" % (self._lvb, cb)) debug("self._lvb: %r, cb: %r" % (self._lvb, cb))
rv = edit_distance.edit_script(self._lvb, cb) rv = edit_distance.edit_script(self._lvb, cb)
debug("rv: %r" % (rv,))
cv = edit_distance.compactify(rv)
debug("cv: %r" % (cv))
self._csnippets[0].edited(rv) self._csnippets[0].edited(rv)
# debug("rv: %r" % (rv,)) # debug("rv: %r" % (rv,))

View File

@ -4,6 +4,7 @@
import heapq # TODO: overkill. Bucketing is better import heapq # TODO: overkill. Bucketing is better
from collections import defaultdict from collections import defaultdict
import sys import sys
from debug import debug
class GridPoint(object): class GridPoint(object):
"""Docstring for GridPoint """ """Docstring for GridPoint """
@ -58,6 +59,18 @@ def edit_script(a, b):
d[cost + 1].append((x,y+1, nline, ncol, what + (("I", oline, ocol,b[y]),))) d[cost + 1].append((x,y+1, nline, ncol, what + (("I", oline, ocol,b[y]),)))
cost += 1 cost += 1
def compactify(es):
cmds = []
for cmd in es:
ctype, line, col, char = cmd
if (cmds and ctype == "D" and cmds[-1][1] == cmd[1] and cmds[-1][2] == cmd[2] and char != '\n'):
cmds[-1][-1] += char
elif (cmds and ctype == "I" and cmds[-1][1] == cmd[1] and cmds[-1][2]+1 == cmd[2] and char != '\n'):
cmds[-1][-1] += char
else:
cmds.append(list(cmd))
return cmds
def transform(a, cmds): def transform(a, cmds):
buf = a.split("\n") buf = a.split("\n")

360
test.py
View File

@ -551,183 +551,175 @@ class MultilineExpandTestTyping_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts") snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts")
wanted = "Wie Hallo Welt!\nUnd Wie gehtsHuiui! gehts" wanted = "Wie Hallo Welt!\nUnd Wie gehtsHuiui! gehts"
keys = "Wie hallo gehts" + ESC + "bhi" + EX + "Huiui!" keys = "Wie hallo gehts" + ESC + "bhi" + EX + "Huiui!"
class SimpleExpandEndingWithNewline_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "Hallo Welt\n")
keys = "hallo" + EX + "\nAnd more"
wanted = "Hallo Welt\n\nAnd more"
# End: Simple Expands #}}} # End: Simple Expands #}}}
### TabStop Tests {{{# # TabStop Tests {{{#
##class TabStopSimpleReplace_ExceptCorrectResult(_VimTest): class TabStopSimpleReplace_ExceptCorrectResult(_VimTest):
## snippets = ("hallo", "hallo ${0:End} ${1:Beginning}") snippets = ("hallo", "hallo ${0:End} ${1:Beginning}")
## keys = "hallo" + EX + "na" + JF + "Du Nase" keys = "hallo" + EX + "na" + JF + "Du Nase"
## wanted = "hallo Du Nase na" wanted = "hallo Du Nase na"
##class TabStopSimpleReplaceSurrounded_ExceptCorrectResult(_VimTest): class TabStopSimpleReplaceSurrounded_ExceptCorrectResult(_VimTest):
## snippets = ("hallo", "hallo ${0:End} a small feed") snippets = ("hallo", "hallo ${0:End} a small feed")
## keys = "hallo" + EX + "Nase" keys = "hallo" + EX + "Nase"
## wanted = "hallo Nase a small feed" wanted = "hallo Nase a small feed"
##class TabStopSimpleReplaceSurrounded1_ExceptCorrectResult(_VimTest): class TabStopSimpleReplaceSurrounded1_ExceptCorrectResult(_VimTest):
## snippets = ("hallo", "hallo $0 a small feed") snippets = ("hallo", "hallo $0 a small feed")
## keys = "hallo" + EX + "Nase" keys = "hallo" + EX + "Nase"
## wanted = "hallo Nase a small feed" wanted = "hallo Nase a small feed"
##class TabStopSimpleReplaceEndingWithNewline_ExceptCorrectResult(_VimTest): class TabStop_Exit_ExceptCorrectResult(_VimTest):
## snippets = ("hallo", "Hallo Welt\n") snippets = ("echo", "$0 run")
## keys = "hallo" + EX + "\nAnd more" keys = "echo" + EX + "test"
## wanted = "Hallo Welt\n\nAnd more" wanted = "test run"
##
##class ExitTabStop_ExceptCorrectResult(_VimTest): class TabStopNoReplace_ExceptCorrectResult(_VimTest):
## snippets = ("echo", "$0 run") snippets = ("echo", "echo ${1:Hallo}")
## keys = "echo" + EX + "test" keys = "echo" + EX
## wanted = "test run" wanted = "echo Hallo"
##
##class TabStopNoReplace_ExceptCorrectResult(_VimTest): class TabStop_EscapingCharsBackticks(_VimTest):
## snippets = ("echo", "echo ${1:Hallo}") snippets = ("test", r"snip \` literal")
## keys = "echo" + EX keys = "test" + EX
## wanted = "echo Hallo" wanted = "snip ` literal"
## class TabStop_EscapingCharsDollars(_VimTest):
##class TabStop_EscapingCharsBackticks(_VimTest): snippets = ("test", r"snip \$0 $$0 end")
## snippets = ("test", r"snip \` literal") keys = "test" + EX + "hi"
## keys = "test" + EX wanted = "snip $0 $hi end"
## wanted = "snip ` literal" class TabStop_EscapingCharsDollars1(_VimTest):
##class TabStop_EscapingCharsDollars(_VimTest): snippets = ("test", r"a\${1:literal}")
## snippets = ("test", r"snip \$0 $$0 end") keys = "test" + EX
## keys = "test" + EX + "hi" wanted = "a${1:literal}"
## wanted = "snip $0 $hi end" class TabStop_EscapingCharsDollars_BeginningOfLine(_VimTest):
##class TabStop_EscapingCharsDollars1(_VimTest): snippets = ("test", "\n\\${1:literal}")
## snippets = ("test", r"a\${1:literal}") keys = "test" + EX
## keys = "test" + EX wanted = "\n${1:literal}"
## wanted = "a${1:literal}" class TabStop_EscapingCharsDollars_BeginningOfDefinitionText(_VimTest):
##class TabStop_EscapingCharsDollars_BeginningOfLine(_VimTest): snippets = ("test", "\\${1:literal}")
## snippets = ("test", "\n\\${1:literal}") keys = "test" + EX
## keys = "test" + EX wanted = "${1:literal}"
## wanted = "\n${1:literal}" class TabStop_EscapingChars_Backslash(_VimTest):
##class TabStop_EscapingCharsDollars_BeginningOfDefinitionText(_VimTest): snippets = ("test", r"This \ is a backslash!")
## snippets = ("test", "\\${1:literal}") keys = "test" + EX
## keys = "test" + EX wanted = "This \\ is a backslash!"
## wanted = "${1:literal}" class TabStop_EscapingChars_Backslash2(_VimTest):
##class TabStop_EscapingChars_Backslash(_VimTest): snippets = ("test", r"This is a backslash \\ done")
## snippets = ("test", r"This \ is a backslash!") keys = "test" + EX
## keys = "test" + EX wanted = r"This is a backslash \ done"
## wanted = "This \\ is a backslash!" class TabStop_EscapingChars_Backslash3(_VimTest):
##class TabStop_EscapingChars_Backslash2(_VimTest): snippets = ("test", r"These are two backslashes \\\\ done")
## snippets = ("test", r"This is a backslash \\ done") keys = "test" + EX
## keys = "test" + EX wanted = r"These are two backslashes \\ done"
## wanted = r"This is a backslash \ done" class TabStop_EscapingChars_Backslash4(_VimTest):
##class TabStop_EscapingChars_Backslash3(_VimTest): # Test for bug 746446
## snippets = ("test", r"These are two backslashes \\\\ done") snippets = ("test", r"\\$1{$2}")
## keys = "test" + EX keys = "test" + EX + "hello" + JF + "world"
## wanted = r"These are two backslashes \\ done" wanted = r"\hello{world}"
##class TabStop_EscapingChars_Backslash4(_VimTest): class TabStop_EscapingChars_RealLife(_VimTest):
## # Test for bug 746446 snippets = ("test", r"usage: \`basename \$0\` ${1:args}")
## snippets = ("test", r"\\$1{$2}") keys = "test" + EX + "[ -u -v -d ]"
## keys = "test" + EX + "hello" + JF + "world" wanted = "usage: `basename $0` [ -u -v -d ]"
## wanted = r"\hello{world}"
##class TabStop_EscapingChars_RealLife(_VimTest): class TabStopEscapingWhenSelected_ECR(_VimTest):
## snippets = ("test", r"usage: \`basename \$0\` ${1:args}") snippets = ("test", "snip ${1:default}")
## keys = "test" + EX + "[ -u -v -d ]" keys = "test" + EX + ESC + "0ihi"
## wanted = "usage: `basename $0` [ -u -v -d ]" wanted = "hisnip default"
## class TabStopEscapingWhenSelectedSingleCharTS_ECR(_VimTest):
##class TabStopEscapingWhenSelected_ECR(_VimTest): snippets = ("test", "snip ${1:i}")
## snippets = ("test", "snip ${1:default}") keys = "test" + EX + ESC + "0ihi"
## keys = "test" + EX + ESC + "0ihi" wanted = "hisnip i"
## wanted = "hisnip default" class TabStopEscapingWhenSelectedNoCharTS_ECR(_VimTest):
##class TabStopEscapingWhenSelectedSingleCharTS_ECR(_VimTest): snippets = ("test", "snip $1")
## snippets = ("test", "snip ${1:i}") keys = "test" + EX + ESC + "0ihi"
## keys = "test" + EX + ESC + "0ihi" wanted = "hisnip "
## wanted = "hisnip i"
##class TabStopEscapingWhenSelectedNoCharTS_ECR(_VimTest): class TabStopUsingBackspaceToDeleteDefaultValue_ECR(_VimTest):
## snippets = ("test", "snip $1") snippets = ("test", "snip ${1/.+/(?0:matched)/} ${1:default}")
## keys = "test" + EX + ESC + "0ihi" keys = "test" + EX + BS
## wanted = "hisnip " wanted = "snip "
##
##class TabStopUsingBackspaceToDeleteDefaultValue_ECR(_VimTest): class TabStopWithOneChar_ExceptCorrectResult(_VimTest):
## snippets = ("test", "snip ${1/.+/(?0:matched)/} ${1:default}") snippets = ("hallo", "nothing ${1:i} hups")
## keys = "test" + EX + BS keys = "hallo" + EX + "ship"
## wanted = "snip " wanted = "nothing ship hups"
##class TabStopUsingBackspaceToDeleteDefaultValueInFirstTab_ECR(_VimTest):
## sleeptime = 0.09 # Do this very slowly class TabStopTestJumping_ExceptCorrectResult(_VimTest):
## snippets = ("test", "snip ${1/.+/(?0:m1)/} ${2/.+/(?0:m2)/} " snippets = ("hallo", "hallo ${2:End} mitte ${1:Beginning}")
## "${1:default} ${2:def}") keys = "hallo" + EX + JF + "Test" + JF + "Hi"
## keys = "test" + EX + BS + JF + "hi" wanted = "hallo Test mitte BeginningHi"
## wanted = "snip m2 hi" class TabStopTestJumping2_ExceptCorrectResult(_VimTest):
##class TabStopUsingBackspaceToDeleteDefaultValueInSecondTab_ECR(_VimTest): snippets = ("hallo", "hallo $2 $1")
## snippets = ("test", "snip ${1/.+/(?0:m1)/} ${2/.+/(?0:m2)/} " keys = "hallo" + EX + JF + "Test" + JF + "Hi"
## "${1:default} ${2:def}") wanted = "hallo Test Hi"
## keys = "test" + EX + "hi" + JF + BS class TabStopTestJumpingRLExampleWithZeroTab_ExceptCorrectResult(_VimTest):
## wanted = "snip m1 hi " snippets = ("test", "each_byte { |${1:byte}| $0 }")
##class TabStopUsingBackspaceToDeleteDefaultValueTypeSomethingThen_ECR(_VimTest): keys = "test" + EX + JF + "Blah"
## snippets = ("test", "snip ${1/.+/(?0:matched)/} ${1:default}") wanted = "each_byte { |byte| Blah }"
## keys = "test" + EX + BS + "hallo"
## wanted = "snip matched hallo" class TabStopTestJumpingDontJumpToEndIfThereIsTabZero_ExceptCorrectResult(_VimTest):
## snippets = ("hallo", "hallo $0 $1")
##class TabStopWithOneChar_ExceptCorrectResult(_VimTest): keys = "hallo" + EX + "Test" + JF + "Hi" + JF + JF + "du"
## snippets = ("hallo", "nothing ${1:i} hups") wanted = "hallo Hidu Test"
## keys = "hallo" + EX + "ship"
## wanted = "nothing ship hups" class TabStopTestBackwardJumping_ExceptCorrectResult(_VimTest):
## snippets = ("hallo", "hallo ${2:End} mitte${1:Beginning}")
##class TabStopTestJumping_ExceptCorrectResult(_VimTest): keys = "hallo" + EX + "Somelengthy Text" + JF + "Hi" + JB + \
## snippets = ("hallo", "hallo ${2:End} mitte ${1:Beginning}") "Lets replace it again" + JF + "Blah" + JF + JB*2 + JF
## keys = "hallo" + EX + JF + "Test" + JF + "Hi" wanted = "hallo Blah mitteLets replace it again"
## wanted = "hallo Test mitte BeginningHi" class TabStopTestBackwardJumping2_ExceptCorrectResult(_VimTest):
##class TabStopTestJumping2_ExceptCorrectResult(_VimTest): snippets = ("hallo", "hallo $2 $1")
## snippets = ("hallo", "hallo $2 $1") keys = "hallo" + EX + "Somelengthy Text" + JF + "Hi" + JB + \
## keys = "hallo" + EX + JF + "Test" + JF + "Hi" "Lets replace it again" + JF + "Blah" + JF + JB*2 + JF
## wanted = "hallo Test Hi" wanted = "hallo Blah Lets replace it again"
##class TabStopTestJumpingRLExampleWithZeroTab_ExceptCorrectResult(_VimTest):
## snippets = ("test", "each_byte { |${1:byte}| $0 }") class TabStopTestMultilineExpand_ExceptCorrectResult(_VimTest):
## keys = "test" + EX + JF + "Blah" snippets = ("hallo", "hallo $0\nnice $1 work\n$3 $2\nSeem to work")
## wanted = "each_byte { |byte| Blah }" keys ="test hallo World" + ESC + "02f i" + EX + "world" + JF + "try" + \
## JF + "test" + JF + "one more" + JF + JF
##class TabStopTestJumpingDontJumpToEndIfThereIsTabZero_ExceptCorrectResult(_VimTest): wanted = "test hallo one more\nnice world work\n" \
## snippets = ("hallo", "hallo $0 $1") "test try\nSeem to work World"
## keys = "hallo" + EX + "Test" + JF + "Hi" + JF + JF + "du"
## wanted = "hallo Hidu Test" class TabStop_TSInDefaultTextRLExample_OverwriteNone_ECR(_VimTest):
## snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""")
##class TabStopTestBackwardJumping_ExceptCorrectResult(_VimTest): keys = "test" + EX
## snippets = ("hallo", "hallo ${2:End} mitte${1:Beginning}") wanted = """<div id="some_id">\n \n</div>"""
## keys = "hallo" + EX + "Somelengthy Text" + JF + "Hi" + JB + \ class TabStop_TSInDefaultTextRLExample_OverwriteFirst_NoJumpBack(_VimTest):
## "Lets replace it again" + JF + "Blah" + JF + JB*2 + JF snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""")
## wanted = "hallo Blah mitteLets replace it again" keys = "test" + EX + " blah" + JF + "Hallo"
##class TabStopTestBackwardJumping2_ExceptCorrectResult(_VimTest): wanted = """<div blah>\n Hallo\n</div>"""
## snippets = ("hallo", "hallo $2 $1") class TabStop_TSInDefaultTextRLExample_DeleteFirst(_VimTest):
## keys = "hallo" + EX + "Somelengthy Text" + JF + "Hi" + JB + \ snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""")
## "Lets replace it again" + JF + "Blah" + JF + JB*2 + JF keys = "test" + EX + BS + JF + "Hallo"
## wanted = "hallo Blah Lets replace it again" wanted = """<div>\n Hallo\n</div>"""
## class TabStop_TSInDefaultTextRLExample_OverwriteFirstJumpBack(_VimTest):
##class TabStopTestMultilineExpand_ExceptCorrectResult(_VimTest): snippets = ("test", """<div${1: id="${2:some_id}"}>\n $3 $0\n</div>""")
## snippets = ("hallo", "hallo $0\nnice $1 work\n$3 $2\nSeem to work") keys = "test" + EX + "Hi" + JF + "Hallo" + JB + "SomethingElse" + JF + \
## keys ="test hallo World" + ESC + "02f i" + EX + "world" + JF + "try" + \ "Nupl" + JF + "Nox"
## JF + "test" + JF + "one more" + JF + JF wanted = """<divSomethingElse>\n Nupl Nox\n</div>"""
## wanted = "test hallo one more\nnice world work\n" \ class TabStop_TSInDefaultTextRLExample_OverwriteSecond(_VimTest):
## "test try\nSeem to work World" snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""")
## keys = "test" + EX + JF + "no" + JF + "End"
##class TabStop_TSInDefaultTextRLExample_OverwriteNone_ECR(_VimTest): wanted = """<div id="no">\n End\n</div>"""
## snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""") class TabStop_TSInDefaultTextRLExample_OverwriteSecondTabBack(_VimTest):
## keys = "test" + EX snippets = ("test", """<div${1: id="${2:some_id}"}>\n $3 $0\n</div>""")
## wanted = """<div id="some_id">\n \n</div>""" keys = "test" + EX + JF + "no" + JF + "End" + JB + "yes" + JF + "Begin" \
##class TabStop_TSInDefaultTextRLExample_OverwriteFirst(_VimTest): + JF + "Hi"
## snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""") wanted = """<div id="yes">\n Begin Hi\n</div>"""
## keys = "test" + EX + " blah" + JF + "Hallo" class TabStop_TSInDefaultTextRLExample_OverwriteSecondTabBackTwice(_VimTest):
## wanted = """<div blah>\n Hallo\n</div>""" snippets = ("test", """<div${1: id="${2:some_id}"}>\n $3 $0\n</div>""")
##class TabStop_TSInDefaultTextRLExample_DeleteFirst(_VimTest): keys = "test" + EX + JF + "no" + JF + "End" + JB + "yes" + JB + \
## snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""") " allaway" + JF + "Third" + JF + "Last"
## keys = "test" + EX + BS + JF + "Hallo" wanted = """<div allaway>\n Third Last\n</div>"""
## wanted = """<div>\n Hallo\n</div>"""
##class TabStop_TSInDefaultTextRLExample_OverwriteFirstJumpBack(_VimTest): class TabStop_TSInDefaultText_ZeroLengthNested_Overwrite(_VimTest):
## snippets = ("test", """<div${1: id="${2:some_id}"}>\n $3 $0\n</div>""") snippets = ("test", """h${1:a$2b}l""")
## keys = "test" + EX + "Hi" + JF + "Hallo" + JB + "SomethingElse" + JF + \ keys = "test" + EX + JF + "ups" + JF + "End"
## "Nupl" + JF + "Nox" wanted = """haupsblEnd"""
## wanted = """<divSomethingElse>\n Nupl Nox\n</div>"""
##class TabStop_TSInDefaultTextRLExample_OverwriteSecond(_VimTest):
## snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""")
## keys = "test" + EX + JF + "no" + JF + "End"
## wanted = """<div id="no">\n End\n</div>"""
##class TabStop_TSInDefaultTextRLExample_OverwriteSecondTabBack(_VimTest):
## snippets = ("test", """<div${1: id="${2:some_id}"}>\n $3 $0\n</div>""")
## keys = "test" + EX + JF + "no" + JF + "End" + JB + "yes" + JF + "Begin" \
## + JF + "Hi"
## wanted = """<div id="yes">\n Begin Hi\n</div>"""
##class TabStop_TSInDefaultTextRLExample_OverwriteSecondTabBackTwice(_VimTest):
## snippets = ("test", """<div${1: id="${2:some_id}"}>\n $3 $0\n</div>""")
## keys = "test" + EX + JF + "no" + JF + "End" + JB + "yes" + JB + \
## " allaway" + JF + "Third" + JF + "Last"
## wanted = """<div allaway>\n Third Last\n</div>"""
##
##class TabStop_TSInDefaultNested_OverwriteOneJumpBackToOther(_VimTest): ##class TabStop_TSInDefaultNested_OverwriteOneJumpBackToOther(_VimTest):
## snippets = ("test", "hi ${1:this ${2:second ${3:third}}} $4") ## snippets = ("test", "hi ${1:this ${2:second ${3:third}}} $4")
## keys = "test" + EX + JF + "Hallo" + JF + "Ende" ## keys = "test" + EX + JF + "Hallo" + JF + "Ende"
@ -1415,6 +1407,22 @@ class MultilineExpandTestTyping_ExceptCorrectResult(_VimTest):
## snippets = ("test", r"$1 ${1/, */, /g}") ## snippets = ("test", r"$1 ${1/, */, /g}")
## keys = "test" + EX + "a, nice, building" ## keys = "test" + EX + "a, nice, building"
## wanted = "a, nice, building a, nice, building" ## wanted = "a, nice, building a, nice, building"
## class TransformationUsingBackspaceToDeleteDefaultValueInFirstTab_ECR(_VimTest):
## sleeptime = 0.09 # Do this very slowly
## snippets = ("test", "snip ${1/.+/(?0:m1)/} ${2/.+/(?0:m2)/} "
## "${1:default} ${2:def}")
## keys = "test" + EX + BS + JF + "hi"
## wanted = "snip m2 hi"
## class TransformationUsingBackspaceToDeleteDefaultValueInSecondTab_ECR(_VimTest):
## snippets = ("test", "snip ${1/.+/(?0:m1)/} ${2/.+/(?0:m2)/} "
## "${1:default} ${2:def}")
## keys = "test" + EX + "hi" + JF + BS
## wanted = "snip m1 hi "
## class TransformationUsingBackspaceToDeleteDefaultValueTypeSomethingThen_ECR(_VimTest):
## snippets = ("test", "snip ${1/.+/(?0:matched)/} ${1:default}")
## keys = "test" + EX + BS + "hallo"
## wanted = "snip matched hallo"
### End: Transformations #}}} ### End: Transformations #}}}
### ${VISUAL} {{{# ### ${VISUAL} {{{#
##class Visual_NoVisualSelection_Ignore(_VimTest): ##class Visual_NoVisualSelection_Ignore(_VimTest):