ex_commands.py 文件源码

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

项目:VintageousPlus 作者: trishume 项目源码 文件源码
def replace_confirming(self, edit, pattern, compiled_rx, replacement,
                replace_count, target_region):
        last_row = row_at(self.view, target_region.b - 1)
        start = target_region.begin()

        while True:
            match = self.view.find(pattern, start)

            # no match or match out of range -- stop
            if (match == R(-1)) or (row_at(self.view, match.a) > last_row):
                self.view.show(first_sel(self.view).begin())
                return

            size_before = self.view.size()

            with adding_regions(self.view, 's_confirm', [match], 'comment'):
                self.view.show(match.a, True)
                if sublime.ok_cancel_dialog("Confirm replacement?"):
                    text = self.view.substr(match)
                    substituted = re.sub(compiled_rx, replacement, text, count=replace_count)
                    self.view.replace(edit, match, substituted)

            start = match.b + (self.view.size() - size_before)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号