def run(self, edit, command, in_vis=False):
"""Update the current view with the result of calling `undo` or `redo`.
Args:
command (str): 'undo', 'redo', or 'redo_or_repeat'.
in_vis (bool): `True` if we were called from `sublundo_next_node`.
"""
t = util.VIEW_TO_TREE[self.view.id()]['tree']
pos = 0
if command == 'undo':
buf, diff, pos = t.undo()
else:
buf, diff, pos = t.redo()
self.view.replace(edit, sublime.Region(0, self.view.size()), buf)
# Re-position the cursor.
self.view.sel().clear()
self.view.sel().add(sublime.Region(pos))
self.view.show(pos)
p = sublime.active_window().find_output_panel('sublundo')
if all([p, diff, in_vis]):
p.replace(edit, sublime.Region(0, p.size()), diff)
self.view.add_regions(
'sublundo',
[self.view.full_line(pos)],
'invalid',
'',
sublime.DRAW_NO_FILL)
评论列表
文章目录