diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index e03de29..4a9ebcb 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -1401,6 +1401,8 @@ individuals have contributed to UltiSnips (in chronological order): Ches Martin - ches Christian - Oberon00 Andrew Ruder - aeruder + Mathias Fußenegger - mfussenegger + Thank you for your support. diff --git a/pythonx/UltiSnips/_vim.py b/pythonx/UltiSnips/_vim.py index 437cd8f..919b038 100644 --- a/pythonx/UltiSnips/_vim.py +++ b/pythonx/UltiSnips/_vim.py @@ -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\\" % virtual_position( diff --git a/test.py b/test.py index cb7c5b7..7ab9964 100755 --- a/test.py +++ b/test.py @@ -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):