-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
FileStatusList: Reuse context menu separators #11916
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
Conversation
There was a problem hiding this 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" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private readonly ToolStripItem _showAllDifferencesSeparator = new ToolStripSeparator() { Name = _showAllDifferencesItemName + "Separator" }; | |
private readonly ToolStripItem _showAllDifferencesSeparator = new ToolStripSeparator() { Name = $"{_showAllDifferencesItemName}Separator" }; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
- I have just moved that code.
- 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interpolation with constants does not have runtime overhead.
@@ -22,6 +22,8 @@ namespace GitUI | |||
{ | |||
public sealed partial class FileStatusList : GitModuleControl | |||
{ | |||
private const string _showAllDifferencesItemName = "ShowDiffForAllParentsText"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private const string _showAllDifferencesItemName = "ShowDiffForAllParentsText"; | |
private const string ShowAllDifferencesItemName = nameof(ShowDiffForAllParentsText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #11909
Proposed changes
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
).Set the visibility of
FormCommit.toolStripSeparatorScript
as in 844050a (done for all usages ofAddUserScripts
).Screenshots
Before
see issue
After
no multiple separators
Test methodology
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.