From d608657495d59469b17fbae9027772c26848a95e Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 24 Oct 2019 19:38:06 -0400 Subject: Move onError catch into searchAt --- ext/fg/js/frontend.js | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'ext/fg') diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index e854f74e..c8a7d254 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -99,11 +99,7 @@ class Frontend { } const search = async () => { - try { - await this.searchAt(e.clientX, e.clientY, 'mouse'); - } catch (e) { - this.onError(e); - } + await this.searchAt(e.clientX, e.clientY, 'mouse'); }; if (scanningModifier === 'none') { @@ -314,12 +310,16 @@ class Frontend { } async searchAt(x, y, cause) { - if (this.pendingLookup || await this.popup.containsPoint(x, y)) { - return; - } + try { + if (this.pendingLookup || await this.popup.containsPoint(x, y)) { + return; + } - const textSource = docRangeFromPoint(x, y, this.options); - return await this.searchSource(textSource, cause); + const textSource = docRangeFromPoint(x, y, this.options); + return await this.searchSource(textSource, cause); + } catch (e) { + this.onError(e); + } } async searchSource(textSource, cause) { @@ -503,15 +503,7 @@ class Frontend { return; } - const search = async () => { - try { - await this.searchAt(x, y, cause); - } catch (e) { - this.onError(e); - } - }; - - search(); + this.searchAt(x, y, cause); } selectionContainsPoint(selection, x, y) { -- cgit v1.2.3