diff options
Diffstat (limited to 'ext/mixed/js')
-rw-r--r-- | ext/mixed/js/display.js | 8 | ||||
-rw-r--r-- | ext/mixed/js/text-scanner.js | 14 |
2 files changed, 15 insertions, 7 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index ea30030c..509683a6 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -82,7 +82,7 @@ class Display extends EventDispatcher { this._queryParserVisibleOverride = null; this._queryParserContainer = document.querySelector('#query-parser-container'); this._queryParser = new QueryParser({ - getOptionsContext: this.getOptionsContext.bind(this), + getSearchContext: this._getSearchContext.bind(this), documentUtil: this._documentUtil }); this._mode = null; @@ -1764,7 +1764,7 @@ class Display extends EventDispatcher { if (this._definitionTextScanner === null) { this._definitionTextScanner = new TextScanner({ node: window, - getOptionsContext: this.getOptionsContext.bind(this), + getSearchContext: this._getSearchContext.bind(this), documentUtil: this._documentUtil, searchTerms: true, searchKanji: false, @@ -1861,6 +1861,10 @@ class Display extends EventDispatcher { } } + _getSearchContext() { + return {optionsContext: this.getOptionsContext()}; + } + _startFrameResize(e) { if (this._frameResizeToken !== null) { return; } diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index 11a6f88f..98d87341 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -24,7 +24,7 @@ class TextScanner extends EventDispatcher { constructor({ node, documentUtil, - getOptionsContext, + getSearchContext, ignoreElements=null, ignorePoint=null, searchTerms=false, @@ -35,7 +35,7 @@ class TextScanner extends EventDispatcher { super(); this._node = node; this._documentUtil = documentUtil; - this._getOptionsContext = getOptionsContext; + this._getSearchContext = getSearchContext; this._ignoreElements = ignoreElements; this._ignorePoint = ignorePoint; this._searchTerms = searchTerms; @@ -290,8 +290,8 @@ class TextScanner extends EventDispatcher { // Private - async _getOptionsContextForInput(inputInfo) { - const optionsContext = clone(await this._getOptionsContext()); + _createOptionsContextForInput(baseOptionsContext, inputInfo) { + const optionsContext = clone(baseOptionsContext); const {modifiers, modifierKeys} = inputInfo; optionsContext.modifiers = [...modifiers]; optionsContext.modifierKeys = [...modifierKeys]; @@ -305,13 +305,16 @@ class TextScanner extends EventDispatcher { let error = null; let searched = false; let optionsContext = null; + let detail = null; try { if (this._textSourceCurrent !== null && this._textSourceCurrent.hasSameStart(textSource)) { return; } - optionsContext = await this._getOptionsContextForInput(inputInfo); + ({optionsContext, detail} = await this._getSearchContext()); + optionsContext = this._createOptionsContextForInput(optionsContext, inputInfo); + searched = true; const result = await this._findDefinitions(textSource, searchTerms, searchKanji, optionsContext); @@ -334,6 +337,7 @@ class TextScanner extends EventDispatcher { inputInfo, textSource, optionsContext, + detail, error }); } |