suggest

package
v1.0.54 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package suggest provides the shared "did you mean" primitives: a rune-aware Levenshtein edit distance and a prefix-weighted Closest ranker. It is the single home for these so cmd, cmd/event, and internal/cmdpolicy stop each carrying their own copy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Closest

func Closest(typed string, candidates []string, maxN int) []string

Closest returns up to maxN of candidates that plausibly match typed, ranked by shared-prefix length (desc) then edit distance (asc), keeping only reasonably-close ones.

Shared prefix is weighted first on purpose: hallucinated names are often semantically close but lexically far (e.g. "+cells-find" vs "+cells-search", "--with-styles" vs nothing close), where the common prefix is the strongest signal of intent that raw edit distance misses.

func Levenshtein

func Levenshtein(a, b string) int

Levenshtein computes the classic edit distance between two strings. It is rune-aware, so it is correct for multi-byte input.

Types

This section is empty.

Jump to

Keyboard shortcuts

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