From 9d54a4641b5bc7c16af2098d479ae992256a0039 Mon Sep 17 00:00:00 2001 From: jamesmaa Date: Thu, 22 Aug 2024 10:50:31 -0700 Subject: [PATCH] Avoid popup flickering --- ext/js/language/text-scanner.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js index e70de8fc00..a072342737 100644 --- a/ext/js/language/text-scanner.js +++ b/ext/js/language/text-scanner.js @@ -469,6 +469,11 @@ export class TextScanner extends EventDispatcher { null ); + if (this._scanResolution === 'word') { + // Move the start offset to the beginning of the word + textSource.setStartOffset(this._scanLength, this._layoutAwareScan, true); + } + if (this._textSourceCurrent !== null && this._textSourceCurrent.hasSameStart(textSource)) { return; } @@ -484,10 +489,6 @@ export class TextScanner extends EventDispatcher { let sentence = null; /** @type {'terms'|'kanji'} */ let type = 'terms'; - if (this._scanResolution === 'word') { - // Move the start offset to the beginning of the word - textSource.setStartOffset(this._scanLength, this._layoutAwareScan, true); - } const result = await this._findDictionaryEntries(textSource, searchTerms, searchKanji, optionsContext); if (result !== null) { ({dictionaryEntries, sentence, type} = result);