From 3dda522244ed5d7c20636a115c516d2cff5850fb Mon Sep 17 00:00:00 2001 From: James Maa Date: Fri, 14 Jun 2024 09:48:42 -0700 Subject: Don't move offset when disallowExpandSelection is true (#1065) * Don't move offset when disallowExpandSelection is true * merge conflict --- ext/js/dom/text-source-range.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ext/js') diff --git a/ext/js/dom/text-source-range.js b/ext/js/dom/text-source-range.js index 7fd9fb69..2d906842 100644 --- a/ext/js/dom/text-source-range.js +++ b/ext/js/dom/text-source-range.js @@ -138,6 +138,7 @@ export class TextSourceRange { * @returns {number} The actual number of codepoints that were read. */ setEndOffset(length, fromEnd, layoutAwareScan) { + if (this._disallowExpandSelection) { return 0; } let node; let offset; if (fromEnd) { @@ -150,10 +151,11 @@ 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 ? this._content : expandedContent; + this._content = expandedContent; return length - state.remainder; } + /** * Moves the start offset of the text by a set amount of unicode codepoints. * @param {number} length The maximum number of codepoints to move by. @@ -162,6 +164,7 @@ export class TextSourceRange { * @returns {number} The actual number of codepoints that were read. */ setStartOffset(length, layoutAwareScan) { + if (this._disallowExpandSelection) { return 0; } const state = new DOMTextScanner(this._range.startContainer, this._range.startOffset, !layoutAwareScan, layoutAwareScan).seek(-length); this._range.setStart(state.node, state.offset); this._rangeStartOffset = this._range.startOffset; -- cgit v1.2.3