Preserve append history across tiers
This commit is contained in:
@@ -16,6 +16,20 @@ type composedDocument struct {
|
||||
inputNodes int
|
||||
}
|
||||
|
||||
type sequenceHistoryMode uint8
|
||||
|
||||
const (
|
||||
sequenceHistoryReplace sequenceHistoryMode = iota + 1
|
||||
sequenceHistoryAppend
|
||||
)
|
||||
|
||||
type sequenceHistoryContribution struct {
|
||||
path Path
|
||||
mode sequenceHistoryMode
|
||||
offset int
|
||||
length int
|
||||
}
|
||||
|
||||
// assemblyAccumulator owns one mutable working document. Acquired trees held by
|
||||
// history applications are separate from its root and remain unchanged.
|
||||
type assemblyAccumulator struct {
|
||||
@@ -113,8 +127,24 @@ func composeDocumentsWithPolicy(policy sequencePolicy, inputs ...*document.Node)
|
||||
mergeComposedMappings(root, input, Path{}, index, sourceIndex+1, policy, validated)
|
||||
}
|
||||
applications := make([]historyApplication, 0, len(inputs))
|
||||
for _, input := range inputs {
|
||||
applications = append(applications, historyApplication{layer: LayerBase, value: input})
|
||||
seenSequences := make(map[string]bool)
|
||||
for sourceIndex, input := range inputs {
|
||||
application := historyApplication{layer: LayerBase, value: input}
|
||||
for _, assigned := range ranges {
|
||||
if assigned.sourceIndex != sourceIndex {
|
||||
continue
|
||||
}
|
||||
pointer := assigned.path.String()
|
||||
mode := sequenceHistoryAppend
|
||||
if !seenSequences[pointer] {
|
||||
mode = sequenceHistoryReplace
|
||||
}
|
||||
seenSequences[pointer] = true
|
||||
application.sequences = append(application.sequences, sequenceHistoryContribution{
|
||||
path: assigned.path.clone(), mode: mode, offset: assigned.start, length: assigned.end - assigned.start,
|
||||
})
|
||||
}
|
||||
applications = append(applications, application)
|
||||
}
|
||||
origins := projectedCompositionOrigins(inputs, ranges)
|
||||
completeCompositionOrigins(root, Path{}, origins)
|
||||
|
||||
Reference in New Issue
Block a user