diff --git a/Default.sublime-keymap b/Default.sublime-keymap index faf2e65..a27d062 100644 --- a/Default.sublime-keymap +++ b/Default.sublime-keymap @@ -124,7 +124,7 @@ "context": [{"key": "setting.command_mode"}] }, - { "keys": ["u"], "command": "undo", "context": [{"key": "setting.command_mode"}] }, + { "keys": ["u"], "command": "vintage_undo", "context": [{"key": "setting.command_mode"}] }, { "keys": ["ctrl+r"], "command": "redo", "context": [{"key": "setting.command_mode"}, {"key": "setting.vintage_ctrl_keys"}] diff --git a/vintage.py b/vintage.py index 5c03361..0cfad5e 100644 --- a/vintage.py +++ b/vintage.py @@ -750,6 +750,14 @@ def run(self, edit): self.view.run_command("lower_case") self.view.run_command("exit_visual_mode") +class VintageUndo(sublime_plugin.WindowCommand): + def run(self): + # Needs to be a window command as running the undo command while the + # undo stack is being updated (like being inside of an edit in a + # TextCommand) causes problems + self.window.active_view().run_command("undo") + self.window.active_view().run_command("exit_visual_mode") + # Sequence is used as part of glue_marked_undo_groups: the marked undo groups # are rewritten into a single sequence command, that accepts all the previous # commands