Skip to content

Commit 87fb7ae

Browse files
authored
Fix missing last opened result due to race condition from plugins that call hide directly (#4408)
1 parent f5097c2 commit 87fb7ae

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,17 @@ private async Task OpenResultAsync(string index)
515515
return;
516516
}
517517

518+
// New history result must be recorded before ExecuteAsync and Hide() is called, otherwise when in 'Empty Last Query' query style mode
519+
// the QueryAsync call will reconstruct the result list without the new item.
520+
// This must happen before ExecuteAsync because some plugin actions call HideMainWindow() inside their action,
521+
// which triggers a home query that reads history before _history.Add would have been called.
522+
// Also, add item to history only if it is from results but not context menu or history.
523+
if (queryResultsSelected)
524+
{
525+
_history.Add(result);
526+
lastHistoryIndex = 1;
527+
}
528+
518529
var hideWindow = false;
519530
var isDialogJumpLeftClick = _isDialogJump && Settings.DialogJumpResultBehaviour == DialogJumpResultBehaviours.LeftClick;
520531

@@ -541,15 +552,6 @@ private async Task OpenResultAsync(string index)
541552
}).ConfigureAwait(false);
542553
}
543554

544-
// New history result must be recorded before Hide() is called, otherwise when in 'Empty Last Query' query style mode
545-
// the QueryAsync call will reconstruct the result list without the new item.
546-
// Also, add item to history only if it is from results but not context menu or history.
547-
if (queryResultsSelected)
548-
{
549-
_history.Add(result);
550-
lastHistoryIndex = 1;
551-
}
552-
553555
// Only hide for query results (not Dialog Jump left-click mode)
554556
if (!isDialogJumpLeftClick && hideWindow)
555557
{

0 commit comments

Comments
 (0)