From ee194fc2594c5dfe48b1ae0c033d7c87a1917bf2 Mon Sep 17 00:00:00 2001 From: Fredrik Ehnbom Date: Sat, 7 Apr 2012 22:02:16 +0200 Subject: [PATCH 1/3] Undo steps shouldn't enter visual mode. Issue #119 --- Default.sublime-keymap | 2 +- vintage.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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..d78f984 100644 --- a/vintage.py +++ b/vintage.py @@ -750,6 +750,11 @@ def run(self, edit): self.view.run_command("lower_case") self.view.run_command("exit_visual_mode") +class VintageUndo(sublime_plugin.TextCommand): + def run(self, edit): + self.view.run_command("undo") + self.view.sel().clear() + # 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 From dc8a4410b5d1e81b2a23dcd87328ef7a4902e316 Mon Sep 17 00:00:00 2001 From: Fredrik Ehnbom Date: Sun, 8 Apr 2012 07:28:18 +0200 Subject: [PATCH 2/3] Use exit_visual_mode rather than sel().clear() for VintageUndo --- vintage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vintage.py b/vintage.py index d78f984..a6ed4f9 100644 --- a/vintage.py +++ b/vintage.py @@ -753,7 +753,7 @@ def run(self, edit): class VintageUndo(sublime_plugin.TextCommand): def run(self, edit): self.view.run_command("undo") - self.view.sel().clear() + self.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 From 5e3909ae5e8a91155b706bb21468fdcf530ceebf Mon Sep 17 00:00:00 2001 From: Fredrik Ehnbom Date: Sat, 19 May 2012 15:54:45 +0200 Subject: [PATCH 3/3] Made VintageUndo a WindowCommand after discussion with Jon. Solves issue #119 --- vintage.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vintage.py b/vintage.py index a6ed4f9..0cfad5e 100644 --- a/vintage.py +++ b/vintage.py @@ -750,10 +750,13 @@ def run(self, edit): self.view.run_command("lower_case") self.view.run_command("exit_visual_mode") -class VintageUndo(sublime_plugin.TextCommand): - def run(self, edit): - self.view.run_command("undo") - 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