Merge pull request #2518 from keymanapp/fix/web/2516-context-break

fix(web): Hotfixes recent break for text prediction
This commit is contained in:
Joshua Horton 2020-01-23 10:04:27 +07:00 • committed by GitHub
commit ea3d276643
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,16 +33,16 @@ namespace com.keyman.text.prediction {
constructor(mock: Mock, config: Configuration) {
this.left = mock.getTextBeforeCaret();
this.startOfBuffer = this.left._kmwLength() > config.leftContextCodeUnits;
this.startOfBuffer = this.left._kmwLength() > config.leftContextCodePoints;
if(!this.startOfBuffer) {
// Our custom substring version will return the last n characters if param #1 is given -n.
this.left = this.left._kmwSubstr(-config.leftContextCodeUnits);
this.left = this.left._kmwSubstr(-config.leftContextCodePoints);
}
this.right = mock.getTextAfterCaret();
this.endOfBuffer = this.right._kmwLength() > config.rightContextCodeUnits;
this.endOfBuffer = this.right._kmwLength() > config.leftContextCodePoints;
if(!this.endOfBuffer) {
this.right = this.right._kmwSubstr(0, config.rightContextCodeUnits);
this.right = this.right._kmwSubstr(0, config.leftContextCodePoints);
}
}
}