@@ -883,10 +883,11 @@ class WoxLauncherController extends GetxController {
883883 // and then the query result is received which will expand the windows height. so it will causes window flicker
884884 clearQueryResultsTimer.cancel ();
885885
886- // If app is hidden (e.g. tray query will trigger change query first then showapp), clear immediately so old results won't flash when shown.
886+ final currentQueryId = query.queryId;
887887 final isVisible = await windowManager.isVisible ();
888+ // If app is hidden (e.g. tray query will trigger change query first then showapp), clear immediately so old results won't flash when shown.
888889 if (! isVisible) {
889- clearQueryResults (traceId);
890+ await clearQueryResults (traceId);
890891 Logger .instance.debug (traceId, "clear query results immediately because window is hidden" );
891892 } else {
892893 // delay clear results, otherwise windows height will shrink immediately,
@@ -903,6 +904,11 @@ class WoxLauncherController extends GetxController {
903904 }
904905
905906 clearQueryResultsTimer = Timer (Duration (milliseconds: clearQueryResultDelay), () {
907+ if (currentQuery.value.queryId != currentQueryId) return ;
908+
909+ final hasResultsNow = activeResultViewController.items.isNotEmpty && activeResultViewController.items.first.value.data.queryId == currentQueryId;
910+ if (isCurrentQueryReturned || hasResultsNow) return ;
911+
906912 clearQueryResults (traceId);
907913 });
908914 }
@@ -971,7 +977,7 @@ class WoxLauncherController extends GetxController {
971977 showApp (msg.traceId, ShowAppParams .fromJson (msg.data));
972978 responseWoxWebsocketRequest (msg, true , null );
973979 } else if (msg.method == "ChangeQuery" ) {
974- onQueryChanged (msg.traceId, PlainQuery .fromJson (msg.data), "receive change query from wox" , moveCursorToEnd: true );
980+ await onQueryChanged (msg.traceId, PlainQuery .fromJson (msg.data), "receive change query from wox" , moveCursorToEnd: true );
975981 focusQueryBox ();
976982 responseWoxWebsocketRequest (msg, true , null );
977983 } else if (msg.method == "RefreshQuery" ) {
0 commit comments