UltiSnips/test/test_Editing.py

123 lines
3.3 KiB
Python
Raw Normal View History

from test.vim_test_case import VimTestCase as _VimTest
from test.constant import *
# Undo of Snippet insertion {{{#
2015-01-20 15:26:03 -05:00
class Undo_RemoveMultilineSnippet(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', 'Hello\naaa ${1} bbb\nWorld')
keys = 'test' + EX + ESC + 'u'
wanted = 'test'
2015-01-20 15:26:03 -05:00
class Undo_RemoveEditInTabstop(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', '$1 Hello\naaa ${1} bbb\nWorld')
keys = 'hello test' + EX + 'upsi' + ESC + 'hh' + 'iabcdef' + ESC + 'u'
wanted = 'hello upsi Hello\naaa upsi bbb\nWorld'
class Undo_RemoveWholeSnippet(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', 'Hello\n${1:Hello}World')
keys = 'first line\n\n\n\n\n\nthird line' + \
ESC + '3k0itest' + EX + ESC + 'u6j'
wanted = 'first line\n\n\ntest\n\n\nthird line'
class Undo_RemoveOneSnippetByTime(_VimTest):
snippets = ('i', 'if:\n\t$1')
keys = 'i' + EX + 'i' + EX + ESC + 'u'
wanted = 'if:\n\ti'
class Undo_RemoveOneSnippetByTime2(_VimTest):
snippets = ('i', 'if:\n\t$1')
keys = 'i' + EX + 'i' + EX + ESC + 'uu'
wanted = 'if:\n\t'
class Undo_ChangesInPlaceholder(_VimTest):
snippets = ('i', 'if $1:\n\t$2')
keys = 'i' + EX + 'asd' + JF + ESC + 'u'
wanted = 'if :\n\t'
class Undo_CompletelyUndoSnippet(_VimTest):
snippets = ('i', 'if $1:\n\t$2')
# undo 'feh'
# undo 'asd'
# undo snippet expansion
# undo entering of 'i'
keys = 'i' + EX + 'asd' + JF + 'feh' + ESC + 'uuuu'
wanted = ''
2015-01-20 15:26:03 -05:00
class JumpForward_DefSnippet(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = (
'test',
"${1}\n`!p snip.rv = '\\n'.join(t[1].split())`\n\n${0:pass}")
keys = 'test' + EX+ 'a b c' + JF + 'shallnot'
2015-01-20 15:26:03 -05:00
wanted = 'a b c\na\nb\nc\n\nshallnot'
class DeleteSnippetInsertion0(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', '${1:hello} $1')
keys = 'test' + EX + ESC + 'Vkx' + 'i\nworld\n'
wanted = 'world'
class DeleteSnippetInsertion1(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', r"$1${1/(.*)/(?0::.)/}")
keys = 'test' + EX + ESC + 'u'
wanted = 'test'
2015-05-04 14:17:58 -04:00
class DoNotCrashOnUndoAndJumpInNestedSnippet(_VimTest):
snippets = ('test', r"if $1: $2")
keys = 'test' + EX + 'a' + JF + 'test' + EX + ESC + 'u' + JF
wanted = 'if a: test'
# End: Undo of Snippet insertion #}}}
# Normal mode editing {{{#
# Test for bug #927844
2015-01-20 15:26:03 -05:00
class DeleteLastTwoLinesInSnippet(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', '$1hello\nnice\nworld')
keys = 'test' + EX + ESC + 'j2dd'
wanted = 'hello'
class DeleteCurrentTabStop1_JumpBack(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', '${1:hi}\nend')
keys = 'test' + EX + ESC + 'ddi' + JB
wanted = 'end'
class DeleteCurrentTabStop2_JumpBack(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', '${1:hi}\n${2:world}\nend')
keys = 'test' + EX + JF + ESC + 'ddi' + JB + 'hello'
wanted = 'hello\nend'
class DeleteCurrentTabStop3_JumpAround(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', '${1:hi}\n${2:world}\nend')
keys = 'test' + EX + JF + ESC + 'ddkji' + JB + 'hello' + JF + 'world'
wanted = 'hello\nendworld'
# End: Normal mode editing #}}}
# Pressing BS in TabStop {{{#
# Test for Bug #774917
2015-01-20 15:26:03 -05:00
class Backspace_TabStop_Zero(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', 'A${1:C} ${0:DDD}', 'This is Case 1')
keys = 'test' + EX + 'A' + JF + BS + 'BBB'
wanted = 'AA BBB'
class Backspace_TabStop_NotZero(_VimTest):
2015-01-20 15:26:03 -05:00
snippets = ('test', 'A${1:C} ${2:DDD}', 'This is Case 1')
keys = 'test' + EX + 'A' + JF + BS + 'BBB'
wanted = 'AA BBB'
# End: Pressing BS in TabStop #}}}