mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 11:18:26 +00:00
feat(matcher): call on_match after setting score
This commit is contained in:
parent
c61114fb32
commit
23ce529fb6
1 changed files with 6 additions and 3 deletions
|
@ -313,8 +313,8 @@ function M:update(item)
|
|||
if item.match_pos then
|
||||
item.pos = nil
|
||||
end
|
||||
item.match_topk = nil
|
||||
local score = self:match(item)
|
||||
item.match_tick, item.match_topk = self.tick, nil
|
||||
if score ~= 0 then
|
||||
if item.score_add then
|
||||
score = score + item.score_add
|
||||
|
@ -332,16 +332,19 @@ function M:update(item)
|
|||
score = score + (1 - 1 / (1 + item.frecency)) * BONUS_FRECENCY
|
||||
end
|
||||
if
|
||||
self.opts.cwd_bonus and (self.cwd == item.cwd or Snacks.picker.util.path(item):find(self.cwd, 1, true) == 1)
|
||||
self.opts.cwd_bonus
|
||||
and (self.cwd == item.cwd or Snacks.picker.util.path(item):find(self.cwd, 1, true) == 1)
|
||||
then
|
||||
score = score + BONUS_CWD
|
||||
end
|
||||
end
|
||||
item.score = score
|
||||
if self.opts.on_match then
|
||||
self.opts.on_match(self, item)
|
||||
end
|
||||
else
|
||||
item.score = 0
|
||||
end
|
||||
item.match_tick, item.score, item.match_topk = self.tick, score, nil
|
||||
return score > 0
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue