Skip to content

Commit

Permalink
Fixes #8146 "Keyboard navigation : Enter Key should open a recent rep…
Browse files Browse the repository at this point in the history
…ository"
  • Loading branch information
lhiginbotham committed Oct 10, 2020
1 parent fcd7957 commit 5d3c8c6
Showing 1 changed file with 35 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ protected virtual void OnModuleChanged(GitModuleEventArgs args)
handler?.Invoke(this, args);
}

protected override bool ProcessDialogKey(Keys keyData)
{
if (keyData == Keys.Enter)
{
return TryOpenSelectedRepository();
}

return base.ProcessDialogKey(keyData);
}

private List<string> GetCategories()
{
return GetRepositories()
Expand Down Expand Up @@ -587,23 +597,7 @@ private void listView1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
var selected = GetSelectedRepository();
if (selected == null)
{
return;
}

if (_controller.IsValidGitWorkingDir(selected.Path))
{
OnModuleChanged(new GitModuleEventArgs(new GitModule(selected.Path)));
return;
}

if (_controller.RemoveInvalidRepository(selected.Path))
{
ShowRecentRepositories();
return;
}
TryOpenSelectedRepository();
}
else if (e.Button == MouseButtons.Right)
{
Expand Down Expand Up @@ -862,5 +856,29 @@ private void OnDragEnter(object sender, DragEventArgs e)
}
}
}

// returns false only if no repository is selected
private bool TryOpenSelectedRepository()
{
var selected = GetSelectedRepository();
if (selected == null)
{
return false;
}

if (_controller.IsValidGitWorkingDir(selected.Path))
{
OnModuleChanged(new GitModuleEventArgs(new GitModule(selected.Path)));
return true;
}

if (_controller.RemoveInvalidRepository(selected.Path))
{
ShowRecentRepositories();
return true;
}

return true;
}
}
}

0 comments on commit 5d3c8c6

Please sign in to comment.