Fix null exception when result is from context menu & Add documents

This commit is contained in:
Jack251970 2025-01-26 20:45:58 +08:00
parent 00de8611e1
commit 95c8475c43
3 changed files with 13 additions and 5 deletions

View file

@ -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))
{

View file

@ -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);

View file

@ -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<Result> 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))
{