match

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package match answers "does what the user typed match this?" for the two places that ask.

The finder dialogs rank a list and want a forgiving answer: initials should reach a command nobody spelled out. Text search walks a buffer and wants an exact one: a caret that lands somewhere the pattern is not is worse than no jump at all. Both live here so the two never drift into disagreeing about what case-insensitive means.

It knows nothing about screens, files or SQL — the inputs are strings and the outputs are numbers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(text, pattern string) bool

Contains reports whether pattern appears anywhere in text, under the same smartcase rule as Next.

func Fuzzy

func Fuzzy(term, candidate string) (score int, ok bool)

Fuzzy scores candidate against term, matching term's runes in order but not necessarily together.

An empty term matches everything with no opinion about order, which is what a freshly opened dialog wants. Case is always ignored: a finder is a filter, and a capital typed into one is a typo more often than an intention.

It finds the best-scoring placement, not the leftmost one. Taking the first occurrence of each rune is cheaper but ranks "dreadfully" above "delete line" for "dl", because the leading "l" of "line" is never reached — the "l" inside "delete" is claimed first.

func Next

func Next(text, pattern string, from int) (offset int, ok bool)

Next finds pattern at or after the byte offset from.

The offset is inclusive so that repeating a search from a match that is still under the caret does not require the caller to nudge past it first. A miss is a miss, not a wrap: whether searching should start over from the top is the caller's decision, and the operator that would delete everything in between must be able to say no.

func Prev

func Prev(text, pattern string, before int) (offset int, ok bool)

Prev finds the last match strictly before the byte offset before.

Types

This section is empty.

Jump to

Keyboard shortcuts

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