diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 333ac3652f4..6a4d54f27ab 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -515,8 +515,11 @@ private async Task OpenResultAsync(string index) return; } + var hideWindow = false; + var isDialogJumpLeftClick = _isDialogJump && Settings.DialogJumpResultBehaviour == DialogJumpResultBehaviours.LeftClick; + // For Dialog Jump and left click mode, we need to navigate to the path - if (_isDialogJump && Settings.DialogJumpResultBehaviour == DialogJumpResultBehaviours.LeftClick) + if (isDialogJumpLeftClick) { if (result is DialogJumpResult dialogJumpResult) { @@ -531,26 +534,30 @@ private async Task OpenResultAsync(string index) // For query mode, we execute the result else { - var hideWindow = await result.ExecuteAsync(new ActionContext + hideWindow = await result.ExecuteAsync(new ActionContext { // not null means pressing modifier key + number, should ignore the modifier key SpecialKeyState = index is not null ? SpecialKeyState.Default : GlobalHotkey.CheckModifiers() }).ConfigureAwait(false); - - if (hideWindow) - { - Hide(); - } } - // Record user selected result for result ranking - _userSelectedRecord.Add(result); - // Add item to history only if it is from results but not context menu or history + // New history result must be recorded before Hide() is called, otherwise when in 'Empty Last Query' query style mode + // the QueryAsync call will reconstruct the result list without the new item. + // Also, add item to history only if it is from results but not context menu or history. if (queryResultsSelected) { _history.Add(result); lastHistoryIndex = 1; } + + // Only hide for query results (not Dialog Jump left-click mode) + if (!isDialogJumpLeftClick && hideWindow) + { + Hide(); + } + + // Record user selected result for result ranking + _userSelectedRecord.Add(result); } private static IReadOnlyList DeepCloneResults(IReadOnlyList results, bool isDialogJump, CancellationToken token = default)