fix(web): correct getExtent

Co-authored-by: Will Lillis <will.lillis24@gmail.com>
This commit is contained in:
Amaan Qureshi 2025-01-06 01:09:44 -05:00
parent 45fa028201
commit 2814c00faa

View file

@ -396,14 +396,16 @@ function spliceInput(input, startIndex, lengthRemoved, newText) {
];
}
// Gets the extent of the text in terms of zero-based row and column numbers.
function getExtent(text) {
let row = 0;
let index;
for (index = 0; index !== -1; index = text.indexOf('\n', index)) {
index++;
let index = -1;
let lastIndex = 0;
while ((index = text.indexOf('\n', index + 1)) !== -1) {
row++;
lastIndex = index + 1;
}
return {row, column: text.length - index};
return {row, column: text.length - lastIndex};
}
function assertCursorState(cursor, params) {