@@ -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 ;
@@ -736,6 +737,9 @@ private ResultsViewModel SelectedResults
736
737
if ( isReturningFromContextMenu )
737
738
{
738
739
_queryText = _queryTextBeforeLeaveResults ;
740
+ // When executing OnPropertyChanged, QueryTextBox_TextChanged1 and Query will be called
741
+ // So we need to ignore it so that we will not call Query again
742
+ _ignoredQueryText = _queryText ;
739
743
OnPropertyChanged ( nameof ( QueryText ) ) ;
740
744
QueryTextCursorMovedToEnd = true ;
741
745
}
@@ -1087,6 +1091,20 @@ public void QueryResults()
1087
1091
1088
1092
public void Query ( bool searchDelay , bool isReQuery = false )
1089
1093
{
1094
+ if ( _ignoredQueryText != null )
1095
+ {
1096
+ if ( _ignoredQueryText == QueryText )
1097
+ {
1098
+ _ignoredQueryText = null ;
1099
+ return ;
1100
+ }
1101
+ else
1102
+ {
1103
+ // If _ignoredQueryText does not match current QueryText, we should still execute Query
1104
+ _ignoredQueryText = null ;
1105
+ }
1106
+ }
1107
+
1090
1108
if ( QueryResultsSelected ( ) )
1091
1109
{
1092
1110
_ = QueryResultsAsync ( searchDelay , isReQuery ) ;
@@ -1192,7 +1210,7 @@ private void QueryHistory()
1192
1210
OriginQuery = new Query { RawQuery = h . Query } ,
1193
1211
Action = _ =>
1194
1212
{
1195
- SelectedResults = Results ;
1213
+ App . API . BackToQueryResults ( ) ;
1196
1214
App . API . ChangeQuery ( h . Query ) ;
1197
1215
return false ;
1198
1216
}
@@ -1518,11 +1536,14 @@ private async Task BuildQueryAsync(IEnumerable<BaseBuiltinShortcutModel> builtIn
1518
1536
}
1519
1537
}
1520
1538
1539
+ // Show expanded builtin shortcuts
1521
1540
if ( queryChanged )
1522
1541
{
1523
- // show expanded builtin shortcuts
1524
- // use private field to avoid infinite recursion
1542
+ // Use private field to avoid infinite recursion
1525
1543
_queryText = queryBuilderTmp . ToString ( ) ;
1544
+ // When executing OnPropertyChanged, QueryTextBox_TextChanged1 and Query will be called
1545
+ // So we need to ignore it so that we will not call Query again
1546
+ _ignoredQueryText = _queryText ;
1526
1547
OnPropertyChanged ( nameof ( QueryText ) ) ;
1527
1548
}
1528
1549
}
@@ -1704,10 +1725,7 @@ public async void Hide()
1704
1725
await CloseExternalPreviewAsync ( ) ;
1705
1726
}
1706
1727
1707
- if ( ! QueryResultsSelected ( ) )
1708
- {
1709
- SelectedResults = Results ;
1710
- }
1728
+ BackToQueryResults ( ) ;
1711
1729
1712
1730
switch ( Settings . LastQueryMode )
1713
1731
{
0 commit comments