From d5b599da3de8e879745945e5e74de74c32a6e23d Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 1 Jan 2026 16:52:58 +0100 Subject: [PATCH] overview: limit search results while typing (less laggy emoji/clipboard search) --- .../ii/modules/ii/overview/SearchWidget.qml | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/dots/.config/quickshell/ii/modules/ii/overview/SearchWidget.qml b/dots/.config/quickshell/ii/modules/ii/overview/SearchWidget.qml index 3dd88aef3..6450ccef0 100644 --- a/dots/.config/quickshell/ii/modules/ii/overview/SearchWidget.qml +++ b/dots/.config/quickshell/ii/modules/ii/overview/SearchWidget.qml @@ -13,7 +13,11 @@ import Quickshell.Io Item { // Wrapper id: root + readonly property string xdgConfigHome: Directories.config + readonly property int typingDebounceInterval: 200 + readonly property int typingResultLimit: 15 // Should be enough to cover the whole view + property string searchingText: LauncherSearch.query property bool showResults: searchingText != "" implicitWidth: searchWidgetContent.implicitWidth + Appearance.sizes.elevationMargin * 2 @@ -178,30 +182,35 @@ Item { // Wrapper } } - model: ScriptModel { - id: model - objectProp: "key" - values: LauncherSearch.results - onValuesChanged: { - root.focusFirstItem(); + Timer { + id: debounceTimer + interval: root.typingDebounceInterval + onTriggered: { + resultModel.values = LauncherSearch.results ?? []; } } + Connections { + target: LauncherSearch + function onResultsChanged() { + resultModel.values = LauncherSearch.results.slice(0, root.typingResultLimit); + root.focusFirstItem(); + debounceTimer.restart(); + } + } + + model: ScriptModel { + id: resultModel + objectProp: "key" + } + delegate: SearchItem { // The selectable item for each search result required property var modelData anchors.left: parent?.left anchors.right: parent?.right entry: modelData - query: StringUtils.cleanOnePrefix(root.searchingText, [ - Config.options.search.prefix.action, - Config.options.search.prefix.app, - Config.options.search.prefix.clipboard, - Config.options.search.prefix.emojis, - Config.options.search.prefix.math, - Config.options.search.prefix.shellCommand, - Config.options.search.prefix.webSearch - ]) + query: StringUtils.cleanOnePrefix(root.searchingText, [Config.options.search.prefix.action, Config.options.search.prefix.app, Config.options.search.prefix.clipboard, Config.options.search.prefix.emojis, Config.options.search.prefix.math, Config.options.search.prefix.shellCommand, Config.options.search.prefix.webSearch]) } } }