Skip to content

Commit

Permalink
Allow highlight branch by Alt+Click in the grid (#8452)
Browse files Browse the repository at this point in the history
Expose the same behavior as "Highlight selected branch" in the revision
grid via Alt+Left Click.

Co-authored-by: Gerhard Olsson <gerhardol@users.noreply.github.com>
  • Loading branch information
RussKie and gerhardol committed Jul 28, 2022
1 parent cabe0d2 commit 8eae96e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions GitUI/Translation/English.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -9651,6 +9651,10 @@ See the changes in the commit form.</source>
<source>Go to &amp;parent commit</source>
<target />
</trans-unit>
<trans-unit id="HighlightSelectedBranch.Text">
<source>Highlight selected branch (until refresh)</source>
<target />
</trans-unit>
<trans-unit id="NavigateBackward.Text">
<source>Navigate &amp;backward</source>
<target />
Expand Down Expand Up @@ -9719,10 +9723,6 @@ See the changes in the commit form.</source>
<source>&amp;Toggle between artificial and HEAD commits</source>
<target />
</trans-unit>
<trans-unit id="ToggleHighlightSelectedBranch.Text">
<source>Highlight selected branch (until refresh)</source>
<target />
</trans-unit>
<trans-unit id="TopoOrder.Text">
<source>Arrange c&amp;ommits by topo order (ancestor order)</source>
<target />
Expand Down
12 changes: 8 additions & 4 deletions GitUI/UserControls/RevisionGrid/RevisionGridControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,11 @@ private void OnGridViewMouseClick(object sender, MouseEventArgs e)
{
var hti = _gridView.HitTest(e.X, e.Y);
_latestSelectedRowIndex = hti.RowIndex;

if (Control.ModifierKeys.HasFlag(Keys.Alt))
{
HighlightSelectedBranch();
}
}

private void OnGridViewCellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
Expand Down Expand Up @@ -2429,10 +2434,9 @@ internal CommandStatus ExecuteCommand(Command cmd)
return ExecuteCommand((int)cmd);
}

private void ToggleHighlightSelectedBranch()
private void HighlightSelectedBranch()
{
var revision = GetSelectedRevisions().FirstOrDefault();

GitRevision revision = GetSelectedRevisions().FirstOrDefault();
if (revision is null)
{
return;
Expand Down Expand Up @@ -2870,7 +2874,7 @@ protected override CommandStatus ExecuteCommand(int cmd)
case Command.SelectNextForkPointAsDiffBase: SelectNextForkPointAsDiffBase(); break;
case Command.GoToMergeBase: GoToMergeBase(); break;
case Command.GoToChild: goToChildToolStripMenuItem_Click(); break;
case Command.ToggleHighlightSelectedBranch: ToggleHighlightSelectedBranch(); break;
case Command.ToggleHighlightSelectedBranch: HighlightSelectedBranch(); break;
case Command.NextQuickSearch: _quickSearchProvider.NextResult(down: true); break;
case Command.PrevQuickSearch: _quickSearchProvider.NextResult(down: false); break;
case Command.NavigateBackward:
Expand Down
5 changes: 3 additions & 2 deletions GitUI/UserControls/RevisionGrid/RevisionGridMenuCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,10 @@ Y Draw non relatives gray
},
new MenuCommand
{
Name = "ToggleHighlightSelectedBranch",
Name = "HighlightSelectedBranch",
Text = "Highlight selected branch (until refresh)",
ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGridControl.Command.ToggleHighlightSelectedBranch),
ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGridControl.Command.ToggleHighlightSelectedBranch)
+ $", {Keys.Alt}+{Keys.LButton}",
ExecuteAction = () => _revisionGrid.ExecuteCommand(RevisionGridControl.Command.ToggleHighlightSelectedBranch)
},

Expand Down

0 comments on commit 8eae96e

Please sign in to comment.