__init__.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:macos-st-packages 作者: zce 项目源码 文件源码
def update(self, new_phantoms):
            """Update the list of phantoms that exist in the text buffer with their current location."""

            regions = query_phantoms(self.view, [p.id for p in self.phantoms])
            for i in range(len(regions)):
                self.phantoms[i].region = regions[i]

            count = 0
            for p in new_phantoms:
                if not isinstance(p, Phantom):
                    # Convert sublime.Phantom to mdpopups.Phantom
                    p = Phantom(
                        p.region, p.content, p.layout,
                        md=False, css=None, on_navigate=p.on_navigate, wrapper_class=None,
                        template_vars=None, template_env_options=None, nl2br=False
                    )
                    new_phantoms[count] = p
                try:
                    # Phantom already exists, copy the id from the current one
                    idx = self.phantoms.index(p)
                    p.id = self.phantoms[idx].id
                except ValueError:
                    p.id = add_phantom(
                        self.view,
                        self.key,
                        p.region,
                        p.content,
                        p.layout,
                        p.md,
                        p.css,
                        p.on_navigate,
                        p.wrapper_class,
                        p.template_vars,
                        p.template_env_options,
                        p.nl2br
                    )
                count += 1

            for p in self.phantoms:
                # if the region is -1, then it's already been deleted, no need to call erase
                if p not in new_phantoms and p.region != sublime.Region(-1):
                    erase_phantom_by_id(self.view, p.id)

            self.phantoms = new_phantoms
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号