summaryrefslogtreecommitdiff
path: root/ext/js/dom
diff options
context:
space:
mode:
authorJames Maa <jmaa@berkeley.edu>2024-06-14 09:48:42 -0700
committerGitHub <noreply@github.com>2024-06-14 16:48:42 +0000
commit3dda522244ed5d7c20636a115c516d2cff5850fb (patch)
treeb45aa7040668a9658f78c3cfdca62c0cf5e80a59 /ext/js/dom
parente4331ab90ee605e073139e20772d5ec69110ec1e (diff)
Don't move offset when disallowExpandSelection is true (#1065)
* Don't move offset when disallowExpandSelection is true * merge conflict
Diffstat (limited to 'ext/js/dom')
-rw-r--r--ext/js/dom/text-source-range.js5
1 files changed, 4 insertions, 1 deletions
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;