app

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

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

func CalculateRecencyBonus(timestamp int64, now int64, maxBonus float64) float64

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

func Run

func Run()

Run starts the application

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL