Skip to main content

Module levenshtein

Module levenshtein 

Source
Expand description

Shared edit-distance “did you mean” helper (#712).

One implementation for every typo-suggestion surface: CLI commands (cli/dispatch/suggest.rs), config keys (cli/config_cmd.rs) and MCP tool names (server/dispatch). Wagner-Fischer over Unicode scalar values with a single rolling row — candidate sets are tiny (dozens of names), so O(a·b) time per pair is irrelevant; what matters is that all callers agree on distances.

Functions§

closest
The closest candidate within a length-scaled edit budget (one edit for short names, roughly a third of the length for longer ones), or None when nothing is near enough to suggest with confidence. Ties resolve to the first candidate in iteration order.
levenshtein
Classic Wagner-Fischer edit distance with O(min) memory.