2014-07-19 11:45:44 -04:00
|
|
|
from test.vim_test_case import VimTestCase as _VimTest
|
|
|
|
from test.constant import *
|
|
|
|
|
2015-12-09 08:59:50 -05:00
|
|
|
|
|
|
|
def check_required_vim_version(test):
|
|
|
|
if test.vim_flavor == 'neovim':
|
|
|
|
return None
|
2016-09-16 16:48:54 -04:00
|
|
|
if not test.vim.has_version(7, 4, 1):
|
2015-12-09 08:59:50 -05:00
|
|
|
return 'Vim newer than 7.4.1 is required'
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
# Undo of Snippet insertion {{{#
|
2015-01-20 15:26:03 -05:00
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class Undo_RemoveMultilineSnippet(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
snippets = ('test', 'Hello\naaa ${1} bbb\nWorld')
|
2015-04-25 13:34:06 -04:00
|
|
|
keys = 'test' + EX + ESC + 'u'
|
|
|
|
wanted = 'test'
|
2015-01-20 15:26:03 -05:00
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04: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'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
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' + \
|
2015-04-25 13:34:06 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04: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}")
|
2015-04-25 13:34:06 -04:00
|
|
|
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'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
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'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class DeleteSnippetInsertion1(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
snippets = ('test', r"$1${1/(.*)/(?0::.)/}")
|
2015-04-25 13:34:06 -04:00
|
|
|
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'
|
2014-07-19 11:45:44 -04:00
|
|
|
# End: Undo of Snippet insertion #}}}
|
|
|
|
|
|
|
|
# Normal mode editing {{{#
|
|
|
|
# Test for bug #927844
|
2015-01-20 15:26:03 -05:00
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class DeleteLastTwoLinesInSnippet(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
snippets = ('test', '$1hello\nnice\nworld')
|
|
|
|
keys = 'test' + EX + ESC + 'j2dd'
|
|
|
|
wanted = 'hello'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
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'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
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'
|
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
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'
|
2014-07-19 11:45:44 -04:00
|
|
|
|
|
|
|
# End: Normal mode editing #}}}
|
|
|
|
|
|
|
|
# Pressing BS in TabStop {{{#
|
|
|
|
# Test for Bug #774917
|
2015-01-20 15:26:03 -05:00
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04: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'
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
|
|
|
|
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'
|
2014-07-19 11:45:44 -04:00
|
|
|
# End: Pressing BS in TabStop #}}}
|
2015-12-08 02:40:31 -05:00
|
|
|
|
|
|
|
class UpdateModifiedSnippetWithoutCursorMove(_VimTest):
|
2015-12-09 08:59:50 -05:00
|
|
|
skip_if = check_required_vim_version
|
2015-12-08 02:40:31 -05:00
|
|
|
snippets = ('test', '${1:one}(${2:xxx})${3:three}')
|
|
|
|
keys = 'test' + EX + 'aaaaa' + JF + BS + JF + '3333'
|
|
|
|
wanted = 'aaaaa()3333'
|
|
|
|
|
|
|
|
class UpdateModifiedSnippetWithoutCursorMove2(_VimTest):
|
2015-12-09 08:59:50 -05:00
|
|
|
skip_if = check_required_vim_version
|
2015-12-08 02:40:31 -05:00
|
|
|
snippets = ('test', '''\
|
|
|
|
private function ${1:functionName}(${2:arguments}):${3:Void}
|
|
|
|
{
|
|
|
|
${VISUAL}$0
|
|
|
|
}''')
|
|
|
|
keys = 'test' + EX + 'a' + JF + BS + JF + 'Int' + JF + 'body'
|
|
|
|
wanted = '''\
|
|
|
|
private function a():Int
|
|
|
|
{
|
|
|
|
body
|
|
|
|
}'''
|