Documentation
¶
Index ¶
- func CalculateItemScore(item Item, fuzzyScore int, matchedIndexes []int, mode SearchMode, ...) float64
- func CalculateMatchBonus(text string, matchedIndexes []int, config ScoringConfig) float64
- func CalculateRecencyBonus(timestamp int64, now int64, maxBonus float64) float64
- func GetCurrentTimestamp() int64
- func Run()
- type Item
- type ScoringConfig
- type SearchMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateItemScore ¶ added in v0.2.6
func CalculateItemScore(item Item, fuzzyScore int, matchedIndexes []int, mode SearchMode, config ScoringConfig, now int64) float64
CalculateItemScore calculates the total score for an item combining fuzzy match score, position bonuses, and recency
func CalculateMatchBonus ¶ added in v0.2.6
func CalculateMatchBonus(text string, matchedIndexes []int, config ScoringConfig) float64
CalculateMatchBonus calculates bonus score based on match positions using fzy/fzf-inspired algorithm
func CalculateRecencyBonus ¶ added in v0.2.6
CalculateRecencyBonus calculates recency bonus using hyperbolic decay Formula: bonus = maxBonus / (1 + ageInHours) This strongly prioritizes recent items:
0h ago -> maxBonus, 1h -> maxBonus/2, 2h -> maxBonus/3, 24h -> maxBonus/25
func GetCurrentTimestamp ¶ added in v0.2.6
func GetCurrentTimestamp() int64
GetCurrentTimestamp returns the current Unix timestamp
Types ¶
type Item ¶
type Item struct {
Text string
Index int // Index in the original source slice
Original interface{} // The original object (history.Entry, git.Branch, or files.Entry)
IsCurrent bool // For git branch (icon logic)
IsRemote bool // For git branch (icon logic)
IsDir bool // For files (directory indicator)
MatchedIndexes []int // Indexes of matched characters for highlighting
}
Item represents a search result item
type ScoringConfig ¶ added in v0.2.6
type ScoringConfig struct {
// Word boundary bonus (match after /, -, _, ., space)
WordBoundaryBonus float64
// Consecutive match bonus
ConsecutiveBonus float64
// Prefix match bonus (match at start)
PrefixBonus float64
// CamelCase bonus (match at uppercase letter)
CamelCaseBonus float64
// Recency bonus settings
MaxRecencyBonus float64
// Current branch bonus (git mode only)
CurrentBranchBonus float64
}
ScoringConfig holds configuration for the unified scoring algorithm
func DefaultScoringConfig ¶ added in v0.2.6
func DefaultScoringConfig() ScoringConfig
DefaultScoringConfig returns the default scoring configuration inspired by fzy and fzf algorithms
type SearchMode ¶
type SearchMode int
SearchMode represents the current search mode
const ( ModeHistory SearchMode = iota ModeGitBranch ModeFiles )