From dc1ad5b3293c1d538d2ba6b9dfbacf3798be4c48 Mon Sep 17 00:00:00 2001 From: Legend-017 Date: Mon, 20 Jul 2026 18:27:58 +0500 Subject: [PATCH] Fix(spotlight): improve file search query restoration and mode switching (#2887) * fix(spotlight): fix empty results on restoring last file search query - When "remember last query" is enabled and the last query is file search, it shows "no results" until the query is manually modified in full launcher mode. * fix(spotlight): properly restore last selected mode(tab) when enabled in full launcher mode * fix(spotlight): allow file trigger in plugins mode(tab) * fix(spotlight): restore previous mode when clearing '/' file search prefix When the '/' prefix is removed from the query, the controller now correctly reverts to the previous mode instead of remaining stuck in "files" mode. * fix(spotlight): code review fix (cherry picked from commit 367ad5f69a437d8f4758a193c56383be4bf3eebb) --- quickshell/Modals/DankLauncherV2/Controller.qml | 7 ++++++- .../DankLauncherV2/DankLauncherV2ModalStandalone.qml | 11 +++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/quickshell/Modals/DankLauncherV2/Controller.qml b/quickshell/Modals/DankLauncherV2/Controller.qml index ea076a7b9..90fe1f767 100644 --- a/quickshell/Modals/DankLauncherV2/Controller.qml +++ b/quickshell/Modals/DankLauncherV2/Controller.qml @@ -449,7 +449,12 @@ Item { searchQuery = query; requestSearch(); - if (searchMode !== "plugins" && query.startsWith("/")) { + if (autoSwitchedToFiles && !query.startsWith("/")) { + restorePreviousMode(); + return; + } + + if (query.startsWith("/")) { var prefix = Utils.parseFileSearchPrefix(query); var explicitType = prefix && prefix.type !== null ? prefix.type : null; var targetType = explicitType !== null ? explicitType : (SessionData.launcherLastFileSearchType || "all"); diff --git a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml index 39747f749..e9ddd3cc8 100644 --- a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml +++ b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml @@ -174,9 +174,12 @@ Item { spotlightContent.controller.selectedFlatIndex = 0; spotlightContent.controller.selectedItem = null; spotlightContent.controller.historyIndex = -1; - spotlightContent.controller.searchQuery = targetQuery; - - spotlightContent.controller.performSearch(); + if (targetQuery) { + spotlightContent.controller.setSearchQuery(targetQuery); + } else { + spotlightContent.controller.searchQuery = ""; + spotlightContent.controller.performSearch(); + } } if (spotlightContent.resetScroll) { spotlightContent.resetScroll(); @@ -271,7 +274,7 @@ Item { target: spotlightContent?.controller ?? null function onModeChanged(mode, userInitiated) { - if (!userInitiated || !SettingsData.rememberLastMode || (mode !== "all" && mode !== "apps")) + if (!userInitiated || !SettingsData.rememberLastMode) return; SessionData.setLauncherLastMode(mode); }