aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-24 19:38:06 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-28 17:03:42 -0400
commitd608657495d59469b17fbae9027772c26848a95e (patch)
tree920a2583017efa6d0d5e7a471c12e6190aaa18bf /ext/fg/js/frontend.js
parent1039536cfb6279aadb9241c5905aa64790cd6fac (diff)
Move onError catch into searchAt
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js30
1 files changed, 11 insertions, 19 deletions
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) {