Skip to content

Commit 95c8475

Browse files
committed
Fix null exception when result is from context menu & Add documents
1 parent 00de861 commit 95c8475

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Flow.Launcher/Storage/TopMostRecord.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class TopMostRecord
1212

1313
internal bool IsTopMost(Result result)
1414
{
15+
// origin query is null when user select the context menu item directly of one item from query list
16+
// in this case, we do not need to check if the result is top most
1517
if (records.IsEmpty || result.OriginQuery == null ||
1618
!records.TryGetValue(result.OriginQuery.RawQuery, out var value))
1719
{

Flow.Launcher/Storage/UserSelectedRecord.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ private static int GenerateResultHashCode(Result result)
5151

5252
private static int GenerateQueryAndResultHashCode(Query query, Result result)
5353
{
54+
// query is null when user select the context menu item directly of one item from query list
55+
// so we only need to consider the result
5456
if (query == null)
5557
{
5658
return GenerateResultHashCode(result);

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,15 @@ private async Task OpenResultAsync(string index)
396396
})
397397
.ConfigureAwait(false);
398398

399-
400399
if (SelectedIsFromQueryResults())
401400
{
402401
_userSelectedRecord.Add(result);
403-
_history.Add(result.OriginQuery.RawQuery);
402+
// origin query is null when user select the context menu item directly of one item from query list
403+
// so we don't want to add it to history
404+
if (result.OriginQuery != null)
405+
{
406+
_history.Add(result.OriginQuery.RawQuery);
407+
}
404408
lastHistoryIndex = 1;
405409
}
406410

@@ -985,9 +989,9 @@ private void QueryContextMenu()
985989
{
986990
List<Result> results;
987991

988-
results = PluginManager.GetContextMenusForPlugin(selected);
989-
results.Add(ContextMenuTopMost(selected));
990-
results.Add(ContextMenuPluginInfo(selected.PluginID));
992+
results = PluginManager.GetContextMenusForPlugin(selected);
993+
results.Add(ContextMenuTopMost(selected));
994+
results.Add(ContextMenuPluginInfo(selected.PluginID));
991995

992996
if (!string.IsNullOrEmpty(query))
993997
{

0 commit comments

Comments
 (0)