diff --git a/common/predictive-text/worker/model-compositor.ts b/common/predictive-text/worker/model-compositor.ts index 7004388f78..1cd69d9616 100644 --- a/common/predictive-text/worker/model-compositor.ts +++ b/common/predictive-text/worker/model-compositor.ts @@ -74,6 +74,17 @@ class ModelCompositor { if(!(transformDistribution instanceof Array)) { transformDistribution = [ {sample: transformDistribution, p: 1.0} ]; } else if(transformDistribution.length == 0) { + /* + Robust stop-gap: if our other filters somehow fail, this fixes the + zero-length array by making it match the form of the array that + would result if it were instead called with the other legal + parameter type - a single Transform. + + Unfortunately, the method will lack all data about even + the original keystroke that resulted in the call... but this way, + we can at least get some predictions rather than shortcutting + and producing none whatsoever. + */ transformDistribution.push({ sample: { insert: '',