mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-29 11:47:39 +00:00
fix(web): add safeguard for split-distribution merging
This commit is contained in:
parent
22f534667f
commit
b1ffa83c8b
1 changed files with 21 additions and 16 deletions
|
|
@ -199,23 +199,28 @@ export abstract class SearchQuotientSpur implements SearchQuotientNode {
|
|||
// per-codepoint.
|
||||
if(localInputId != spaceInputId || localInputId === undefined) {
|
||||
return space.construct(parentMerge, space.inputs, space.inputSource);
|
||||
} else {
|
||||
// Get the twin halves that were split.
|
||||
// Assumption: the two halves are in their original order, etc.
|
||||
const localInputs = this.inputs;
|
||||
const spaceInputs = space.inputs;
|
||||
|
||||
// Merge them!
|
||||
const mergedInputs = localInputs?.map((entry, index) => {
|
||||
return {
|
||||
sample: buildMergedTransform(entry.sample, spaceInputs[index].sample),
|
||||
p: entry.p
|
||||
}
|
||||
});
|
||||
|
||||
// Now to re-merge the two halves.
|
||||
return space.construct(this.parentNode, mergedInputs, this.inputSource);
|
||||
}
|
||||
// Get the twin halves that were split.
|
||||
// Assumption: the two halves are in their original order, etc.
|
||||
const localInputs = this.inputs;
|
||||
const spaceInputs = space.inputs;
|
||||
|
||||
// Sanity check - ensure that the input distributions have the same length;
|
||||
// if not, this shouldn't represent a SearchPath split!
|
||||
if(localInputs.length != spaceInputs.length) {
|
||||
return space.construct(parentMerge, space.inputs, space.inputSource);
|
||||
}
|
||||
|
||||
// Merge them!
|
||||
const mergedInputs = localInputs?.map((entry, index) => {
|
||||
return {
|
||||
sample: buildMergedTransform(entry.sample, spaceInputs[index].sample),
|
||||
p: entry.p
|
||||
}
|
||||
});
|
||||
|
||||
// Now to re-merge the two halves.
|
||||
return space.construct(this.parentNode, mergedInputs, this.inputSource);
|
||||
} else {
|
||||
// If the parent was a cluster, the cluster itself is the merge.
|
||||
return parentMerge;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue