aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-08-31 14:57:24 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-08-31 14:57:50 -0400
commitad0dca7bb12d13545b559e9c738fcc0767ba20d5 (patch)
treec3a27f29d185ba06c7fac98f65a54a952d131a2d /ext/mixed/js
parente47e041217708c49032dd3d215eacb23276a1f59 (diff)
Make the imposter element tracked using TextSourceRange
Diffstat (limited to 'ext/mixed/js')
-rw-r--r--ext/mixed/js/display.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index a2707bd0..4620e198 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -84,16 +84,22 @@ class Display {
if (textSource === null) {
return false;
}
- textSource.setEndOffset(this.options.scanning.length);
- const {definitions, length} = await apiTermsFind(textSource.text());
- if (definitions.length === 0) {
- return false;
- }
+ let definitions, length, sentence;
+ try {
+ textSource.setEndOffset(this.options.scanning.length);
- textSource.setEndOffset(length);
+ ({definitions, length} = await apiTermsFind(textSource.text()));
+ if (definitions.length === 0) {
+ return false;
+ }
- const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt);
+ textSource.setEndOffset(length);
+
+ sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt);
+ } finally {
+ textSource.cleanup();
+ }
const context = {
source: {