Skip to content

Commit

Permalink
Display shortcuts assigned to scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mstv committed May 15, 2020
1 parent 5d4b39d commit 3486ba0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion GitUI/CommandsDialogs/UserScriptContextMenuExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using GitUI.Hotkey;
using GitUI.Script;
using ResourceManager;

namespace GitUI.CommandsDialogs
{
public static class UserScriptContextMenuExtensions
{
private static readonly Lazy<IEnumerable<HotkeyCommand>> Hotkeys = new Lazy<IEnumerable<HotkeyCommand>>(()
=> HotkeySettingsManager.LoadHotkeys(FormSettings.HotkeySettingsName));

/// <summary>
/// Appends user scripts to the <paramref name="contextMenu"/>, or under <paramref name="hostMenuItem"/>,
/// if scripts are marked as <see cref="ScriptInfo.AddToRevisionGridContextMenu"/>.
Expand Down Expand Up @@ -60,7 +66,8 @@ void AddOwnScripts()
{
Text = script.Name,
Name = script.Name + "_ownScript",
Image = script.GetIcon()
Image = script.GetIcon(),
ShortcutKeyDisplayString = Hotkeys.Value?.FirstOrDefault(h => h.Name == script.Name)?.KeyData.ToShortcutKeyDisplayString()
};

item.Click += (s, e) =>
Expand Down

0 comments on commit 3486ba0

Please sign in to comment.