Skip to content

Commit

Permalink
Disable cmd-z. Fixes #92
Browse files Browse the repository at this point in the history
  • Loading branch information
nosami committed Jun 8, 2017
1 parent 1520bf3 commit 3e74281
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
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.27.1"
Version = "0.27.2"
)>]

[<assembly:AddinName ("Vim")>]
Expand Down
8 changes: 8 additions & 0 deletions XSVim/Properties/Manifest.addin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@
<Extension path="/MonoDevelop/Ide/TextEditorExtensions">
<Class class="XSVim.XSVim" />
</Extension>
<Extension path = "/MonoDevelop/Ide/Commands">
<Command id = "MonoDevelop.Ide.Commands.EditCommands.Undo"
_label = "_Undo"
icon = "gtk-undo"
_description = "Disable cmd-z (vim)"
shortcut = "Control|Z"
macShortcut = "Meta|Z" />
</Extension>
</ExtensionModel>
7 changes: 7 additions & 0 deletions XSVim/XSVim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
open System
open System.Collections.Generic
open System.Text.RegularExpressions
open MonoDevelop.Components.Commands
open MonoDevelop.Core
open MonoDevelop.Core.Text
open MonoDevelop.Ide
Expand Down Expand Up @@ -1024,6 +1025,7 @@ type XSVim() =
static let editorStates = Dictionary<string, VimState>()
let mutable disposables : IDisposable list = []
let mutable processingKey = false

member x.FileName = x.Editor.FileName.FullPath.ToString()

override x.Initialize() =
Expand Down Expand Up @@ -1057,6 +1059,7 @@ type XSVim() =
processingKey <- true
let newState, handledKeyPress = Vim.handleKeyPress vimState descriptor x.Editor
processingKey <- false

match newState.statusMessage with
| Some m -> IdeApp.Workbench.StatusBar.ShowMessage m
| _ -> IdeApp.Workbench.StatusBar.ShowReady()
Expand All @@ -1067,6 +1070,10 @@ type XSVim() =
| VisualMode -> false
| _ -> not handledKeyPress

[<CommandUpdateHandler ("MonoDevelop.Ide.Commands.EditCommands.Undo")>]
// Disable cmd-z (see https://github.com/nosami/XSVim/issues/92)
member x.CanUndo(ci:CommandInfo) = ci.Enabled <- false

override x.Dispose() =
base.Dispose()
disposables |> List.iter(fun d -> d.Dispose())

0 comments on commit 3e74281

Please sign in to comment.