From 9e46b3cd00ef0529b4bf4a7f9bba52aac499838d Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 29 Apr 2022 21:14:37 +0200 Subject: [PATCH] fix: dont highlight out of range --- repl/src/CodeMirror6.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/repl/src/CodeMirror6.jsx b/repl/src/CodeMirror6.jsx index c182b702..37a6a49e 100644 --- a/repl/src/CodeMirror6.jsx +++ b/repl/src/CodeMirror6.jsx @@ -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, ); }