Preserve item helper history in source order

This commit is contained in:
2026-10-17 04:44:29 +00:00
parent 4633a1b8a2
commit 26720b98f0
4 changed files with 89 additions and 18 deletions

View File

@@ -578,8 +578,11 @@ func projectNestedEvidence(composed *composedDocument, scope acquisitionScope) {
if composed == nil {
return
}
applications := composed.applications
projectedApplications := make([]historyApplication, 0, len(applications))
for sourceIndex, contribution := range scope.contributions {
if contribution.nested == nil {
projectedApplications = append(projectedApplications, applications[sourceIndex])
continue
}
start := 0
@@ -590,26 +593,26 @@ func projectNestedEvidence(composed *composedDocument, scope acquisitionScope) {
}
}
prefix := contribution.destination.Index(start)
if sourceIndex < len(composed.applications) {
outer := composed.applications[sourceIndex]
if sourceIndex < len(applications) {
outer := applications[sourceIndex]
structural := document.Clone(outer.value)
if node, found := documentAtPath(structural, contribution.destination); found && node.Kind == document.Sequence && len(node.Sequence) > start {
node.Sequence[start] = &document.Node{Kind: document.Mapping, Location: node.Sequence[start].Location}
if node, found := documentAtPath(structural, contribution.destination); found && node.Kind == document.Sequence && len(node.Sequence) > 0 {
// The retained fragment is still a local singleton. Its assigned
// outer index belongs to the projection, not this source tree.
node.Sequence[0] = &document.Node{Kind: document.Mapping, Location: node.Sequence[0].Location}
}
outer.value = structural
composed.applications[sourceIndex] = outer
projectedApplications = append(projectedApplications, outer)
for _, nested := range contribution.nested.applications {
projected := nested
projected.path = appendDestination(prefix, nested.path)
projected.sequences = cloneSequenceHistoryContributions(nested.sequences)
for index := range projected.sequences {
projected.sequences[index].path = appendDestination(prefix, projected.sequences[index].path)
}
composed.applications = append(composed.applications, projected)
projectedApplications = append(projectedApplications, projected)
}
}
projectNestedOrigins(composed.origins, contribution.nested.root, contribution.nested.origins, prefix)
}
composed.applications = projectedApplications
}
func projectNestedOrigins(target map[string]Origin, root *document.Node, origins map[string]Origin, prefix Path) {