1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
from test.vim_test_case import VimTestCase as _VimTest
from test.constant import EX, ESC
class SnippetPriorities_MultiWordTriggerOverwriteExisting(_VimTest):
snippets = (
("test me", "${1:Hallo}", "Types Hallo"),
("test me", "${1:World}", "Types World"),
("test me", "We overwrite", "Overwrite the two", "", 1),
)
keys = "test me" + EX
wanted = "We overwrite"
class SnippetPriorities_DoNotCareAboutNonMatchings(_VimTest):
snippets = (
("test1", "Hallo", "Types Hallo"),
("test2", "We overwrite", "Overwrite the two", "", 1),
)
keys = "test1" + EX
wanted = "Hallo"
class SnippetPriorities_OverwriteExisting(_VimTest):
snippets = (
("test", "${1:Hallo}", "Types Hallo"),
("test", "${1:World}", "Types World"),
("test", "We overwrite", "Overwrite the two", "", 1),
)
keys = "test" + EX
wanted = "We overwrite"
class SnippetPriorities_OverwriteTwice_ECR(_VimTest):
snippets = (
("test", "${1:Hallo}", "Types Hallo"),
("test", "${1:World}", "Types World"),
("test", "We overwrite", "Overwrite the two", "", 1),
("test", "again", "Overwrite again", "", 2),
)
keys = "test" + EX
wanted = "again"
class SnippetPriorities_OverwriteThenChoose_ECR(_VimTest):
snippets = (
("test", "${1:Hallo}", "Types Hallo"),
("test", "${1:World}", "Types World"),
("test", "We overwrite", "Overwrite the two", "", 1),
("test", "No overwrite", "Not overwritten", "", 1),
)
keys = "test" + EX + "1\n\n" + "test" + EX + "2\n"
wanted = "We overwrite\nNo overwrite"
class SnippetPriorities_AddedHasHigherThanFile(_VimTest):
files = {
"us/all.snippets": r"""
snippet test "Test Snippet" b
This is a test snippet
endsnippet
"""
}
snippets = (("test", "We overwrite", "Overwrite the two", "", 1),)
keys = "test" + EX
wanted = "We overwrite"
class SnippetPriorities_FileHasHigherThanAdded(_VimTest):
files = {
"us/all.snippets": r"""
snippet test "Test Snippet" b
This is a test snippet
endsnippet
"""
}
snippets = (("test", "We do not overwrite", "Overwrite the two", "", -1),)
keys = "test" + EX
wanted = "This is a test snippet"
class SnippetPriorities_FileHasHigherThanAdded_neg_prio(_VimTest):
files = {
"us/all.snippets": r"""
priority -3
snippet test "Test Snippet" b
This is a test snippet
endsnippet
"""
}
snippets = (("test", "We overwrite", "Overwrite the two", "", -5),)
keys = "test" + EX
wanted = "This is a test snippet"
class SnippetPriorities_SimpleClear(_VimTest):
files = {
"us/all.snippets": r"""
priority 1
clearsnippets
priority -1
snippet test "Test Snippet"
Should not expand to this.
endsnippet
"""
}
keys = "test" + EX
wanted = "test" + EX
class SnippetPriorities_SimpleClear2(_VimTest):
files = {
"us/all.snippets": r"""
clearsnippets
snippet test "Test snippet"
Should not expand to this.
endsnippet
"""
}
keys = "test" + EX
wanted = "test" + EX
class SnippetPriorities_ClearedByParent(_VimTest):
files = {
"us/p.snippets": r"""
clearsnippets
""",
"us/c.snippets": r"""
extends p
snippet test "Test snippets"
Should not expand to this.
endsnippet
""",
}
keys = ESC + ":set ft=c\n" + "itest" + EX
wanted = "test" + EX
class SnippetPriorities_ClearedByChild(_VimTest):
files = {
"us/p.snippets": r"""
snippet test "Test snippets"
Should only expand in p.
endsnippet
""",
"us/c.snippets": r"""
extends p
clearsnippets
""",
}
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
|