Skip to content

Commit

Permalink
Restore from minimized: Configurable avoid async Git
Browse files Browse the repository at this point in the history
Add an experimental setting to not run git-ls-files when the
window is minimized on activation, as async commands when
minimized seem to block the app from being restored.

Rename configuration added in gitextensions#10119 to
deactivate at upgrade as this setting may give a negative
experience after gitextensions#10802 mostly fixes the problem.
  • Loading branch information
gerhardol committed Apr 1, 2023
1 parent 5e79d32 commit 66bf6d3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
9 changes: 7 additions & 2 deletions GitCommands/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2005,9 +2005,14 @@ public static bool WriteErrorLog
}

// Set manually in settings file
public static bool WorkaroundRestoreFromMinimize
public static bool WorkaroundActivateFromMinimize
{
get => GetBool("WorkaroundRestoreFromMinimize", false);
get => GetBool("WorkaroundActivateFromMinimize", false);
}

public static bool GitAsyncWhenMinimized
{
get => GetBool("GitAsyncWhenMinimized", true);
}

private static IEnumerable<(string name, string value)> GetSettingsFromRegistry()
Expand Down
3 changes: 2 additions & 1 deletion GitUI/CommandsDialogs/FormBrowse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,8 @@ private void OnActivate()
notificationBarBisectInProgress.RefreshBisect();

// check if we are in the middle of an action (merge/rebase/etc.)
notificationBarGitActionInProgress.RefreshGitAction();
notificationBarGitActionInProgress.RefreshGitAction(
checkForConflicts: AppSettings.GitAsyncWhenMinimized || (WindowState != FormWindowState.Minimized));
}

private void UpdateStashCount()
Expand Down
12 changes: 8 additions & 4 deletions GitUI/UserControls/InteractiveGitActionControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ public void RefreshBisect()
SetGitAction(GitAction.None, false);
}

public void RefreshGitAction()
/// <summary>
/// Refresh the banner in the revision grid after reactivation.
/// </summary>
/// <param name="checkForConflicts">Allow running Git command to check for conflicts.</param>
public void RefreshGitAction(bool checkForConflicts)
{
// get the current state of the repo

Expand All @@ -72,9 +76,9 @@ public void RefreshGitAction()
try
{
// This command can be executed seemingly in the background (selecting Browse),
// do not notify the user (this can occur if Git is upgraded)
// The command also occasionally fails when "reactivating" WSL Git.
hasConflicts = Module.InTheMiddleOfConflictedMerge(throwOnErrorExit: false);
// do not notify the user (this can occur if Git is upgraded).
// Running Git commands async when restoring may fail.
hasConflicts = checkForConflicts && Module.InTheMiddleOfConflictedMerge(throwOnErrorExit: false);
}
catch (Win32Exception)
{
Expand Down
4 changes: 2 additions & 2 deletions ResourceManager/GitExtensionsFormBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ protected override void WndProc(ref Message m)
if (m.Msg == NativeMethods.WM_ACTIVATEAPP && m.WParam != IntPtr.Zero)
{
OnApplicationActivated();
if (WindowState == FormWindowState.Minimized && Owner is null && AppSettings.WorkaroundRestoreFromMinimize)
if (WindowState == FormWindowState.Minimized && Owner is null && AppSettings.WorkaroundActivateFromMinimize)
{
// Changed behavior from .NET4 to .NET5, application occasionally requires explicit "restore" in Taskbar.
// Application occasionally requires explicit "restore" in Taskbar.
// See https://github.com/gitextensions/gitextensions/pull/10119.
Trace.WriteLine("WindowState is unexpectedly Minimized in OnApplicationActivated(), restoring.");
WindowState = FormWindowState.Normal;
Expand Down

0 comments on commit 66bf6d3

Please sign in to comment.