Skip to content

Commit

Permalink
change(web): Output error if we can't apply suggestion
Browse files Browse the repository at this point in the history
This addresses code review comments. We output a separate error if
the configuration isn't yet set because the model isn't fully loaded yet.
Also we output errors instead of warnings so that they get logged as
events in Sentry.
  • Loading branch information
ermshiperete committed May 29, 2024
1 parent 8dc30c9 commit a5875f2
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,17 @@ export default class LanguageProcessor extends EventEmitter<LanguageProcessorEve
throw "Accepting suggestions requires a destination OutputTarget instance."
}

if(!this.isConfigured) {
console.error("Can't apply suggestions until model is fully loaded");
return null;
}

// Find the state of the context at the time the suggestion was generated.
// This may refer to the context before an input keystroke or before application
// of a predictive suggestion.
let original = this.getPredictionState(suggestion.transformId);
if(!original || !this.isConfigured) {
console.warn("Could not apply the Suggestion!");
const original = this.getPredictionState(suggestion.transformId);
if(!original) {
console.error("Could not apply the Suggestion!");
return null;
} else {
// Apply the Suggestion!
Expand Down

0 comments on commit a5875f2

Please sign in to comment.