fix: add null check (#22474)
Sentry issue #22472 Add null check to detect when a line is deleted. e.g. upon deleting the last line.
This commit is contained in:
parent
ddccd8d24b
commit
4ae4c1ebce
|
|
@ -27,22 +27,24 @@ export const entityMarker: MarkHelper = (
|
|||
) => {
|
||||
let markers: CodeMirror.TextMarker[] = [];
|
||||
if (from && to) {
|
||||
markers = editor.findMarks(
|
||||
{
|
||||
line: from.line,
|
||||
ch: 0,
|
||||
},
|
||||
{
|
||||
line: to.line,
|
||||
// when a line is deleted?
|
||||
ch: editor.getLine(to.line).length - 1,
|
||||
},
|
||||
);
|
||||
clearMarkers(markers);
|
||||
const toLine = editor.getLine(to.line);
|
||||
if (toLine) {
|
||||
markers = editor.findMarks(
|
||||
{
|
||||
line: from.line,
|
||||
ch: 0,
|
||||
},
|
||||
{
|
||||
line: to.line,
|
||||
ch: toLine.length - 1,
|
||||
},
|
||||
);
|
||||
clearMarkers(markers);
|
||||
|
||||
editor.eachLine(from.line, to.line, (line: CodeMirror.LineHandle) => {
|
||||
addMarksForLine(editor, line, entityNavigationData);
|
||||
});
|
||||
editor.eachLine(from.line, to.line, (line: CodeMirror.LineHandle) => {
|
||||
addMarksForLine(editor, line, entityNavigationData);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
markers = editor.getAllMarks();
|
||||
clearMarkers(markers);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user