Skip to content

Commit

Permalink
all: added 'keep_selection' to general module config to avoid selecti…
Browse files Browse the repository at this point in the history
…ng first item on query change
  • Loading branch information
abenz1267 committed Feb 18, 2025
1 parent aae8796 commit 97b76f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/config/config.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ placeholder = "Switcher"
prefix = "/"

[builtins.websearch]
keep_selection = true
weight = 5
icon = "applications-internet"
name = "websearch"
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ type GeneralModule struct {
History bool `koanf:"history"`
HistoryBlacklist []Blacklist `koanf:"history_blacklist"`
Icon string `koanf:"icon"`
KeepSelection bool `koanf:"keep_selection"`
KeepSort bool `koanf:"keep_sort"`
MinChars int `koanf:"min_chars"`
Name string `koanf:"name"`
Expand Down
14 changes: 13 additions & 1 deletion internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,19 @@ func afterUI() {
elements.listPlaceholder.SetVisible(false)
}

common.selection.SetSelected(0)
if len(toUse) == 1 || singleModule != nil {
module := singleModule

if module == nil {
module = toUse[0]
}

if !module.General().KeepSelection {
common.selection.SetSelected(0)
}
} else {
common.selection.SetSelected(0)
}

if common.items.NItems() == 1 {
entry := gioutil.ObjectValue[util.Entry](common.items.Item(0))
Expand Down

0 comments on commit 97b76f6

Please sign in to comment.