From dcb6f68826bd64d6cb41d2d7a0d5da1a58da9a1b Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 24 Oct 2019 20:01:04 -0400 Subject: Don't pass null textSource into searchSource --- ext/fg/js/frontend.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'ext/fg/js') 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); } -- cgit v1.2.3