-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanchor.go
More file actions
29 lines (25 loc) · 1015 Bytes
/
anchor.go
File metadata and controls
29 lines (25 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package diffx
// Anchor elimination post-processing.
//
// The histogram algorithm handles stopword filtering during anchor selection,
// so aggressive post-processing is no longer needed. This file provides the
// eliminateWeakAnchors function which now simply merges adjacent operations.
// eliminateWeakAnchors merges adjacent operations of the same type.
//
// Previously this converted stopwords at Equal boundaries to Delete+Insert pairs,
// but that created confusing self-replacement patterns like [-for-] {+for+}.
// The histogram algorithm now filters stopwords from being anchors, so this
// post-processing just ensures operations are properly merged.
func eliminateWeakAnchors(ops []DiffOp, a, b []Element) []DiffOp {
if len(ops) < 2 {
return ops
}
return mergeAdjacentOps(ops)
}
// WithAnchorElimination enables or disables anchor elimination post-processing.
// Default: true.
func WithAnchorElimination(enabled bool) Option {
return func(o *options) {
o.anchorElimination = enabled
}
}