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 90b9111
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion XSVim/Properties/AddinInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open MonoDevelop
[<assembly:Addin (
"XSVim",
Namespace = "XSVim",
Version = "0.33.0"
Version = "0.33.1"
)>]

[<assembly:AddinName ("Vim")>]
Expand Down
2 changes: 1 addition & 1 deletion XSVim/Properties/Manifest.addin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Command id = "MonoDevelop.Ide.Commands.EditCommands.Undo"
_label = "_Undo"
icon = "gtk-undo"
_description = "Disable cmd-z (vim)"
_description = "Undo (vim)"
shortcut = "Control|Z"
macShortcut = "Meta|Z" />
</Extension>
Expand Down
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 90b9111

Please sign in to comment.