Skip to content

Commit b119785

Browse files
committed
Do not query when back from the context menu
1 parent 62e1252 commit b119785

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable
3434
private bool _isQueryRunning;
3535
private Query _lastQuery;
3636
private string _queryTextBeforeLeaveResults;
37+
private string _ignoredQueryText = null;
3738

3839
private readonly FlowLauncherJsonStorage<History> _historyItemsStorage;
3940
private readonly FlowLauncherJsonStorage<UserSelectedRecord> _userSelectedRecordStorage;
@@ -730,6 +731,9 @@ private ResultsViewModel SelectedResults
730731
if (isReturningFromContextMenu)
731732
{
732733
_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;
733737
OnPropertyChanged(nameof(QueryText));
734738
QueryTextCursorMovedToEnd = true;
735739
}
@@ -1076,6 +1080,20 @@ private bool QueryResultsPreviewed()
10761080

10771081
public void Query(bool searchDelay, bool isReQuery = false)
10781082
{
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+
10791097
if (QueryResultsSelected())
10801098
{
10811099
_ = QueryResultsAsync(searchDelay, isReQuery);

0 commit comments

Comments
 (0)