Skip to content

Commit

Permalink
Merge pull request #2529 from Flow-Launcher/improve-context-menu-resu…
Browse files Browse the repository at this point in the history
…lts-2

Improve context menu results
  • Loading branch information
taooceros authored Mar 31, 2024
2 parents 62a7d9a + 3b8fc29 commit 4721b97
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
25 changes: 25 additions & 0 deletions Flow.Launcher.Plugin/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,31 @@ public override string ToString()
return Title + SubTitle + Score;
}

/// <summary>
/// Clones the current result
/// </summary>
public Result Clone()
{
return new Result
{
Title = Title,
SubTitle = SubTitle,
ActionKeywordAssigned = ActionKeywordAssigned,
CopyText = CopyText,
AutoCompleteText = AutoCompleteText,
IcoPath = IcoPath,
RoundedIcon = RoundedIcon,
Icon = Icon,
Glyph = Glyph,
Action = Action,
AsyncAction = AsyncAction,
Score = Score,
TitleHighlightData = TitleHighlightData,
OriginQuery = OriginQuery,
PluginDirectory = PluginDirectory
};
}

/// <summary>
/// Additional data associated with this result
/// </summary>
Expand Down
17 changes: 2 additions & 15 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -688,20 +688,7 @@ private void QueryContextMenu()
List<Result> results;
if (selected == lastContextMenuResult)
{
// Use copy to keep the original results unchanged
results = lastContextMenuResults.ConvertAll(result => new Result
{
Title = result.Title,
SubTitle = result.SubTitle,
IcoPath = result.IcoPath,
PluginDirectory = result.PluginDirectory,
Action = result.Action,
ContextData = result.ContextData,
Glyph = result.Glyph,
OriginQuery = result.OriginQuery,
Score = result.Score,
AsyncAction = result.AsyncAction,
});
results = lastContextMenuResults;
}
else
{
Expand All @@ -715,7 +702,7 @@ private void QueryContextMenu()

if (!string.IsNullOrEmpty(query))
{
var filtered = results.Where
var filtered = results.Select(x => x.Clone()).Where
(
r =>
{
Expand Down

0 comments on commit 4721b97

Please sign in to comment.