From fa6cbe65c937e5c8bf6e8229653ceed0d55216f4 Mon Sep 17 00:00:00 2001 From: jahorton Date: Fri, 2 Oct 2020 14:24:29 +0700 Subject: [PATCH] change(common/models): better reversion id strat --- common/predictive-text/worker/model-compositor.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/predictive-text/worker/model-compositor.ts b/common/predictive-text/worker/model-compositor.ts index 5d37be3556..9db8b242f3 100644 --- a/common/predictive-text/worker/model-compositor.ts +++ b/common/predictive-text/worker/model-compositor.ts @@ -400,8 +400,15 @@ class ModelCompositor { // Since we're outside of the standard `predict` control path, we'll need to // set the Reversion's ID directly. let reversion = this.toAnnotatedSuggestion(firstConversion, 'revert'); - reversion.id = this.SUGGESTION_ID_SEED; - this.SUGGESTION_ID_SEED++; + if(suggestion.id) { + // Since a reversion inverts its source suggestion, we set its ID to be the + // additive inverse of the source suggestion's ID. Makes easy mapping / + // verification later. + reversion.id = -suggestion.id; + } else { + reversion.id = -this.SUGGESTION_ID_SEED; + this.SUGGESTION_ID_SEED++; + } // Step 3: if we track Contexts, update the tracking data as appropriate. if(this.contextTracker) {