Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unregister commands that conflict with vim shortcuts #147

Merged
merged 2 commits into from
Aug 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.37.9"
Version = "0.38.0"
)>]

[<assembly:AddinName ("Vim")>]
Expand Down
34 changes: 33 additions & 1 deletion XSVim/XSVim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,39 @@ open Reflection

[<AutoOpen>]
module VimHelpers =
let dispatchCommand command = IdeApp.CommandService.DispatchCommand command |> ignore
let commandManager = IdeApp.CommandService |> Option.ofObj

let dispatchCommand command =
commandManager
|> Option.iter(fun c -> c.DispatchCommand command |> ignore)

let unregisterConflictingCommands() =
match commandManager with
| Some commandManager' ->
let commands = commandManager'.GetCommands() |> Array.ofSeq
[
"Control+P"
"Control+D"
"Control+U"
"Control+F"
"Control+B"
"Control+W"
"Control+V"
"Control+C"
"Control+R"
"Control+Y"
"Control+E"
"Control+A"
"Control+X"
"Control+N"
"Control+["
]
|> List.iter(fun k ->
commands
|> Array.tryFind(fun command -> command.AccelKey = k)
|> Option.iter commandManager'.UnregisterCommand)
| None -> ()
unregisterConflictingCommands()

let closingBraces = [')'; '}'; ']'] |> set
let openingbraces = ['('; '{'; '[' ] |> set
Expand Down