fix: dont highlight out of range

This commit is contained in:
Felix Roos 2022-04-29 21:14:37 +02:00
parent cf922b036e
commit 9e46b3cd00

View File

@ -26,8 +26,13 @@ const highlightField = StateField.define({
.map(({ start, end }) => {
let from = tr.newDoc.line(start.line).from + start.column;
let to = tr.newDoc.line(end.line).from + end.column;
const l = tr.newDoc.length;
if (from > l || to > l) {
return;
}
return highlightMark.range(from, to);
}),
})
.filter(Boolean),
true,
);
}