Skip to content

Commit

Permalink
misc: entry flag to reset score to 0 explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
abenz1267 committed Mar 23, 2024
1 parent af98bcd commit 986b031
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
13 changes: 5 additions & 8 deletions modules/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ func (a Applications) Entries(_ string) []Entry {
a.entries = parse()
}

for k := range a.entries {
a.entries[k].ScoreFinal = 0
a.entries[k].ScoreFuzzy = 0
}

return a.entries
}

Expand Down Expand Up @@ -95,9 +90,10 @@ func parse() []Entry {

app := Application{
Generic: Entry{
Class: ApplicationsName,
History: true,
Matching: Fuzzy,
Class: ApplicationsName,
History: true,
Matching: Fuzzy,
RecalculateScore: true,
},
Actions: []Entry{},
}
Expand All @@ -117,6 +113,7 @@ func parse() []Entry {
Categories: app.Generic.Categories,
History: app.Generic.History,
HistoryIdentifier: app.Generic.Label,
RecalculateScore: true,
})

isAction = true
Expand Down
12 changes: 4 additions & 8 deletions modules/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ type Commands struct {
}

func (c Commands) Entries(term string) []Entry {
for k := range c.entries {
c.entries[k].ScoreFinal = 0
c.entries[k].ScoreFuzzy = 0
}

return c.entries
}

Expand Down Expand Up @@ -65,9 +60,10 @@ func (cc Commands) Setup(cfg *config.Config) Workable {

for _, v := range entries {
c.entries = append(c.entries, Entry{
Label: v.label,
Sub: "Walker",
Exec: v.exec,
Label: v.label,
Sub: "Walker",
Exec: v.exec,
RecalculateScore: true,
})
}

Expand Down
1 change: 1 addition & 0 deletions modules/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type External struct {
cmd string
transform bool
switcherExclusive bool
recalculateScore bool
}

func (e External) SwitcherExclusive() bool {
Expand Down
1 change: 1 addition & 0 deletions modules/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Entry struct {
History bool `json:"history,omitempty"`
HistoryIdentifier string `json:"history_identifier,omitempty"`
Matching MatchingType `json:"matching,omitempty"`
RecalculateScore bool `json:"recalculate_score,omitempty"`
ScoreFinal float64 `json:"score_final,omitempty"`
ScoreFuzzy int `json:"score_fuzzy,omitempty"`
Used int `json:"-"`
Expand Down
5 changes: 5 additions & 0 deletions ui/interactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,11 @@ func processAsync(ctx context.Context) {
toPush := []modules.Entry{}

for k := range e {
if e[k].RecalculateScore {
e[k].ScoreFinal = 0
e[k].ScoreFuzzy = 0
}

if e[k].ScoreFinal == 0 {
switch e[k].Matching {
case modules.Fuzzy:
Expand Down

0 comments on commit 986b031

Please sign in to comment.