Skip to content

Commit

Permalink
Check if focus is where it was initially. Fixes #1899.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbialobr committed Jun 19, 2013
1 parent 094415b commit 188add9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
20 changes: 13 additions & 7 deletions GitUI/CommandsDialogs/FormCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -643,14 +643,20 @@ private void LoadUnstagedOutput(IList<GitItemStatus> allChangedFiles)
if (OnStageAreaLoaded != null)
OnStageAreaLoaded();

if (_loadUnstagedOutputFirstTime && (this.ActiveControl == splitMain))
if (_loadUnstagedOutputFirstTime)
{
if (Unstaged.GitItemStatuses.Any())
Unstaged.Focus();
else if (Staged.GitItemStatuses.Any())
Message.Focus();
else
Amend.Focus();
var fc = this.FindFocusedControl();

if (fc == this.Ok)
{
if (Unstaged.GitItemStatuses.Any())
Unstaged.Focus();
else if (Staged.GitItemStatuses.Any())
Message.Focus();
else
Amend.Focus();
}

_loadUnstagedOutputFirstTime = false;
}
}
Expand Down
12 changes: 12 additions & 0 deletions GitUI/GitUIExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,5 +325,17 @@ public static void InvokeSync(this Control control, SendOrPostCallback action, o
if (!control.IsDisposed)
UISynchronizationContext.Send(checkDisposedAndInvoke, state);
}

public static Control FindFocusedControl(this ContainerControl container)
{
var control = container.ActiveControl;
container = control as ContainerControl;

if (container == null)
return control;
else
return container.FindFocusedControl();
}

}
}

0 comments on commit 188add9

Please sign in to comment.