From 0ade97639757f15979193013640cf73ee41ff420 Mon Sep 17 00:00:00 2001 From: James Maa Date: Tue, 11 Jun 2024 19:26:57 -0700 Subject: Fix semantics of disallowExpandSelection (#1051) * Fix semantics of disallowExpandSelection * Missed one --- ext/js/dom/text-source-range.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/js/dom/text-source-range.js b/ext/js/dom/text-source-range.js index 4a6f5e2f..7fd9fb69 100644 --- a/ext/js/dom/text-source-range.js +++ b/ext/js/dom/text-source-range.js @@ -150,7 +150,7 @@ export class TextSourceRange { const state = new DOMTextScanner(node, offset, !layoutAwareScan, layoutAwareScan).seek(length); this._range.setEnd(state.node, state.offset); const expandedContent = fromEnd ? this._content + state.content : state.content; - this._content = this._disallowExpandSelection ? expandedContent : this._content; + this._content = this._disallowExpandSelection ? this._content : expandedContent; return length - state.remainder; } @@ -257,7 +257,7 @@ export class TextSourceRange { * @returns {TextSourceRange} A new instance of the class corresponding to the range. */ static create(range) { - return new TextSourceRange(range, range.startOffset, range.toString(), null, null, null, null, true); + return new TextSourceRange(range, range.startOffset, range.toString(), null, null, null, null, false); } /** @@ -266,7 +266,7 @@ export class TextSourceRange { * @returns {TextSourceRange} A new instance of the class corresponding to the range. */ static createLazy(range) { - return new TextSourceRange(range, range.startOffset, range.toString(), null, null, null, null, false); + return new TextSourceRange(range, range.startOffset, range.toString(), null, null, null, null, true); } /** @@ -279,7 +279,7 @@ export class TextSourceRange { static createFromImposter(range, imposterElement, imposterSourceElement) { const cachedRects = convertMultipleRectZoomCoordinates(range.getClientRects(), range.startContainer); const cachedSourceRect = convertRectZoomCoordinates(imposterSourceElement.getBoundingClientRect(), imposterSourceElement); - return new TextSourceRange(range, range.startOffset, range.toString(), imposterElement, imposterSourceElement, cachedRects, cachedSourceRect, true); + return new TextSourceRange(range, range.startOffset, range.toString(), imposterElement, imposterSourceElement, cachedRects, cachedSourceRect, false); } /** -- cgit v1.2.3