summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-24 20:01:04 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-28 17:03:42 -0400
commitdcb6f68826bd64d6cb41d2d7a0d5da1a58da9a1b (patch)
treeaa62cafcedea0f9dfb14cc37eaa916c3d688e902 /ext
parent185963899b4176b31a14ab141f1335c17a2de9c4 (diff)
Don't pass null textSource into searchSource
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/settings-popup-preview.js7
-rw-r--r--ext/fg/js/frontend.js17
2 files changed, 17 insertions, 7 deletions
diff --git a/ext/bg/js/settings-popup-preview.js b/ext/bg/js/settings-popup-preview.js
index b12fb726..ce6da4c0 100644
--- a/ext/bg/js/settings-popup-preview.js
+++ b/ext/bg/js/settings-popup-preview.js
@@ -158,9 +158,14 @@ class SettingsPopupPreview {
const range = document.createRange();
range.selectNode(textNode);
const source = new TextSourceRange(range, range.toString(), null);
+ if (source === null) { return; }
this.frontend.textSourceLast = null;
- await this.frontend.searchSource(source, 'script');
+ try {
+ await this.frontend.searchSource(source, 'script');
+ } finally {
+ source.cleanup();
+ }
await this.frontend.lastShowPromise;
if (this.frontend.popup.isVisible()) {
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 897c7b73..5e2ef529 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -319,19 +319,27 @@ class Frontend {
}
const textSource = docRangeFromPoint(x, y, this.options);
- return await this.searchSource(textSource, cause);
+ if (textSource === null) {
+ return;
+ }
+
+ try {
+ return await this.searchSource(textSource, cause);
+ } finally {
+ textSource.cleanup();
+ }
} catch (e) {
this.onError(e);
}
}
async searchSource(textSource, cause) {
- let hideResults = textSource === null;
+ let hideResults = false;
let searched = false;
let success = false;
try {
- if (!hideResults && (!this.textSourceLast || !this.textSourceLast.equals(textSource))) {
+ if (!this.textSourceLast || !this.textSourceLast.equals(textSource)) {
searched = true;
this.pendingLookup = true;
const focus = (cause === 'mouse');
@@ -351,9 +359,6 @@ class Frontend {
this.onError(e);
}
} finally {
- if (textSource !== null) {
- textSource.cleanup();
- }
if (hideResults && this.options.scanning.autoHideResults) {
this.searchClear(true);
}