diff --git a/Flow.Launcher/Storage/QueryHistory.cs b/Flow.Launcher/Storage/QueryHistory.cs index 21e78f8c7..d612c81d0 100644 --- a/Flow.Launcher/Storage/QueryHistory.cs +++ b/Flow.Launcher/Storage/QueryHistory.cs @@ -70,13 +70,15 @@ namespace Flow.Launcher.Storage LastOpenedHistoryItems.RemoveAt(0); } + // If the last item is the same as the current result, just update the timestamp and the icon path if (LastOpenedHistoryItems.Count > 0 && TryGetLastOpenedHistoryResult(result, out var existingHistoryItem)) { existingHistoryItem.ExecutedDateTime = DateTime.Now; - if (existingHistoryItem.IcoPath != result.IcoPath) + { existingHistoryItem.IcoPath = result.IcoPath; + } } else { @@ -102,17 +104,14 @@ namespace Flow.Launcher.Storage /// Call this after plugins are loaded/initialized. public void UpdateIcoPathAbsolute() { - if (LastOpenedHistoryItems.Count == 0) - return; + if (LastOpenedHistoryItems.Count == 0) return; foreach (var item in LastOpenedHistoryItems) { - if (string.IsNullOrEmpty(item.PluginID)) - continue; + if (string.IsNullOrEmpty(item.PluginID)) continue; var pluginPair = PluginManager.GetPluginForId(item.PluginID); - if (pluginPair == null) - continue; + if (pluginPair == null) continue; item.PluginDirectory = pluginPair.Metadata.PluginDirectory; } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index e91533dfe..c3eeada11 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -355,11 +355,10 @@ namespace Flow.Launcher.ViewModel if (QueryResultsSelected()) { SelectedResults = History; - - if (SelectedResults.Results.Count > 0) + if (History.Results.Count > 0) { - SelectedResults.SelectedIndex = 0; - SelectedResults.SelectedItem = SelectedResults.Results[0]; + History.SelectedIndex = 0; + History.SelectedItem = History.Results[0]; } } else @@ -1331,8 +1330,8 @@ namespace Flow.Launcher.ViewModel { // Items saved to disk are differentiated by Query also, but LastOpened style only cares about unique results historyItems = historyItems - .GroupBy(r => new { r.Title, r.SubTitle, r.PluginID, r.RecordKey }) - .Select(g => g.First()); + .GroupBy(r => new { r.Title, r.SubTitle, r.PluginID, r.RecordKey }) + .Select(g => g.First()); } foreach (var item in historyItems) @@ -1340,11 +1339,16 @@ namespace Flow.Launcher.ViewModel var copiedItem = item.DeepCopy(); if (Settings.HistoryStyle == HistoryStyle.Query) + { copiedItem.Title = Localize.executeQuery(copiedItem.Query); + } + // Subtitle has datetime which can cause duplicates when saving. copiedItem.SubTitle = Localize.lastExecuteTime(copiedItem.ExecutedDateTime); + // Empty PluginID so the source of last opened history results won't be updated, these results are meant to be temporary copy. copiedItem.PluginID = string.Empty; + if (Settings.HistoryStyle == HistoryStyle.LastOpened) { copiedItem.AsyncAction = async c =>