Skip to content

Conversation

mstv
Copy link
Member

@mstv mstv commented Sep 13, 2024

Fixes #11909

Proposed changes

  1. There are used different ContextMenuStrips for files and for submodules.
    The menu items are added on menu open - and automatically removed from the other menu.
    When re-adding them, the separators must not be created anew (as it is done for _openInVisualStudioSeparator).

  2. Set the visibility of FormCommit.toolStripSeparatorScript as in 844050a (done for all usages of AddUserScripts).

Screenshots

Before

see issue

After

no multiple separators

Test methodology

  • manual

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@mstv mstv self-assigned this Sep 13, 2024
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK. I cannot reproduce in master though

@@ -31,6 +33,8 @@ public sealed partial class FileStatusList : GitModuleControl
private readonly ToolStripItem _openInVisualStudioSeparator = new ToolStripSeparator();
private readonly ToolStripItem _NO_TRANSLATE_openInVisualStudioMenuItem;
private readonly CancellationTokenSequence _reloadSequence = new();
private readonly ToolStripItem _showAllDifferencesSeparator = new ToolStripSeparator() { Name = _showAllDifferencesItemName + "Separator" };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private readonly ToolStripItem _showAllDifferencesSeparator = new ToolStripSeparator() { Name = _showAllDifferencesItemName + "Separator" };
private readonly ToolStripItem _showAllDifferencesSeparator = new ToolStripSeparator() { Name = $"{_showAllDifferencesItemName}Separator" };

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?
It is compile-time constant.
And I would expect that a single concatenation of two (constant) strings is cheaper than string formatting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a premature micro optimisation. I trust the compiler to do the best here.
Interpolated strings are preferred to string concatenations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a premature micro optimisation. I trust the compiler to do the best here.
Interpolated strings are preferred to string concatenations.

  1. I have just moved that code.
  2. I was anticipating your performance argument with which you use to reason the switch to interpolated strings.
    Only in case of a simple concatenation, the + is slightly clearer to me than interpolation.

Though in order to have a simple coding rule, I have changed it as requested.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -22,6 +22,8 @@ namespace GitUI
{
public sealed partial class FileStatusList : GitModuleControl
{
private const string _showAllDifferencesItemName = "ShowDiffForAllParentsText";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private const string _showAllDifferencesItemName = "ShowDiffForAllParentsText";
private const string ShowAllDifferencesItemName = nameof(ShowDiffForAllParentsText);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have followed the naming conventions for private constants:

image

image


There is no such identifier ShowDiffForAllParentsText except in TranslatedStrings.
I have aligned the moved / new identifiers as well.

@RussKie RussKie added this to the 5.0.1 milestone Sep 14, 2024
@mstv mstv merged commit 9b393c6 into gitextensions:master Sep 15, 2024
3 of 4 checks passed
@mstv mstv deleted the fix/files_context_menu branch September 15, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Double context-menu divider for FormCommit's workspace items
4 participants