@@ -640,7 +640,31 @@ private void DecreaseMaxResult()
640
640
/// <param name="isReQuery">Force query even when Query Text doesn't change</param>
641
641
public void ChangeQueryText ( string queryText , bool isReQuery = false )
642
642
{
643
- _ = ChangeQueryTextAsync ( queryText , isReQuery ) ;
643
+ // Must check access so that we will not block the UI thread which causes window visibility issue
644
+ if ( ! Application . Current . Dispatcher . CheckAccess ( ) )
645
+ {
646
+ Application . Current . Dispatcher . Invoke ( ( ) => ChangeQueryText ( queryText , isReQuery ) ) ;
647
+ return ;
648
+ }
649
+
650
+ if ( QueryText != queryText )
651
+ {
652
+ // Change query text first
653
+ QueryText = queryText ;
654
+ // When we are changing query from codes, we should not delay the query
655
+ Query ( false , isReQuery : false ) ;
656
+
657
+ // set to false so the subsequent set true triggers
658
+ // PropertyChanged and MoveQueryTextToEnd is called
659
+ QueryTextCursorMovedToEnd = false ;
660
+ }
661
+ else if ( isReQuery )
662
+ {
663
+ // When we are re-querying, we should not delay the query
664
+ Query ( false , isReQuery : true ) ;
665
+ }
666
+
667
+ QueryTextCursorMovedToEnd = true ;
644
668
}
645
669
646
670
/// <summary>
@@ -1050,7 +1074,18 @@ private bool QueryResultsPreviewed()
1050
1074
1051
1075
public void Query ( bool searchDelay , bool isReQuery = false )
1052
1076
{
1053
- _ = QueryAsync ( searchDelay , isReQuery ) ;
1077
+ if ( QueryResultsSelected ( ) )
1078
+ {
1079
+ _ = QueryResultsAsync ( searchDelay , isReQuery ) ;
1080
+ }
1081
+ else if ( ContextMenuSelected ( ) )
1082
+ {
1083
+ QueryContextMenu ( ) ;
1084
+ }
1085
+ else if ( HistorySelected ( ) )
1086
+ {
1087
+ QueryHistory ( ) ;
1088
+ }
1054
1089
}
1055
1090
1056
1091
private async Task QueryAsync ( bool searchDelay , bool isReQuery = false )
0 commit comments