'Returns all snippets matching the given trigger.
If \'potentially\' is true, returns all that could_match().
If \'autotrigger_only\' is true, function will return only snippets which
are marked with flag \'A\' (should be automatically expanded without
trigger key press).
It\'s handled specially to avoid walking down the list of all snippets,
which can be very slow, because function will be called on each change
made in insert mode.'

def get_matching_snippets(self, trigger, potentially, autotrigger_only, visual_content):

    all_snippets = self._snippets
    if autotrigger_only:
        all_snippets = [s for s in all_snippets if s.has_option('A')]
    if (not potentially):
        return [s for s in all_snippets if s.matches(trigger, visual_content)]
    else:
        return [s for s in all_snippets if s.could_match(trigger)]
