Skip to content

Commit

Permalink
switcher: fix panic when switcher has auto_select = true
Browse files Browse the repository at this point in the history
  • Loading branch information
abenz1267 committed Jan 4, 2025
1 parent 0466aca commit a739be6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion cmd/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.14-git
0.11.14
1 change: 0 additions & 1 deletion internal/state/appstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
type AppState struct {
ActiveItem *int
AutoSelect bool
AutoSelectOld bool
Clipboard modules.Workable
ConfigError error
IsDebug bool
Expand Down
29 changes: 15 additions & 14 deletions internal/ui/interactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,24 +459,25 @@ func handleSwitcher(module string) {
explicits = []modules.Workable{}
explicits = append(explicits, m)

common.items.Splice(0, int(common.items.NItems()))
elements.input.SetObjectProperty("placeholder-text", m.General().Placeholder)
setupSingleModule()
glib.IdleAdd(func() {
common.items.Splice(0, int(common.items.NItems()))
elements.input.SetObjectProperty("placeholder-text", m.General().Placeholder)

if val, ok := layouts[singleModule.General().Name]; ok {
glib.IdleAdd(func() {
setupSingleModule()

if val, ok := layouts[singleModule.General().Name]; ok {
layout = val
setupLayout(singleModule.General().Theme, singleModule.General().ThemeBase)
})
}
}

if elements.input.Text() != "" {
elements.input.SetText("")
} else {
debouncedProcess(process)
}
if elements.input.Text() != "" {
elements.input.SetText("")
} else {
debouncedProcess(process)
}

elements.input.GrabFocus()
elements.input.GrabFocus()
})
}
}
}
Expand Down Expand Up @@ -1014,7 +1015,7 @@ func quit(ignoreEvent bool) {

appstate.IsRunning = false
appstate.IsSingle = false
appstate.AutoSelect = appstate.AutoSelectOld
appstate.AutoSelect = false

historyIndex = 0

Expand Down
6 changes: 0 additions & 6 deletions internal/ui/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,6 @@ func setupSingleModule() {
singleModule = toUse[0]
}

appstate.AutoSelectOld = appstate.AutoSelect

if !appstate.AutoSelect {
appstate.AutoSelect = singleModule.General().AutoSelect
}

glib.IdleAdd(func() {
debouncedProcess = util.NewDebounce(time.Millisecond * time.Duration(singleModule.General().Delay))
})
Expand Down
9 changes: 7 additions & 2 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,13 @@ func afterUI() {

common.selection.SetSelected(0)

if common.items.NItems() == 1 && appstate.AutoSelect {
activateItem(false, false)
if common.items.NItems() == 1 {
entry := gioutil.ObjectValue[util.Entry](common.items.Item(0))
module := findModule(entry.Module, toUse)

if module.General().AutoSelect || appstate.AutoSelect {
activateItem(false, false)
}
}

elements.grid.ScrollTo(0, gtk.ListScrollNone, nil)
Expand Down

0 comments on commit a739be6

Please sign in to comment.