当前位置: 首页>>代码示例>>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;未经允许,请勿转载。