summaryrefslogtreecommitdiff
path: root/ext/mixed/js
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2019-09-02 08:30:19 -0700
committerGitHub <noreply@github.com>2019-09-02 08:30:19 -0700
commit037363e3a70675a580431d2ee891e3d88fae511c (patch)
treed42dab6f73fdcc52b9192a29cc1e1219608ca035 /ext/mixed/js
parenteee89fa1853b80d563bc9ef5ba05d9a9e8ee2d0d (diff)
parente3d7ec8db7a86d475fba00d48f9cbe150feb36ff (diff)
Merge pull request #197 from toasted-nutbread/imposter-improvements
Imposter element improvements
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: {