Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

A small patch in a large file

The ordinary case, and the one Myers is fast at: most of the file is untouched. The search ends after as many rounds as there are edits, not as there are lines, which is the whole reason to prefer it to an edit matrix.

The diff

Context: 6 line(s).

 1@@ -1,10 +1,9 @@
 2 package main
 3 
 4 import "fmt"
 5 
 6 func main() {
 7-	fmt.Println("hello")
 8+	name := "world"
 9+	fmt.Println("hello", name)
10 }
11 
12-// TODO: say who
13-

The script

property value
inserted lines 2
deleted lines 3
unchanged lines 7
minimal yes

Replaying it on the left document reproduces the right one yes, which is the property that holds even when the script is not minimal.

back