當前位置: 首頁>>代碼示例>>Python>>正文


Python VisualContentPreserver.conserve_placeholder方法代碼示例

本文整理匯總了Python中UltiSnips.vim_state.VisualContentPreserver.conserve_placeholder方法的典型用法代碼示例。如果您正苦於以下問題:Python VisualContentPreserver.conserve_placeholder方法的具體用法?Python VisualContentPreserver.conserve_placeholder怎麽用?Python VisualContentPreserver.conserve_placeholder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UltiSnips.vim_state.VisualContentPreserver的用法示例。


在下文中一共展示了VisualContentPreserver.conserve_placeholder方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: SnippetManager

# 需要導入模塊: from UltiSnips.vim_state import VisualContentPreserver [as 別名]
# 或者: from UltiSnips.vim_state.VisualContentPreserver import conserve_placeholder [as 別名]

#.........這裏部分代碼省略.........
            # post-jump action on the last tabstop should be able to access
            # snippet instance which is ended just now.
            stack_for_post_jump = self._csnippets[:]

            # If next tab has length 1 and the distance between itself and
            # self._ctab is 1 then there is 1 less CursorMove events.  We
            # cannot ignore next movement in such case.
            ntab_short_and_near = False

            if self._cs:
                snippet_for_action = self._cs
            elif stack_for_post_jump:
                snippet_for_action = stack_for_post_jump[-1]
            else:
                snippet_for_action = None

            if self._cs:
                ntab = self._cs.select_next_tab(backwards)
                if ntab:
                    if self._cs.snippet.has_option('s'):
                        lineno = _vim.buf.cursor.line
                        _vim.buf[lineno] = _vim.buf[lineno].rstrip()
                    _vim.select(ntab.start, ntab.end)
                    jumped = True
                    if (self._ctab is not None
                            and ntab.start - self._ctab.end == Position(0, 1)
                            and ntab.end - ntab.start == Position(0, 1)):
                        ntab_short_and_near = True

                    self._ctab = ntab

                    # Run interpolations again to update new placeholder
                    # values, binded to currently newly jumped placeholder.
                    self._visual_content.conserve_placeholder(self._ctab)
                    self._cs.current_placeholder = \
                        self._visual_content.placeholder
                    self._should_reset_visual = False
                    self._csnippets[0].update_textobjects()
                    self._vstate.remember_buffer(self._csnippets[0])

                    if ntab.number == 0 and self._csnippets:
                        self._current_snippet_is_done()
                else:
                    # This really shouldn't happen, because a snippet should
                    # have been popped when its final tabstop was used.
                    # Cleanup by removing current snippet and recursing.
                    self._current_snippet_is_done()
                    jumped = self._jump(backwards)

            if jumped:
                if self._ctab:
                    self._vstate.remember_position()
                    self._vstate.remember_unnamed_register(self._ctab.current_text)
                if not ntab_short_and_near:
                    self._ignore_movements = True

            if len(stack_for_post_jump) > 0 and ntab is not None:
                with use_proxy_buffer(stack_for_post_jump, self._vstate):
                    snippet_for_action.snippet.do_post_jump(
                        ntab.number,
                        -1 if backwards else 1,
                        stack_for_post_jump,
                        snippet_for_action
                    )

        return jumped
開發者ID:981746,項目名稱:ultisnips,代碼行數:70,代碼來源:snippet_manager.py


注:本文中的UltiSnips.vim_state.VisualContentPreserver.conserve_placeholder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。