@@ -37,6 +37,9 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable
3737 private string _queryTextBeforeLeaveResults ;
3838 private string _ignoredQueryText ; // Used to ignore query text change when switching between context menu and query results
3939
40+ private readonly object _shouldClearExistingResultsLock = new ( ) ;
41+ private bool _shouldClearExistingResults ;
42+
4043 private readonly FlowLauncherJsonStorage < History > _historyItemsStorage ;
4144 private readonly FlowLauncherJsonStorage < UserSelectedRecord > _userSelectedRecordStorage ;
4245 private readonly FlowLauncherJsonStorageTopMostRecord _topMostRecord ;
@@ -1079,8 +1082,6 @@ private bool QueryResultsPreviewed()
10791082
10801083 #region Query
10811084
1082- internal bool ShouldClearExistingResults { get ; set ; }
1083-
10841085 public void QueryResults ( )
10851086 {
10861087 _ = QueryResultsAsync ( false ) ;
@@ -1439,7 +1440,10 @@ await PluginManager.QueryHomeForPluginAsync(plugin, query, token) :
14391440 if ( shouldClearExistingResults )
14401441 {
14411442 // Setup the flag to clear existing results so that ResultsViewModel.NewResults will handle in the next update
1442- ShouldClearExistingResults = true ;
1443+ lock ( _shouldClearExistingResultsLock )
1444+ {
1445+ _shouldClearExistingResults = true ;
1446+ }
14431447 }
14441448 _lastQuery = query ;
14451449 _previousIsHomeQuery = currentIsHomeQuery ;
@@ -1467,7 +1471,10 @@ void QueryHistoryTask(CancellationToken token)
14671471 if ( shouldClearExistingResults )
14681472 {
14691473 // Setup the flag to clear existing results so that ResultsViewModel.NewResults will handle in the next update
1470- ShouldClearExistingResults = true ;
1474+ lock ( _shouldClearExistingResultsLock )
1475+ {
1476+ _shouldClearExistingResults = true ;
1477+ }
14711478 }
14721479 _lastQuery = query ;
14731480 _previousIsHomeQuery = currentIsHomeQuery ;
@@ -1708,6 +1715,20 @@ internal bool ResultsSelected(ResultsViewModel results)
17081715 return selected ;
17091716 }
17101717
1718+ internal bool CheckShouldClearExistingResultsAndReset ( )
1719+ {
1720+ lock ( _shouldClearExistingResultsLock )
1721+ {
1722+ if ( _shouldClearExistingResults )
1723+ {
1724+ _shouldClearExistingResults = false ;
1725+ return true ;
1726+ }
1727+
1728+ return false ;
1729+ }
1730+ }
1731+
17111732 #endregion
17121733
17131734 #region Hotkey
0 commit comments