Documentation
¶
Overview ¶
Package textedit provides byte spans and edits for source-preserving transformations.
Spans refer to the original source buffer. Apply checks edit bounds and overlap before producing replacement bytes, and Position maps byte offsets to line and column diagnostics. Language-specific parsing and edit intent belong to callers.
Index ¶
Constants ¶
const MatchBudget = 4_000_000
MatchBudget is the most cells Match's table may take between two sequences' common ends: 4,000,000 int32s, 16 MB. Past it, the middle is all changed, which callers read as a change to hold for, never as sameness.
Variables ¶
This section is empty.
Functions ¶
func Match ¶ added in v0.7.0
Match pairs two sequences' elements, a's n and b's m, by a longest common subsequence after their common start and end, same saying whether a[i] and b[j] are equal: from[j] is the index in a that b[j] keeps, or -1 for one b adds or alters. Where the middle's table would pass MatchBudget, every element of it is unmatched and within is false: the comparison's memory stays bounded, its answer "changed" (Codex's review of 8e314b96, finding 5, where a license comparison took 51 MB for a 25 KB pair). It's the one way the comparisons of lines and words match, each mapping the pairs to its own answer.
Types ¶
type EditError ¶
type EditError struct {
Type EditErrorType
Edit Edit
}
type EditErrorType ¶
type EditErrorType int
const ( ReversedSpan EditErrorType = iota OutOfBounds Overlap )
func (EditErrorType) String ¶
func (t EditErrorType) String() string