Skip to content

Commit

Permalink
fix(diff): Script separator only if items (gitextensions#11745)
Browse files Browse the repository at this point in the history
  • Loading branch information
gerhardol committed May 25, 2024
1 parent 024141c commit 844050a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/GitUI/CommandsDialogs/RevisionDiffControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ private void UpdateStatusOfMenuItems()
blameToolStripMenuItem.Checked = false;
}

DiffContextMenu.AddUserScripts(runScriptToolStripMenuItem, ExecuteCommand, script => script.OnEvent == ScriptEvent.ShowInFileList, UICommands);
toolStripSeparatorScript.Visible = DiffContextMenu.AddUserScripts(runScriptToolStripMenuItem, ExecuteCommand, script => script.OnEvent == ScriptEvent.ShowInFileList, UICommands);
}

private void DiffContextMenu_Opening(object sender, CancelEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public static class UserScriptContextMenuExtensions
/// <param name="hostMenuItem">The menu item user scripts not marked as <see cref="ScriptInfo.AddToRevisionGridContextMenu"/> are added to.</param>
/// <param name="scriptInvoker">The handler that handles user script invocation.</param>
/// <param name="serviceProvider">The DI service provider.</param>
public static void AddUserScripts(this ContextMenuStrip contextMenu, ToolStripMenuItem hostMenuItem, Func<int, bool> scriptInvoker, Func<ScriptInfo, bool> scriptFilterAddDirect, IServiceProvider serviceProvider)
/// <returns><see langword="true"/> if any scripts were added to menus; otherwise <see langword="false"/>.</returns>
public static bool AddUserScripts(this ContextMenuStrip contextMenu, ToolStripMenuItem hostMenuItem, Func<int, bool> scriptInvoker, Func<ScriptInfo, bool> scriptFilterAddDirect, IServiceProvider serviceProvider)
{
ArgumentNullException.ThrowIfNull(contextMenu);
ArgumentNullException.ThrowIfNull(hostMenuItem);
Expand All @@ -34,6 +35,7 @@ public static void AddUserScripts(this ContextMenuStrip contextMenu, ToolStripMe

IHotkeySettingsLoader hotkeySettingsLoader = serviceProvider.GetRequiredService<IHotkeySettingsLoader>();
IReadOnlyList<HotkeyCommand> hotkeys = hotkeySettingsLoader.LoadHotkeys(FormSettings.HotkeySettingsName);
bool itemsAdded = false;

foreach (ScriptInfo script in scripts)
{
Expand Down Expand Up @@ -61,7 +63,11 @@ public static void AddUserScripts(this ContextMenuStrip contextMenu, ToolStripMe
hostMenuItem.DropDown.Items.Add(item);
hostMenuItem.Enable(true);
}

itemsAdded = true;
}

return itemsAdded;
}

/// <summary>
Expand Down

0 comments on commit 844050a

Please sign in to comment.