Fix autoHideResults not working

This commit is contained in:
toasted-nutbread 2019-11-03 11:06:31 -05:00
parent 7de24dd355
commit 75ff05148d
2 changed files with 16 additions and 16 deletions

View File

@ -158,7 +158,6 @@ class SettingsPopupPreview {
const range = document.createRange();
range.selectNode(textNode);
const source = new TextSourceRange(range, range.toString(), null);
if (source === null) { return; }
try {
await this.frontend.searchSource(source, 'script');

View File

@ -336,17 +336,16 @@ class Frontend {
}
const textSource = docRangeFromPoint(x, y, this.options);
if (
textSource === null ||
(this.textSourceCurrent !== null && this.textSourceCurrent.equals(textSource))
) {
if (this.textSourceCurrent !== null && this.textSourceCurrent.equals(textSource)) {
return;
}
try {
return await this.searchSource(textSource, cause);
await this.searchSource(textSource, cause);
} finally {
textSource.cleanup();
if (textSource !== null) {
textSource.cleanup();
}
}
} catch (e) {
this.onError(e);
@ -358,17 +357,19 @@ class Frontend {
try {
this.pendingLookup = true;
results = (
await this.findTerms(textSource) ||
await this.findKanji(textSource)
);
if (results !== null) {
const focus = (cause === 'mouse');
this.showContent(textSource, focus, results.definitions, results.type);
if (textSource !== null) {
results = (
await this.findTerms(textSource) ||
await this.findKanji(textSource)
);
if (results !== null) {
const focus = (cause === 'mouse');
this.showContent(textSource, focus, results.definitions, results.type);
}
}
} catch (e) {
if (window.yomichan_orphaned) {
if (textSource && this.options.scanning.modifier !== 'none') {
if (textSource !== null && this.options.scanning.modifier !== 'none') {
this.lastShowPromise = this.popup.showContent(
textSource.getRect(),
textSource.getWritingMode(),
@ -386,7 +387,7 @@ class Frontend {
this.pendingLookup = false;
}
return results !== null;
return results;
}
showContent(textSource, focus, definitions, type) {