Package diff supports a pluggable diff algorithm.
ApplyEdits applies the set of edits to the before and returns the resulting content. It may panic or produce garbage if the edits are not valid for the provided before content.
SortTextEdits attempts to order all edits by their starting points. The sort is stable so that edits with the same starting point will not be reordered.
ComputeEdits is the type for a function that produces a set of edits that convert from the before content to the after content.
Hunk represents a contiguous set of line edits to apply.
Line represents a single line operation to apply as part of a Hunk.
OpKind is used to denote the type of operation a line represents.
const ( // Delete is the operation kind for a line that is present in the input // but not in the output. Delete OpKind = iota // Insert is the operation kind for a line that is new in the output. Insert // Equal is the operation kind for a line that is the same in the input and // output, often used to provide context around edited lines. Equal )
String returns a human readable representation of an OpKind. It is not intended for machine processing.
TextEdit represents a change to a section of a document. The text within the specified span should be replaced by the supplied new text.
LineEdits takes a set of edits and expands and merges them as necessary to ensure that there are only full line edits left when it is done.
Unified represents a set of edits as a unified diff.
ToUnified takes a file contents and a sequence of edits, and calculates a unified diff that represents those edits.
Format converts a unified diff to the standard textual form for that diff. The output of this function can be passed to tools like patch.
|difftest||Package difftest supplies a set of tests that will operate on any implementation of a diff algorithm as exposed by "golang.org/x/tools/internal/lsp/diff"|
|myers||Package myers implements the Myers diff algorithm.|