diff --git a/src/editor/caret.ts b/src/editor/caret.ts index b2b7846880..a4e4258ad6 100644 --- a/src/editor/caret.ts +++ b/src/editor/caret.ts @@ -43,6 +43,8 @@ function setDocumentRangeSelection(editor: HTMLDivElement, model: EditorModel, r } export function setCaretPosition(editor: HTMLDivElement, model: EditorModel, caretPosition: IPosition) { + if (model.isEmpty) return; // selection can't possibly be wrong, so avoid a reflow + const range = document.createRange(); const { node, offset } = getNodeAndOffsetForPosition(editor, model, caretPosition); range.setStart(node, offset);