Documentation
¶
Overview ¶
Package filter narrows a list to the rows worth looking at, the shape every tool here reaches for once a list is long enough to need a live search: a predicate to combine and apply, a smart-case substring match for the base case, and a scoped-prefix query so "kind:thread pool" or "r:foo b:bar rest" parses the same way wherever the prefixes differ.
What stays local to each caller is which prefixes it recognizes and what they mean: a "kind:" that matches a row's own field, or a "p:" that looks up a pull request, is domain knowledge this package has no way to share.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Match ¶
Match reports whether text contains pattern, case-insensitively unless pattern itself carries an uppercase letter. That is the rule every editor's search box uses and the one nobody has to be told, so it is the default a caller reaches for before reaching past it to a fuzzy or glob matcher of its own.
func Tokens ¶
Tokens splits query into the plain text left over and the scoped words it carries, a word being scoped when it starts with one of scopes followed by ":" (matched case-insensitively, e.g. "kind:" catches "Kind:thread" too). "kind:thread pool" with scopes "kind" gives back text "pool" and scoped["kind"] = ["thread"]; an unrecognized prefix like "p:123" against scopes "kind" is left in text untouched, since only a caller knows which prefixes it means to parse.
Types ¶
type Predicate ¶
Predicate reports whether one item should be kept.
func All ¶
All is the predicate that keeps an item only when every one of preds does, short-circuiting scans left to right. An empty preds keeps everything.