Skip to content

Commit

Permalink
config: added visibility_threshold to hide items below a fixed score
Browse files Browse the repository at this point in the history
  • Loading branch information
abenz1267 committed Oct 29, 2024
1 parent 4b4b9ee commit fc98fb7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion internal/config/config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"list": {
"max_entries": 50,
"show_initial_entries": true,
"single_click": true
"single_click": true,
"visibility_threshold": 20
},
"search": {
"force_keyboard_focus": true,
Expand Down
9 changes: 5 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,11 @@ type Search struct {
}

type List struct {
Cycle bool `mapstructure:"cycle"`
MaxEntries int `mapstructure:"max_entries"`
ShowInitialEntries bool `mapstructure:"show_initial_entries"`
SingleClick bool `mapstructure:"single_click"`
Cycle bool `mapstructure:"cycle"`
MaxEntries int `mapstructure:"max_entries"`
ShowInitialEntries bool `mapstructure:"show_initial_entries"`
SingleClick bool `mapstructure:"single_click"`
VisibilityThreshold int `mapstructure:"visibility_threshold"`
}

func Get(config string) *Config {
Expand Down
10 changes: 8 additions & 2 deletions internal/ui/interactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,14 @@ func processAsync(ctx context.Context, text string) {
}
}

if e[k].ScoreFinal != 0 {
toPush = append(toPush, e[k])
if toMatch == "" {
if e[k].ScoreFinal != 0 {
toPush = append(toPush, e[k])
}
} else {
if e[k].ScoreFinal > float64(cfg.List.VisibilityThreshold) {
toPush = append(toPush, e[k])
}
}
}

Expand Down

0 comments on commit fc98fb7

Please sign in to comment.