add support for selection=old

This commit is contained in:
Mathias Fussenegger 2014-04-30 21:48:52 +02:00
parent e4f2e34fc6
commit da5b124af5
2 changed files with 23 additions and 2 deletions

View File

@ -118,8 +118,6 @@ def select(start, end):
_unmap_select_mode_mapping()
selection = eval("&selection")
if "old" in selection:
raise RuntimeError("selection=old does not work with UltiSnips :(.")
col = col2byte(start.line + 1, start.col)
vim.current.window.cursor = start.line + 1, col
@ -143,6 +141,8 @@ def select(start, end):
move_cmd += "%iG$" % end.line
else:
move_cmd += "%iG%i|" % virtual_position(end.line + 1, end.col)
elif "old" in selection:
move_cmd += "%iG%i|" % virtual_position(end.line + 1, end.col)
else:
move_cmd += "%iG%i|" % virtual_position(end.line + 1, end.col + 1)
move_cmd += "o%iG%i|o\\<c-g>" % virtual_position(

21
test.py
View File

@ -3134,6 +3134,27 @@ class ExclusiveSelection_RealWorldCase_Test(_ES_Base):
// code
}"""
# End: Exclusive Selection #}}}
# Old Selection {{{#
class _OS_Base(_VimTest):
def _extra_options_pre_init(self, vim_config):
vim_config.append("set selection=old")
class OldSelection_SimpleTabstop_Test(_OS_Base):
snippets =("test", "h${1:blah}w $1")
keys = "test" + EX + "ui" + JF
wanted = "huiw ui"
class OldSelection_RealWorldCase_Test(_OS_Base):
snippets = ("for",
"""for ($${1:i} = ${2:0}; $$1 < ${3:count}; $$1${4:++}) {
${5:// code}
}""")
keys = "for" + EX + "k" + JF
wanted = """for ($k = 0; $k < count; $k++) {
// code
}"""
# End: Old Selection #}}}
# Normal mode editing {{{#
# Test for bug #927844
class DeleteLastTwoLinesInSnippet(_VimTest):