Documentation
¶
Index ¶
Constants ¶
View Source
const (
EOF tokenType
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Diff ¶
type Diff struct {
Line int // 1-based line number where the search should start
Search string // Text to find in the document
Replace string // Text to replace the found section with
}
Diff represents a text replacement operation with search and replace strings that should be applied at a specific line position in a document.
type Edit ¶
type Edit struct {
Start int // Byte offset where the edit starts (inclusive)
End int // Byte offset where the edit ends (exclusive)
Text string // New text to replace the section between Start and End
}
Edit represents a specific text edit operation with byte offsets that can be applied to a document.
func Search ¶
Search tries to locate `diff.Search` inside `source`. It begins at the requested line and expands alternately upward/downward until a slice whose similarity ≥ threshold is found.
Similarity = 1 - (levenshtein distance / maxLen). On success it returns the byte‑offset edit [Start, End) to replace and true. If nothing satisfies the threshold it returns (zero Edit, false).
Click to show internal directories.
Click to hide internal directories.