@@ -35,6 +35,7 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable
35
35
private Query _progressQuery ; // Used for QueryResultAsync
36
36
private Query _updateQuery ; // Used for ResultsUpdated
37
37
private string _queryTextBeforeLeaveResults ;
38
+ private string _ignoredQueryText = null ;
38
39
39
40
private readonly FlowLauncherJsonStorage < History > _historyItemsStorage ;
40
41
private readonly FlowLauncherJsonStorage < UserSelectedRecord > _userSelectedRecordStorage ;
@@ -734,6 +735,9 @@ private ResultsViewModel SelectedResults
734
735
if ( isReturningFromContextMenu )
735
736
{
736
737
_queryText = _queryTextBeforeLeaveResults ;
738
+ // When executing OnPropertyChanged, QueryTextBox_TextChanged1 and Query will be called
739
+ // So we need to ignore it so that we will not call Query again
740
+ _ignoredQueryText = _queryText ;
737
741
OnPropertyChanged ( nameof ( QueryText ) ) ;
738
742
QueryTextCursorMovedToEnd = true ;
739
743
}
@@ -1080,6 +1084,20 @@ private bool QueryResultsPreviewed()
1080
1084
1081
1085
public void Query ( bool searchDelay , bool isReQuery = false )
1082
1086
{
1087
+ if ( _ignoredQueryText != null )
1088
+ {
1089
+ if ( _ignoredQueryText == QueryText )
1090
+ {
1091
+ _ignoredQueryText = null ;
1092
+ return ;
1093
+ }
1094
+ else
1095
+ {
1096
+ // If _ignoredQueryText does not match current QueryText, we should still execute Query
1097
+ _ignoredQueryText = null ;
1098
+ }
1099
+ }
1100
+
1083
1101
if ( QueryResultsSelected ( ) )
1084
1102
{
1085
1103
_ = QueryResultsAsync ( searchDelay , isReQuery ) ;
@@ -1174,7 +1192,7 @@ private void QueryHistory()
1174
1192
OriginQuery = new Query { RawQuery = h . Query } ,
1175
1193
Action = _ =>
1176
1194
{
1177
- SelectedResults = Results ;
1195
+ App . API . BackToQueryResults ( ) ;
1178
1196
App . API . ChangeQuery ( h . Query ) ;
1179
1197
return false ;
1180
1198
}
@@ -1433,11 +1451,14 @@ private async Task BuildQueryAsync(IEnumerable<BaseBuiltinShortcutModel> builtIn
1433
1451
}
1434
1452
}
1435
1453
1454
+ // Show expanded builtin shortcuts
1436
1455
if ( queryChanged )
1437
1456
{
1438
- // show expanded builtin shortcuts
1439
- // use private field to avoid infinite recursion
1457
+ // Use private field to avoid infinite recursion
1440
1458
_queryText = queryBuilderTmp . ToString ( ) ;
1459
+ // When executing OnPropertyChanged, QueryTextBox_TextChanged1 and Query will be called
1460
+ // So we need to ignore it so that we will not call Query again
1461
+ _ignoredQueryText = _queryText ;
1441
1462
OnPropertyChanged ( nameof ( QueryText ) ) ;
1442
1463
}
1443
1464
}
@@ -1616,10 +1637,7 @@ public async void Hide()
1616
1637
await CloseExternalPreviewAsync ( ) ;
1617
1638
}
1618
1639
1619
- if ( ! QueryResultsSelected ( ) )
1620
- {
1621
- SelectedResults = Results ;
1622
- }
1640
+ BackToQueryResults ( ) ;
1623
1641
1624
1642
switch ( Settings . LastQueryMode )
1625
1643
{
0 commit comments