From 90b9111f112612ed2db17b3f3cfbff64206193f8 Mon Sep 17 00:00:00 2001 From: nosami Date: Fri, 23 Jun 2017 06:21:09 +0100 Subject: [PATCH] Reinstate cmd-z. Now uses vim undo group. Re #15 --- XSVim/Properties/AddinInfo.fs | 2 +- XSVim/Properties/Manifest.addin.xml | 2 +- XSVim/XSVim.fs | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/XSVim/Properties/AddinInfo.fs b/XSVim/Properties/AddinInfo.fs index 2c123b7..cedcdf5 100644 --- a/XSVim/Properties/AddinInfo.fs +++ b/XSVim/Properties/AddinInfo.fs @@ -5,7 +5,7 @@ open MonoDevelop [] [] diff --git a/XSVim/Properties/Manifest.addin.xml b/XSVim/Properties/Manifest.addin.xml index bf5edf4..3f4620c 100644 --- a/XSVim/Properties/Manifest.addin.xml +++ b/XSVim/Properties/Manifest.addin.xml @@ -9,7 +9,7 @@ diff --git a/XSVim/XSVim.fs b/XSVim/XSVim.fs index 241b5b5..789d220 100755 --- a/XSVim/XSVim.fs +++ b/XSVim/XSVim.fs @@ -1196,10 +1196,10 @@ module Vim = match state.mode, keyPress.KeyChar with | _, c when keyPress.ModifierKeys = ModifierKeys.Control -> state.keys @ [sprintf "" c], None + | _, 'z' when keyPress.ModifierKeys = ModifierKeys.Command -> + state.keys @ ["u"], None | NotInsertMode, c when keyPress.KeyChar <> '\000' -> state.keys @ [c |> string], None - //| ExMode, c when keyPress.KeyChar <> '\000' -> - //state.keys @ [c |> string], None | _ -> match keyPress.SpecialKey with | SpecialKey.Escape -> [""], None @@ -1282,7 +1282,14 @@ type XSVim() = override x.KeyPress descriptor = match descriptor.ModifierKeys with - | ModifierKeys.Command -> false + | ModifierKeys.Control + | ModifierKeys.Command when descriptor.KeyChar = 'z' -> + // cmd-z uses the vim undo group + let vimState = editorStates.[x.FileName] + vimState.undoGroup |> Option.iter(fun d -> d.Dispose()) + EditActions.Undo x.Editor + false + | ModifierKeys.Command when descriptor.KeyChar <> 'z' -> false | _ -> let vimState = editorStates.[x.FileName] let oldState = vimState @@ -1302,7 +1309,7 @@ type XSVim() = | _ -> not handledKeyPress [] - // Disable cmd-z (see https://github.com/nosami/XSVim/issues/92) + // We handle cmd-z ourselves to use the vim undo stack member x.CanUndo(ci:CommandInfo) = ci.Enabled <- false override x.Dispose() =