fuzzy

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fuzzy finds the text an edit means to replace when the model's copy of it is not byte for byte the file's: nine strategies from an exact match to similarity scoring, each tried in turn, with the guards that keep a near miss from editing the wrong place

Index

Constants

View Source
const DidYouMean = "\n\nDid you mean one of these sections?\n"

Lead of the closest lines hint appended to a no match failure

View Source
const NoMatch = "Could not find a match for old_string in the file"

Failure of a replace whose old_string matches nowhere in the file

Variables

This section is empty.

Functions

func Applied

func Applied(content, old, new string) bool

Whether a re sent edit already landed: its new text, of some length, is in the content and its old text is gone; content compared as a reader shows it

func BoundaryNote

func BoundaryNote(used []string, target, where string) string

Note for an edit a similarity strategy located, empty when every strategy matched exactly

func HoldsNoMatch

func HoldsNoMatch(text string) bool

Whether a failure text is or carries a no match failure

func NoMatchHint

func NoMatchHint(failure string, count int, old, content string) string

Did you mean snippet for a failure that found no match at all, empty for any other

func NoMatchIn

func NoMatchIn(path string) string

No match failure naming the file

Types

type Result

type Result struct {
	Content string
	// Spans replaced
	Count int
	// Strategy that found them
	Strategy string
	// What an escape drift correction changed before matching, empty when nothing was corrected
	Note string
}

Outcome of a replace

func Replace

func Replace(content, old, new string, all bool) (Result, error)

Replaces old with new in the content through the first strategy that finds it, every match when all is set. Content that is not valid UTF-8 is matched as a reader shows it, each undecodable byte as U+FFFD, and every byte the edit leaves unchanged is written back as it was

Jump to

Keyboard shortcuts

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