From 1b3ecf4a85bf116e086869b2aa17e5cd118cbf0d Mon Sep 17 00:00:00 2001 From: Stanislav Seletskiy Date: Mon, 27 Apr 2015 15:42:21 +0600 Subject: [PATCH] priority test, docs & fmt fixes --- doc/UltiSnips.txt | 6 ++---- test/test_ContextSnippets.py | 16 ++++++++++++++++ test/test_UltiSnipFunc.py | 3 ++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index 8cf3fbb..33dcbf8 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -1333,10 +1333,8 @@ endsnippet That snippet will expand to 'return err' only if the previous line is starting from 'if err' prefix. -Note: context snippets prioritized over non-context ones. So, if there are -two snippets with the same trigger, and one of them is context snippet and -it's expression evaluates to 'True', then context snippet will be used for -expansion and first will be ignored. +Note: context snippets prioritized over non-context ones. It makes possible to +use non-context snippets as fallback, if no context matched: ------------------- SNIP ------------------- snippet i "if ..." b diff --git a/test/test_ContextSnippets.py b/test/test_ContextSnippets.py index b99936f..ae5a77f 100644 --- a/test/test_ContextSnippets.py +++ b/test/test_ContextSnippets.py @@ -85,3 +85,19 @@ class ContextSnippets_SnippetPriority(_VimTest): if true { // pass }""" + + +class ContextSnippets_PriorityKeyword(_VimTest): + files = { 'us/all.snippets': r""" + snippet i "desc" "True" e + a + endsnippet + + priority 100 + snippet i + b + endsnippet + """} + + keys = "i" + EX + wanted = "b" diff --git a/test/test_UltiSnipFunc.py b/test/test_UltiSnipFunc.py index bca2fb2..b266b9a 100644 --- a/test/test_UltiSnipFunc.py +++ b/test/test_UltiSnipFunc.py @@ -159,7 +159,8 @@ class MySnippetSource(SnippetSource): if before.endswith('blumba'): return [ UltiSnipsSnippetDefinition( - -100, "blumba", "this is a dynamic snippet", "", "", {}, "blub", None) + -100, "blumba", "this is a dynamic snippet", "", "", {}, "blub", + None) ] return [] """)