Fix setEndOffset (#2214)
* Add _layoutAwareScan option to TextSourceElement.setEndOffset for parity * Remove default param
This commit is contained in:
parent
c5c5308ff2
commit
cd0a6b60e2
@ -60,7 +60,7 @@ class TextSourceElement {
|
||||
return this._content;
|
||||
}
|
||||
|
||||
setEndOffset(length, fromEnd=false) {
|
||||
setEndOffset(length, _layoutAwareScan, fromEnd) {
|
||||
if (fromEnd) {
|
||||
const delta = Math.min(this._fullContent.length - this._endOffset, length);
|
||||
this._endOffset += delta;
|
||||
|
@ -66,7 +66,7 @@ class TextSourceRange {
|
||||
return this._content;
|
||||
}
|
||||
|
||||
setEndOffset(length, layoutAwareScan, fromEnd=false) {
|
||||
setEndOffset(length, layoutAwareScan, fromEnd) {
|
||||
const state = (
|
||||
fromEnd ?
|
||||
new DOMTextScanner(this._range.endContainer, this._range.endOffset, !layoutAwareScan, layoutAwareScan).seek(length) :
|
||||
|
@ -226,7 +226,7 @@ class TextScanner extends EventDispatcher {
|
||||
getTextSourceContent(textSource, length, layoutAwareScan) {
|
||||
const clonedTextSource = textSource.clone();
|
||||
|
||||
clonedTextSource.setEndOffset(length, layoutAwareScan);
|
||||
clonedTextSource.setEndOffset(length, layoutAwareScan, false);
|
||||
|
||||
const includeSelector = this._includeSelector;
|
||||
const excludeSelector = this._excludeSelector;
|
||||
@ -872,7 +872,7 @@ class TextScanner extends EventDispatcher {
|
||||
const {dictionaryEntries, originalTextLength} = await yomichan.api.termsFind(searchText, details, optionsContext);
|
||||
if (dictionaryEntries.length === 0) { return null; }
|
||||
|
||||
textSource.setEndOffset(originalTextLength, layoutAwareScan);
|
||||
textSource.setEndOffset(originalTextLength, layoutAwareScan, false);
|
||||
const sentence = this._documentUtil.extractSentence(
|
||||
textSource,
|
||||
layoutAwareScan,
|
||||
@ -899,7 +899,7 @@ class TextScanner extends EventDispatcher {
|
||||
const dictionaryEntries = await yomichan.api.kanjiFind(searchText, optionsContext);
|
||||
if (dictionaryEntries.length === 0) { return null; }
|
||||
|
||||
textSource.setEndOffset(1, layoutAwareScan);
|
||||
textSource.setEndOffset(1, layoutAwareScan, false);
|
||||
const sentence = this._documentUtil.extractSentence(
|
||||
textSource,
|
||||
layoutAwareScan,
|
||||
@ -1121,7 +1121,7 @@ class TextScanner extends EventDispatcher {
|
||||
(excludeSelector !== null && DocumentUtil.anyNodeMatchesSelector(nodes, excludeSelector))
|
||||
) {
|
||||
--length;
|
||||
textSource.setEndOffset(length, layoutAwareScan);
|
||||
textSource.setEndOffset(length, layoutAwareScan, false);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user