Skip to content

Commit 1b3e036

Browse files
committed
Fix quick switch window show issue
1 parent 89283ef commit 1b3e036

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Flow.Launcher.Infrastructure/QuickSwitch/QuickSwitch.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,10 @@ uint dwmsEventTime
384384
// Show quick switch window after navigating the path
385385
else
386386
{
387-
NavigateDialogPath(hwnd, true, () => InvokeShowQuickSwitchWindow(dialogWindowChanged));
387+
if (!NavigateDialogPath(hwnd, true, () => InvokeShowQuickSwitchWindow(dialogWindowChanged)))
388+
{
389+
InvokeShowQuickSwitchWindow(dialogWindowChanged);
390+
}
388391
}
389392
}
390393
else
@@ -519,26 +522,26 @@ public static void JumpToPath(nint hwnd, string path, Action action = null)
519522
JumpToPath(dialogWindowTab, path, false, action);
520523
}
521524

522-
private static void NavigateDialogPath(HWND hwnd, bool auto = false, Action action = null)
525+
private static bool NavigateDialogPath(HWND hwnd, bool auto = false, Action action = null)
523526
{
524-
if (hwnd == HWND.Null) return;
527+
if (hwnd == HWND.Null) return false;
525528

526529
var dialogWindow = GetDialogWindow(hwnd);
527-
if (dialogWindow == null) return;
530+
if (dialogWindow == null) return false;
528531

529532
var dialogWindowTab = dialogWindow.GetCurrentTab();
530-
if (dialogWindowTab == null) return;
533+
if (dialogWindowTab == null) return false;
531534

532535
// Get explorer path
533536
string path;
534537
lock (_lastExplorerLock)
535538
{
536539
path = _lastExplorer?.GetExplorerPath();
537540
}
538-
if (string.IsNullOrEmpty(path)) return;
541+
if (string.IsNullOrEmpty(path)) return false;
539542

540543
// Jump to path
541-
JumpToPath(dialogWindowTab, path, auto, action);
544+
return JumpToPath(dialogWindowTab, path, auto, action);
542545
}
543546

544547
private static IQuickSwitchDialogWindow GetDialogWindow(HWND hwnd)
@@ -574,9 +577,9 @@ private static IQuickSwitchDialogWindow GetDialogWindow(HWND hwnd)
574577
}
575578

576579
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD101:Avoid unsupported async delegates", Justification = "<Pending>")]
577-
private static void JumpToPath(IQuickSwitchDialogWindowTab dialog, string path, bool auto = false, Action action = null)
580+
private static bool JumpToPath(IQuickSwitchDialogWindowTab dialog, string path, bool auto = false, Action action = null)
578581
{
579-
if (!CheckPath(path, out var isFile)) return;
582+
if (!CheckPath(path, out var isFile)) return false;
580583

581584
var t = new Thread(async () =>
582585
{
@@ -586,6 +589,7 @@ private static void JumpToPath(IQuickSwitchDialogWindowTab dialog, string path,
586589
var timeOut = !SpinWait.SpinUntil(() => Win32Helper.GetForegroundWindowHWND() == dialogHandle, 1000);
587590
if (timeOut)
588591
{
592+
action?.Invoke();
589593
return;
590594
}
591595

@@ -645,7 +649,7 @@ private static void JumpToPath(IQuickSwitchDialogWindowTab dialog, string path,
645649
action?.Invoke();
646650
});
647651
t.Start();
648-
return;
652+
return true;
649653

650654
static bool CheckPath(string path, out bool file)
651655
{

0 commit comments

Comments
 (0)