// This is the current key binding for the command being overridden by an action // By definition, this is the VS key binding (because we're overriding an existing // VS command and using its key bindings) public override ActionShortcut GetOverriddenVsShortcut(IActionDefWithId def) { if (dte == null) { return(null); } // Not sure if we're ever called on a non-UI thread, but better safe than sorry if (!threading.Dispatcher.CheckAccess()) { return(null); } // def.CommandId is the command ID of the ReSharper action. We want the command ID // of the VS command it's overriding var commandId = vsActionDefs.TryGetOverriddenCommandIds(def).FirstOrDefault(); if (commandId == null) { return(null); } var command = VsCommandHelpers.TryGetVsCommandAutomationObject(commandId, dte); if (command == null) { return(null); } return(GetVsShortcut(command)); }
public void Execute(IDataContext context, DelegateExecute nextExecute) { if (IsFSharpFile(context)) { var commandId = VsCommandHelpers.TryMapVsCommandNameToVsCommandID(ExecuteInInteractive, vsCmdNameMapping); if (commandId != null) { vsActionManager.ExecuteVsCommand(commandId); return; } } nextExecute(); }
public CommandBarActionDef(VsShortcutFinder vsShortcutFinder, DTE dte, string actionId, CommandID commandId, CommandBarControl control, CommandBarPopup[] parentPopups) { ActionId = actionId; // Lazily initialise. Talking to the command bar objects is SLOOOOOOOWWWWWW. backingFields = Lazy.Of(() => { Assertion.AssertNotNull(control, "control != null"); var sb = new StringBuilder(); foreach (var popup in parentPopups) { sb.AppendFormat("{0} \u2192 ", popup.Caption); } var fields = new BackingFields { Text = MnemonicStore.RemoveMnemonicMark(control.Caption), Path = MnemonicStore.RemoveMnemonicMark(sb.ToString()) }; var command = VsCommandHelpers.TryGetVsCommandAutomationObject(commandId, dte); var vsShortcut = vsShortcutFinder.GetVsShortcut(command); if (vsShortcut != null) { var details = new ShortcutDetails[vsShortcut.KeyboardShortcuts.Length]; for (int i = 0; i < vsShortcut.KeyboardShortcuts.Length; i++) { var keyboardShortcut = vsShortcut.KeyboardShortcuts[i]; details[i] = new ShortcutDetails(KeyConverter.Convert(keyboardShortcut.Key), keyboardShortcut.Modifiers); } fields.VsShortcut = new ShortcutSequence(details); } return(fields); }, true); }