feat(picker.smart): better frecency bonus

This commit is contained in:
Folke Lemaitre 2025-01-17 23:46:04 +01:00
parent 2cb5c5bac7
commit 74feefc522
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -3,6 +3,9 @@ local M = {}
---@class snacks.picker
---@field smart fun(opts?: snacks.picker.smart.Config): snacks.picker.finder
local BONUS_FRECENCY = 8
local BONUS_CWD = 10
---@param opts snacks.picker.smart.Config
---@type snacks.picker.finder
function M.smart(opts, filter)
@ -16,9 +19,10 @@ function M.smart(opts, filter)
return false
end
done[path] = true
local score = freceny:get(item)
local score = (1 - 1 / (1 + freceny:get(item))) * BONUS_FRECENCY
item.frecency = score
if path:find(cwd, 1, true) then
score = score + 20
score = score + BONUS_CWD
end
item.score_add = score
end)(opts, filter)