aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/frontend.js21
-rw-r--r--ext/fg/js/source.js4
2 files changed, 12 insertions, 13 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 41c93f00..e4035289 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -169,27 +169,21 @@ class Frontend {
}
async searchAt(point) {
- let textSource = null;
+ const textSource = docRangeFromPoint(point);
+ let hideResults = false;
try {
if (this.pendingLookup) {
return;
}
- textSource = docRangeFromPoint(point);
- if (!textSource || !textSource.containsPoint(point)) {
- docImposterDestroy();
- return;
- }
-
if (this.textSourceLast && this.textSourceLast.equals(textSource)) {
return;
}
- this.pendingLookup = true;
-
- if (!await this.searchTerms(textSource)) {
- await this.searchKanji(textSource);
+ if (textSource && textSource.containsPoint(point)) {
+ this.pendingLookup = true;
+ hideResults = !await this.searchTerms(textSource) && !await this.searchKanji(textSource);
}
} catch (e) {
if (window.yomichan_orphaned) {
@@ -201,6 +195,11 @@ class Frontend {
}
} finally {
docImposterDestroy();
+
+ if (hideResults && this.options.scanning.autoHideResults) {
+ this.popup.hide();
+ }
+
this.pendingLookup = false;
}
}
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index 3b6ecb2a..664dbec7 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -82,7 +82,7 @@ class TextSourceRange {
}
equals(other) {
- return other.range && other.range.compareBoundaryPoints(Range.START_TO_START, this.range) === 0;
+ return other && other.range && other.range.compareBoundaryPoints(Range.START_TO_START, this.range) === 0;
}
static shouldEnter(node) {
@@ -239,6 +239,6 @@ class TextSourceElement {
}
equals(other) {
- return other.element === this.element && other.content === this.content;
+ return other && other.element === this.element && other.content === this.content;
}
}