2014-07-19 11:45:44 -04:00
|
|
|
from test.vim_test_case import VimTestCase as _VimTest
|
2015-02-08 14:34:38 -05:00
|
|
|
from test.constant import EX, ESC
|
2014-07-19 11:45:44 -04:00
|
|
|
|
|
|
|
# Snippet Priority {{{#
|
2015-01-20 15:26:03 -05:00
|
|
|
|
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class SnippetPriorities_MultiWordTriggerOverwriteExisting(_VimTest):
|
|
|
|
snippets = (
|
2015-01-20 15:26:03 -05:00
|
|
|
('test me', '${1:Hallo}', 'Types Hallo'),
|
|
|
|
('test me', '${1:World}', 'Types World'),
|
|
|
|
('test me', 'We overwrite', 'Overwrite the two', '', 1),
|
2014-07-19 11:45:44 -04:00
|
|
|
)
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test me' + EX
|
|
|
|
wanted = 'We overwrite'
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class SnippetPriorities_DoNotCareAboutNonMatchings(_VimTest):
|
|
|
|
snippets = (
|
2015-01-20 15:26:03 -05:00
|
|
|
('test1', 'Hallo', 'Types Hallo'),
|
|
|
|
('test2', 'We overwrite', 'Overwrite the two', '', 1),
|
2014-07-19 11:45:44 -04:00
|
|
|
)
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test1' + EX
|
|
|
|
wanted = 'Hallo'
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class SnippetPriorities_OverwriteExisting(_VimTest):
|
|
|
|
snippets = (
|
2015-01-20 15:26:03 -05:00
|
|
|
('test', '${1:Hallo}', 'Types Hallo'),
|
|
|
|
('test', '${1:World}', 'Types World'),
|
|
|
|
('test', 'We overwrite', 'Overwrite the two', '', 1),
|
2014-07-19 11:45:44 -04:00
|
|
|
)
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX
|
|
|
|
wanted = 'We overwrite'
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class SnippetPriorities_OverwriteTwice_ECR(_VimTest):
|
|
|
|
snippets = (
|
2015-01-20 15:26:03 -05:00
|
|
|
('test', '${1:Hallo}', 'Types Hallo'),
|
|
|
|
('test', '${1:World}', 'Types World'),
|
|
|
|
('test', 'We overwrite', 'Overwrite the two', '', 1),
|
|
|
|
('test', 'again', 'Overwrite again', '', 2),
|
2014-07-19 11:45:44 -04:00
|
|
|
)
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX
|
|
|
|
wanted = 'again'
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class SnippetPriorities_OverwriteThenChoose_ECR(_VimTest):
|
|
|
|
snippets = (
|
2015-01-20 15:26:03 -05:00
|
|
|
('test', '${1:Hallo}', 'Types Hallo'),
|
|
|
|
('test', '${1:World}', 'Types World'),
|
|
|
|
('test', 'We overwrite', 'Overwrite the two', '', 1),
|
|
|
|
('test', 'No overwrite', 'Not overwritten', '', 1),
|
2014-07-19 11:45:44 -04:00
|
|
|
)
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX + '1\n\n' + 'test' + EX + '2\n'
|
|
|
|
wanted = 'We overwrite\nNo overwrite'
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class SnippetPriorities_AddedHasHigherThanFile(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'us/all.snippets': r"""
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet test "Test Snippet" b
|
|
|
|
This is a test snippet
|
|
|
|
endsnippet
|
|
|
|
"""}
|
|
|
|
snippets = (
|
2015-01-20 15:26:03 -05:00
|
|
|
('test', 'We overwrite', 'Overwrite the two', '', 1),
|
2014-07-19 11:45:44 -04:00
|
|
|
)
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX
|
|
|
|
wanted = 'We overwrite'
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
class SnippetPriorities_FileHasHigherThanAdded(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'us/all.snippets': r"""
|
2014-07-19 11:45:44 -04:00
|
|
|
snippet test "Test Snippet" b
|
|
|
|
This is a test snippet
|
|
|
|
endsnippet
|
|
|
|
"""}
|
|
|
|
snippets = (
|
2015-01-20 15:26:03 -05:00
|
|
|
('test', 'We do not overwrite', 'Overwrite the two', '', -1),
|
2014-07-19 11:45:44 -04:00
|
|
|
)
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX
|
|
|
|
wanted = 'This is a test snippet'
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
2015-02-08 14:35:49 -05:00
|
|
|
class SnippetPriorities_FileHasHigherThanAdded_neg_prio(_VimTest):
|
2015-01-20 15:26:03 -05:00
|
|
|
files = { 'us/all.snippets': r"""
|
2014-07-19 11:45:44 -04:00
|
|
|
priority -3
|
|
|
|
snippet test "Test Snippet" b
|
|
|
|
This is a test snippet
|
|
|
|
endsnippet
|
|
|
|
"""}
|
|
|
|
snippets = (
|
2015-01-20 15:26:03 -05:00
|
|
|
('test', 'We overwrite', 'Overwrite the two', '', -5),
|
2014-07-19 11:45:44 -04:00
|
|
|
)
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX
|
|
|
|
wanted = 'This is a test snippet'
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
|
|
|
class SnippetPriorities_SimpleClear(_VimTest):
|
|
|
|
files = {
|
2015-01-20 15:26:03 -05:00
|
|
|
'us/all.snippets': r"""
|
2014-07-26 04:10:22 -04:00
|
|
|
priority 1
|
|
|
|
clearsnippets
|
|
|
|
priority -1
|
|
|
|
snippet test "Test Snippet"
|
|
|
|
Should not expand to this.
|
|
|
|
endsnippet
|
|
|
|
"""
|
|
|
|
}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX
|
|
|
|
wanted = 'test' + EX
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
|
|
|
class SnippetPriorities_SimpleClear2(_VimTest):
|
|
|
|
files = {
|
2015-01-20 15:26:03 -05:00
|
|
|
'us/all.snippets': r"""
|
2014-07-26 04:10:22 -04:00
|
|
|
clearsnippets
|
|
|
|
snippet test "Test snippet"
|
|
|
|
Should not expand to this.
|
|
|
|
endsnippet
|
|
|
|
"""
|
|
|
|
}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = 'test' + EX
|
|
|
|
wanted = 'test' + EX
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
|
|
|
class SnippetPriorities_ClearedByParent(_VimTest):
|
|
|
|
files = {
|
2015-01-20 15:26:03 -05:00
|
|
|
'us/p.snippets': r"""
|
2014-07-26 04:10:22 -04:00
|
|
|
clearsnippets
|
|
|
|
""",
|
2015-01-20 15:26:03 -05:00
|
|
|
'us/c.snippets': r"""
|
2014-07-26 04:10:22 -04:00
|
|
|
extends p
|
|
|
|
snippet test "Test snippets"
|
|
|
|
Should not expand to this.
|
|
|
|
endsnippet
|
|
|
|
"""
|
|
|
|
}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = ESC + ':set ft=c\n' + 'itest' + EX
|
|
|
|
wanted = 'test' + EX
|
|
|
|
|
2014-07-26 04:10:22 -04:00
|
|
|
|
|
|
|
class SnippetPriorities_ClearedByChild(_VimTest):
|
|
|
|
files = {
|
2015-01-20 15:26:03 -05:00
|
|
|
'us/p.snippets': r"""
|
2014-07-26 04:10:22 -04:00
|
|
|
snippet test "Test snippets"
|
|
|
|
Should only expand in p.
|
|
|
|
endsnippet
|
|
|
|
""",
|
2015-01-20 15:26:03 -05:00
|
|
|
'us/c.snippets': r"""
|
2014-07-26 04:10:22 -04:00
|
|
|
extends p
|
|
|
|
clearsnippets
|
|
|
|
"""
|
|
|
|
}
|
2015-01-20 15:26:03 -05:00
|
|
|
keys = (ESC + ':set ft=p\n' + 'itest' + EX + '\n' +
|
|
|
|
ESC + ':set ft=c\n' + 'itest' + EX + ESC + ':set ft=p')
|
|
|
|
wanted = 'Should only expand in p.\ntest' + EX
|
2014-07-26 04:10:22 -04:00
|
|
|
|
2014-07-19 11:45:44 -04:00
|
|
|
# End: Snippet Priority #}}}
|