7 failures. Now weeding out abs_start and abs_end
This commit is contained in:
parent
b057d6332e
commit
f1f6e9abff
@ -411,14 +411,27 @@ class TextObject(object):
|
||||
self._del_child(c)
|
||||
|
||||
# We have to handle this ourselves
|
||||
sp = self.abs_start # TODO
|
||||
def _move_end(obj, diff): # TODO: this is code duplication, the other one is buggy!
|
||||
if obj.abs_end < sp: return
|
||||
|
||||
if delta.line >= 0:
|
||||
if obj.abs_end.line == sp.line:
|
||||
obj._end.col += diff.col
|
||||
obj._end.line += diff.line
|
||||
else:
|
||||
obj._end.line += diff.line
|
||||
if obj.abs_end.line == sp.line:
|
||||
obj._end.col += diff.col
|
||||
|
||||
if ctype == "D": # TODO: code duplication
|
||||
assert(self.abs_start != self.abs_end) # Makes no sense to delete in empty textobject
|
||||
|
||||
if char == "\n":
|
||||
delta = Position(-1, 0) # TODO: this feels somehow incorrect:
|
||||
delta = Position(-1, col) # TODO: this feels somehow incorrect:
|
||||
else:
|
||||
delta = Position(0, -len(char))
|
||||
self._end += delta
|
||||
_move_end(self, delta)
|
||||
|
||||
self.child_end_moved(self.abs_end, delta, set((self,)))
|
||||
else:
|
||||
@ -427,8 +440,7 @@ class TextObject(object):
|
||||
delta = Position(1, -col) # TODO: this feels somehow incorrect
|
||||
else:
|
||||
delta = Position(0, len(char))
|
||||
|
||||
self._end += delta
|
||||
_move_end(self, delta)
|
||||
|
||||
self.child_end_moved(old_end, delta, set((self,)))
|
||||
|
||||
|
@ -60,7 +60,7 @@ def edit_script(a, b, sline = 0, scol = 0):
|
||||
|
||||
if x < len(a): # DELETE
|
||||
if (what and what[-1][0] == "D" and what[-1][1] == line and
|
||||
what[-1][2] == col and a[x] != '\n' and
|
||||
what[-1][2] == col and a[x] != '\n' and what[-1][-1] != '\n' and
|
||||
seen[x+1,y] > cost + D_COST // 2
|
||||
):
|
||||
seen[x+1,y] = cost + D_COST // 2
|
||||
@ -76,7 +76,11 @@ def transform(a, cmds):
|
||||
for cmd in cmds:
|
||||
ctype, line, col, char = cmd
|
||||
if ctype == "D":
|
||||
buf[line] = buf[line][:col] + buf[line][col+len(char):]
|
||||
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]
|
||||
elif ctype == "I":
|
||||
buf[line] = buf[line][:col] + char + buf[line][col:]
|
||||
buf = '\n'.join(buf).split('\n')
|
||||
@ -134,6 +138,17 @@ class TestRealLife1(_Base, unittest.TestCase):
|
||||
("I", 0, 11, " "),
|
||||
)
|
||||
|
||||
class TestWithNewline(_Base, unittest.TestCase):
|
||||
a = 'First Line\nSecond Line'
|
||||
b = 'n'
|
||||
wanted = (
|
||||
("D", 0, 0, "First Line"),
|
||||
("D", 0, 0, "\n"),
|
||||
("D", 0, 0, "Second Line"),
|
||||
("I", 0, 0, "n"),
|
||||
)
|
||||
|
||||
|
||||
class TestCheapDelete(_Base, unittest.TestCase):
|
||||
a = 'Vorne hallo Hinten'
|
||||
b = 'Vorne Hinten'
|
||||
|
50
test.py
50
test.py
@ -782,31 +782,31 @@ class TabStop_TSInDefault_MirrorsOutside_OverwriteFirstSwitchNumbers(_VimTest):
|
||||
# keys = "test" + EX + JF + "WORLD" + JF + "End"
|
||||
# wanted = "world = require('WORLD')End"
|
||||
|
||||
##class TabStop_Multiline_Leave(_VimTest):
|
||||
## snippets = ("test", "hi ${1:first line\nsecond line} world" )
|
||||
## keys = "test" + EX
|
||||
## wanted = "hi first line\nsecond line world"
|
||||
##class TabStop_Multiline_Overwrite(_VimTest):
|
||||
## snippets = ("test", "hi ${1:first line\nsecond line} world" )
|
||||
## keys = "test" + EX + "Nothing"
|
||||
## wanted = "hi Nothing world"
|
||||
##class TabStop_Multiline_MirrorInFront_Leave(_VimTest):
|
||||
## snippets = ("test", "hi $1 ${1:first line\nsecond line} world" )
|
||||
## keys = "test" + EX
|
||||
## wanted = "hi first line\nsecond line first line\nsecond line world"
|
||||
##class TabStop_Multiline_MirrorInFront_Overwrite(_VimTest):
|
||||
## snippets = ("test", "hi $1 ${1:first line\nsecond line} world" )
|
||||
## keys = "test" + EX + "Nothing"
|
||||
## wanted = "hi Nothing Nothing world"
|
||||
##class TabStop_Multiline_DelFirstOverwriteSecond_Overwrite(_VimTest):
|
||||
## snippets = ("test", "hi $1 $2 ${1:first line\nsecond line} ${2:Hi} world" )
|
||||
## keys = "test" + EX + BS + JF + "Nothing"
|
||||
## wanted = "hi Nothing Nothing world"
|
||||
##
|
||||
##class TabStopNavigatingInInsertModeSimple_ExceptCorrectResult(_VimTest):
|
||||
## snippets = ("hallo", "Hallo ${1:WELT} ups")
|
||||
## keys = "hallo" + EX + "welt" + 2*ARR_L + "hips" + JF + "end"
|
||||
## wanted = "hallo wehipslt upsend"
|
||||
class TabStop_Multiline_Leave(_VimTest):
|
||||
snippets = ("test", "hi ${1:first line\nsecond line} world" )
|
||||
keys = "test" + EX
|
||||
wanted = "hi first line\nsecond line world"
|
||||
class TabStop_Multiline_Overwrite(_VimTest):
|
||||
snippets = ("test", "hi ${1:first line\nsecond line} world" )
|
||||
keys = "test" + EX + "Nothing"
|
||||
wanted = "hi Nothing world"
|
||||
class TabStop_Multiline_MirrorInFront_Leave(_VimTest):
|
||||
snippets = ("test", "hi $1 ${1:first line\nsecond line} world" )
|
||||
keys = "test" + EX
|
||||
wanted = "hi first line\nsecond line first line\nsecond line world"
|
||||
class TabStop_Multiline_MirrorInFront_Overwrite(_VimTest):
|
||||
snippets = ("test", "hi $1 ${1:first line\nsecond line} world" )
|
||||
keys = "test" + EX + "Nothing"
|
||||
wanted = "hi Nothing Nothing world"
|
||||
class TabStop_Multiline_DelFirstOverwriteSecond_Overwrite(_VimTest):
|
||||
snippets = ("test", "hi $1 $2 ${1:first line\nsecond line} ${2:Hi} world" )
|
||||
keys = "test" + EX + BS + JF + "Nothing"
|
||||
wanted = "hi Nothing Nothing world"
|
||||
|
||||
class TabStopNavigatingInInsertModeSimple_ExceptCorrectResult(_VimTest):
|
||||
snippets = ("hallo", "Hallo ${1:WELT} ups")
|
||||
keys = "hallo" + EX + "haselnut" + 2*ARR_L + "hips" + JF + "end"
|
||||
wanted = "Hallo haselnhipsut upsend"
|
||||
### End: TabStop Tests #}}}
|
||||
### ShellCode Interpolation {{{#
|
||||
##class TabStop_Shell_SimpleExample(_VimTest):
|
||||
|
Loading…
x
Reference in New Issue
Block a user