@@ -34,6 +34,7 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable
34
34
private bool _isQueryRunning ;
35
35
private Query _lastQuery ;
36
36
private string _queryTextBeforeLeaveResults ;
37
+ private string _ignoredQueryText = null ;
37
38
38
39
private readonly FlowLauncherJsonStorage < History > _historyItemsStorage ;
39
40
private readonly FlowLauncherJsonStorage < UserSelectedRecord > _userSelectedRecordStorage ;
@@ -730,6 +731,9 @@ private ResultsViewModel SelectedResults
730
731
if ( isReturningFromContextMenu )
731
732
{
732
733
_queryText = _queryTextBeforeLeaveResults ;
734
+ // When executing OnPropertyChanged, QueryTextBox_TextChanged1 and Query will be called
735
+ // So we need to ignore it so that we will not call Query again
736
+ _ignoredQueryText = _queryText ;
733
737
OnPropertyChanged ( nameof ( QueryText ) ) ;
734
738
QueryTextCursorMovedToEnd = true ;
735
739
}
@@ -1076,6 +1080,20 @@ private bool QueryResultsPreviewed()
1076
1080
1077
1081
public void Query ( bool searchDelay , bool isReQuery = false )
1078
1082
{
1083
+ if ( _ignoredQueryText != null )
1084
+ {
1085
+ if ( _ignoredQueryText == QueryText )
1086
+ {
1087
+ _ignoredQueryText = null ;
1088
+ return ;
1089
+ }
1090
+ else
1091
+ {
1092
+ // If _ignoredQueryText does not match current QueryText, we should still execute Query
1093
+ _ignoredQueryText = null ;
1094
+ }
1095
+ }
1096
+
1079
1097
if ( QueryResultsSelected ( ) )
1080
1098
{
1081
1099
_ = QueryResultsAsync ( searchDelay , isReQuery ) ;
@@ -1170,7 +1188,7 @@ private void QueryHistory()
1170
1188
OriginQuery = new Query { RawQuery = h . Query } ,
1171
1189
Action = _ =>
1172
1190
{
1173
- SelectedResults = Results ;
1191
+ App . API . BackToQueryResults ( ) ;
1174
1192
App . API . ChangeQuery ( h . Query ) ;
1175
1193
return false ;
1176
1194
}
@@ -1414,11 +1432,14 @@ private async Task BuildQueryAsync(IEnumerable<BaseBuiltinShortcutModel> builtIn
1414
1432
}
1415
1433
}
1416
1434
1435
+ // Show expanded builtin shortcuts
1417
1436
if ( queryChanged )
1418
1437
{
1419
- // show expanded builtin shortcuts
1420
- // use private field to avoid infinite recursion
1438
+ // Use private field to avoid infinite recursion
1421
1439
_queryText = queryBuilderTmp . ToString ( ) ;
1440
+ // When executing OnPropertyChanged, QueryTextBox_TextChanged1 and Query will be called
1441
+ // So we need to ignore it so that we will not call Query again
1442
+ _ignoredQueryText = _queryText ;
1422
1443
OnPropertyChanged ( nameof ( QueryText ) ) ;
1423
1444
}
1424
1445
}
@@ -1600,10 +1621,7 @@ public async void Hide()
1600
1621
await CloseExternalPreviewAsync ( ) ;
1601
1622
}
1602
1623
1603
- if ( ! QueryResultsSelected ( ) )
1604
- {
1605
- SelectedResults = Results ;
1606
- }
1624
+ BackToQueryResults ( ) ;
1607
1625
1608
1626
switch ( Settings . LastQueryMode )
1609
1627
{
0 commit comments