From 9d35b26f1be02bbda8a574b973fe3d2c5f2f2981 Mon Sep 17 00:00:00 2001 From: Joshua Horton Date: Thu, 22 Jul 2021 10:56:38 +0700 Subject: [PATCH] docs(common/models): applies PR suggestion Co-authored-by: Marc Durdin --- common/predictive-text/worker/model-compositor.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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: '',