diff --git a/Flow.Launcher/Storage/LastOpenedHistoryResult.cs b/Flow.Launcher/Storage/LastOpenedHistoryResult.cs
index 90d47a4d7..4a4257048 100644
--- a/Flow.Launcher/Storage/LastOpenedHistoryResult.cs
+++ b/Flow.Launcher/Storage/LastOpenedHistoryResult.cs
@@ -60,26 +60,37 @@ public class LastOpenedHistoryResult : Result
}
///
- /// Creates a deep copy of .
+ /// Selectively creates a deep copy of the required properties for .
+ /// This copy should be independent of original and full isolated.
///
/// A new containing the same required data.
- public LastOpenedHistoryResult Copy()
+ public LastOpenedHistoryResult DeepCopy()
{
-
+ // queryValue and glyphValue are captured to ensure they are correctly referenced in the Action delegate.
+ var queryValue = Query;
+ var glyphValue = this.Glyph;
return new LastOpenedHistoryResult
{
Title = this.Title,
SubTitle = this.SubTitle,
PluginID = this.PluginID,
Query = this.Query,
- OriginQuery = this.OriginQuery,
+ OriginQuery = new Query { TrimmedQuery = Query },
RecordKey = this.RecordKey,
IcoPath = this.IcoPath,
PluginDirectory = this.PluginDirectory,
- Action = this.Action,
- AsyncAction = this.AsyncAction,
- Glyph = this.Glyph,
+ // Used for Query History style reopening
+ Action = _ =>
+ {
+ App.API.BackToQueryResults();
+ App.API.ChangeQuery(queryValue);
+ return false;
+ },
+ //Used for Last Opened History style reopening, currently need to be assigned at MainViewModel.cs
+ AsyncAction = null,
+ Glyph = new GlyphInfo(this.Glyph.FontFamily, this.Glyph.Glyph),
ExecutedDateTime = this.ExecutedDateTime
+ // Note: Other properties are left as default — copy if needed.
};
}
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 844adf4c4..53ee68e01 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -1333,7 +1333,7 @@ namespace Flow.Launcher.ViewModel
foreach (var item in historyItems)
{
- var copiedItem = item.Copy();
+ var copiedItem = item.DeepCopy();
// Subtitle has datetime which can cause duplicates when saving.
copiedItem.SubTitle = Localize.lastExecuteTime(item.ExecutedDateTime);
// Empty PluginID so the source of last opened history results won't be updated, these results are meant to be temporary copy.