'Expands the given snippet, and handles everything that needs to be
done with it.'

def _do_snippet(self, snippet, before):

    self._setup_inner_state()
    self._snip_expanded_in_action = False
    self._should_update_textobjects = False
    text_before = before
    if snippet.matched:
        text_before = before[:(- len(snippet.matched))]
    with use_proxy_buffer(self._csnippets, self._vstate):
        with self._action_context():
            cursor_set_in_action = snippet.do_pre_expand(self._visual_content.text, self._csnippets)
    if cursor_set_in_action:
        text_before = _vim.buf.line_till_cursor
        before = _vim.buf.line_till_cursor
    with suspend_proxy_edits():
        if self._cs:
            start = Position(_vim.buf.cursor.line, len(text_before))
            end = Position(_vim.buf.cursor.line, len(before))
            if (not cursor_set_in_action):
                edit_actions = [('D', start.line, start.col, snippet.matched), ('I', start.line, start.col, snippet.matched)]
                self._csnippets[0].replay_user_edits(edit_actions)
            si = snippet.launch(text_before, self._visual_content, self._cs.find_parent_for_new_to(start), start, end)
        else:
            start = Position(_vim.buf.cursor.line, len(text_before))
            end = Position(_vim.buf.cursor.line, len(before))
            si = snippet.launch(text_before, self._visual_content, None, start, end)
        self._visual_content.reset()
        self._csnippets.append(si)
        si.update_textobjects()
        with use_proxy_buffer(self._csnippets, self._vstate):
            with self._action_context():
                snippet.do_post_expand(si._start, si._end, self._csnippets)
        self._vstate.remember_buffer(self._csnippets[0])
        if (not self._snip_expanded_in_action):
            self._jump()
        elif (self._cs.current_text != ''):
            self._jump()
        else:
            self._current_snippet_is_done()
        if self._inside_action:
            self._snip_expanded_in_action = True
