Documentation
¶
Overview ¶
Package locator implements the scoring and filtering engine behind a Qt-Creator-style Locator (Ctrl+K) / fuzzy quick-open box. It is deliberately UI-agnostic: it knows nothing about widgets, windows, or rendering, so an IDE front-end can feed it a flat list of candidates (files, symbols, lines) and render the ranked result however it likes.
Matching is subsequence fuzzy matching: a query matches a candidate when every rune of the query appears in the candidate, in order, comparing case-insensitively. Scoring rewards matches a human reads as "closer" -- consecutive runs, hits on word / camelCase / path-separator boundaries, and prefix or exact matches -- and penalises the gaps between scattered matches. All comparison is rune-based, so multi-byte / Unicode candidates rank correctly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FuzzyScore ¶
FuzzyScore reports whether query is a case-insensitive subsequence of candidate and, when it is, a score where higher means a better match.
An empty query matches every candidate with a neutral score of 0. A non-match returns (0, false); callers MUST consult matched rather than the score, because a legitimate (very gappy) match can also score low -- though never zero, so a matched score is always positive.
Types ¶
type Item ¶
Item is a single quick-open candidate. Name is the primary string the query is scored against (a file name, symbol, or line label). Detail is carried through untouched for the UI to show as a subtitle (a path, a line preview) and Kind is a free-form category tag ("file", "symbol", ...). Only Name participates in scoring.
func Match ¶
Match returns the items whose Name matches query (case-insensitive subsequence), best score first. Ties break by Name ascending, then by original slice order, so the result is fully deterministic and stable. Non-matching items are dropped. An empty query returns every item: all share the neutral score, so they come back Name-sorted. The returned slice is always non-nil (empty when nothing matches).