Preserve item helper history in source order
This commit is contained in:
@@ -125,8 +125,8 @@ func applicationOperationPath(application historyApplication, query Path, lookup
|
||||
if !application.path.valid() || application.value == nil {
|
||||
return Path{}, false
|
||||
}
|
||||
if application.path.String() != "" {
|
||||
if pathsIntersect(application.path, query) {
|
||||
if !pathContains(application.path, query) {
|
||||
if pathContains(query, application.path) {
|
||||
return application.path.clone(), true
|
||||
}
|
||||
return Path{}, false
|
||||
@@ -148,17 +148,18 @@ func applicationOperationPath(application historyApplication, query Path, lookup
|
||||
if sequencePathMatched {
|
||||
return Path{}, false
|
||||
}
|
||||
if len(query.segments) == 0 {
|
||||
return Path{}, true
|
||||
if len(query.segments) == len(application.path.segments) || application.value.Kind != document.Mapping {
|
||||
return application.path.clone(), true
|
||||
}
|
||||
for length := 1; length <= len(query.segments); length++ {
|
||||
prefix := Path{segments: clonePathSegments(query.segments[:length], 0)}
|
||||
relative, _ := relativeHistoryPath(application.path, query)
|
||||
for length := 1; length <= len(relative.segments); length++ {
|
||||
prefix := Path{segments: clonePathSegments(relative.segments[:length], 0)}
|
||||
node, present := documentAtPathWithLookup(application.value, prefix, lookup)
|
||||
if !present {
|
||||
return Path{}, false
|
||||
}
|
||||
if length == len(query.segments) || node.Kind != document.Mapping {
|
||||
return prefix, true
|
||||
if length == len(relative.segments) || node.Kind != document.Mapping {
|
||||
return appendDestination(application.path, prefix), true
|
||||
}
|
||||
}
|
||||
return Path{}, false
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user