Skip to content

Commit

Permalink
Reinstate cmd-z. Now uses vim undo group. Re #15
Browse files Browse the repository at this point in the history
  • Loading branch information
nosami committed Jun 23, 2017
1 parent 84e2686 commit 58e420d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions XSVim/XSVim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,10 +1196,10 @@ module Vim =
match state.mode, keyPress.KeyChar with
| _, c when keyPress.ModifierKeys = ModifierKeys.Control ->
state.keys @ [sprintf "<C-%c>" 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 -> ["<esc>"], None
Expand Down Expand Up @@ -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
Expand All @@ -1302,7 +1309,7 @@ type XSVim() =
| _ -> not handledKeyPress

[<CommandUpdateHandler ("MonoDevelop.Ide.Commands.EditCommands.Undo")>]
// 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() =
Expand Down

0 comments on commit 58e420d

Please sign in to comment.