From 3a4558baf8dba3cce445b2bedd09da83f2ef4dd0 Mon Sep 17 00:00:00 2001 From: Alexey Bezhan Date: Fri, 4 Mar 2011 23:47:39 +0300 Subject: [PATCH] When listing snippets overwrite only snippets with the same trigger Snippets with overwrite_previous argumetns would cause list_snippets to empty snippets array, which works fine for expansions, but makes it impossible to see all available snippets. Fixed by removing only snippets with the same trigger from the list. --- plugin/UltiSnips/__init__.py | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin/UltiSnips/__init__.py b/plugin/UltiSnips/__init__.py index 9709a90..5c787c3 100644 --- a/plugin/UltiSnips/__init__.py +++ b/plugin/UltiSnips/__init__.py @@ -846,11 +846,15 @@ class SnippetManager(object): found_snippets += self._find_snippets(ft, before, possible) # Search if any of the snippets overwrites the previous - snippets = [] + # Dictionary allows O(1) access for easy overwrites + snippets = {} for s in found_snippets: - if s.overwrites_previous: - snippets = [] - snippets.append(s) + if (s.trigger not in snippets) or s.overwrites_previous: + snippets[s.trigger] = [] + snippets[s.trigger].append(s) + + # Transform dictionary into flat list of snippets + snippets = [item for sublist in snippets.values() for item in sublist] return snippets -- 1.7.4.4