···3434 NewContent string // new content (only used for Replace operations)
3535}
36363737+type outputEdit struct {
3838+ edit Edit
3939+ origPosition int
4040+}
4141+4242+type mergeInfo struct {
4343+ partnIndex int // index of the partner edit
4444+ isDelete bool
4545+}
4646+3747// Diff represents a generic diffing algorithm.
3848type Diff interface {
3949 // Compute computes the edit operations needed to transform a into b.
···367377 return edits
368378 }
369379370370- type mergeInfo struct {
371371- partnIndex int // index of the partner edit
372372- isDelete bool
373373- }
374374-375380 merged := make(map[int]mergeInfo)
376381 const lookAheadWindow = 50
377382···409414 }
410415 }
411416412412- for i := 0; i < len(edits); i++ {
417417+ for i := range edits {
413418 if _, exists := merged[i]; exists || edits[i].Kind != Insert {
414419 continue
415420 }
···427432 }
428433 }
429434430430- type outputEdit struct {
431431- edit Edit
432432- origPosition int
433433- }
434434-435435 outputs := make([]outputEdit, 0, len(edits))
436436437437 for i := range edits {
···480480 for _, out := range outputs {
481481 result = append(result, out.edit)
482482 }
483483-484483 return result
485484}
486485487486// areSimilarLines determines if two lines are similar enough to be considered a replacement.
488487//
489488// Uses a two-phase similarity check:
490490-// 1. Common prefix must be at least 70% of the shorter line
491491-// 2. Remaining suffixes must be at least 60% similar (Levenshtein-like check)
489489+//
490490+// 1. Common prefix must be at least 70% of the shorter line
491491+// 2. Remaining suffixes must be at least 60% similar (Levenshtein-like check)
492492func areSimilarLines(a, b string) bool {
493493 if a == b {
494494 return true
···501501 }
502502503503 commonPrefix := 0
504504- for i := 0; i < minLen; i++ {
504504+ for i := range minLen {
505505 if a[i] == b[i] {
506506 commonPrefix++
507507 } else {
···530530 }
531531532532 maxSuffixLen := max(suffixLenB, suffixLenA)
533533-534533 if maxSuffixLen > 0 && float64(lenDiff)/float64(maxSuffixLen) > 0.3 {
535534 return false
536535 }
537537-538536 return true
539537}