@@ -34,8 +34,6 @@ public partial class MainViewModel : BaseModel, ISavable
3434
3535 private bool _isQueryRunning ;
3636 private Query _lastQuery ;
37- private Result lastContextMenuResult = new Result ( ) ;
38- private List < Result > lastContextMenuResults = new List < Result > ( ) ;
3937 private string _queryTextBeforeLeaveResults ;
4038
4139 private readonly FlowLauncherJsonStorage < History > _historyItemsStorage ;
@@ -398,11 +396,15 @@ private async Task OpenResultAsync(string index)
398396 } )
399397 . ConfigureAwait ( false ) ;
400398
401-
402399 if ( SelectedIsFromQueryResults ( ) )
403400 {
404401 _userSelectedRecord . Add ( result ) ;
405- _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+ }
406408 lastHistoryIndex = 1 ;
407409 }
408410
@@ -986,19 +988,10 @@ private void QueryContextMenu()
986988 if ( selected != null ) // SelectedItem returns null if selection is empty.
987989 {
988990 List < Result > results ;
989- if ( selected == lastContextMenuResult )
990- {
991- results = lastContextMenuResults ;
992- }
993- else
994- {
995- results = PluginManager . GetContextMenusForPlugin ( selected ) ;
996- lastContextMenuResults = results ;
997- lastContextMenuResult = selected ;
998- results . Add ( ContextMenuTopMost ( selected ) ) ;
999- results . Add ( ContextMenuPluginInfo ( selected . PluginID ) ) ;
1000- }
1001991
992+ results = PluginManager . GetContextMenusForPlugin ( selected ) ;
993+ results . Add ( ContextMenuTopMost ( selected ) ) ;
994+ results . Add ( ContextMenuPluginInfo ( selected . PluginID ) ) ;
1002995
1003996 if ( ! string . IsNullOrEmpty ( query ) )
1004997 {
@@ -1273,6 +1266,8 @@ private Result ContextMenuTopMost(Result result)
12731266 {
12741267 _topMostRecord . Remove ( result ) ;
12751268 App . API . ShowMsg ( InternationalizationManager . Instance . GetTranslation ( "success" ) ) ;
1269+ App . API . BackToQueryResults ( ) ;
1270+ App . API . ReQuery ( ) ;
12761271 return false ;
12771272 }
12781273 } ;
@@ -1289,6 +1284,8 @@ private Result ContextMenuTopMost(Result result)
12891284 {
12901285 _topMostRecord . AddOrUpdate ( result ) ;
12911286 App . API . ShowMsg ( InternationalizationManager . Instance . GetTranslation ( "success" ) ) ;
1287+ App . API . BackToQueryResults ( ) ;
1288+ App . API . ReQuery ( ) ;
12921289 return false ;
12931290 }
12941291 } ;
@@ -1377,8 +1374,6 @@ public async void Hide()
13771374 lastHistoryIndex = 1 ;
13781375 // Trick for no delay
13791376 MainWindowOpacity = 0 ;
1380- lastContextMenuResult = new Result ( ) ;
1381- lastContextMenuResults = new List < Result > ( ) ;
13821377
13831378 if ( ExternalPreviewVisible )
13841379 CloseExternalPreview ( ) ;
0 commit comments