diff --git a/Flow.Launcher/Storage/TopMostRecord.cs b/Flow.Launcher/Storage/TopMostRecord.cs index cbd0b88fc..e76c57493 100644 --- a/Flow.Launcher/Storage/TopMostRecord.cs +++ b/Flow.Launcher/Storage/TopMostRecord.cs @@ -12,6 +12,8 @@ namespace Flow.Launcher.Storage internal bool IsTopMost(Result result) { + // origin query is null when user select the context menu item directly of one item from query list + // in this case, we do not need to check if the result is top most if (records.IsEmpty || result.OriginQuery == null || !records.TryGetValue(result.OriginQuery.RawQuery, out var value)) { diff --git a/Flow.Launcher/Storage/UserSelectedRecord.cs b/Flow.Launcher/Storage/UserSelectedRecord.cs index d6405005d..4f62d2b08 100644 --- a/Flow.Launcher/Storage/UserSelectedRecord.cs +++ b/Flow.Launcher/Storage/UserSelectedRecord.cs @@ -51,6 +51,8 @@ namespace Flow.Launcher.Storage private static int GenerateQueryAndResultHashCode(Query query, Result result) { + // query is null when user select the context menu item directly of one item from query list + // so we only need to consider the result if (query == null) { return GenerateResultHashCode(result); diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 2d232ebdd..5c3251bfc 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -396,11 +396,15 @@ namespace Flow.Launcher.ViewModel }) .ConfigureAwait(false); - if (SelectedIsFromQueryResults()) { _userSelectedRecord.Add(result); - _history.Add(result.OriginQuery.RawQuery); + // origin query is null when user select the context menu item directly of one item from query list + // so we don't want to add it to history + if (result.OriginQuery != null) + { + _history.Add(result.OriginQuery.RawQuery); + } lastHistoryIndex = 1; } @@ -985,9 +989,9 @@ namespace Flow.Launcher.ViewModel { List results; - results = PluginManager.GetContextMenusForPlugin(selected); - results.Add(ContextMenuTopMost(selected)); - results.Add(ContextMenuPluginInfo(selected.PluginID)); + results = PluginManager.GetContextMenusForPlugin(selected); + results.Add(ContextMenuTopMost(selected)); + results.Add(ContextMenuPluginInfo(selected.PluginID)); if (!string.IsNullOrEmpty(query)) {