From dedf9789485eb9110f02b46dcbb8d9a26e7aea6f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 11 Jul 2019 18:33:22 +0200 Subject: [PATCH] prevent inserting parts at index -1 for empty documents --- src/editor/model.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/editor/model.js b/src/editor/model.js index 778797dad2..4e39c70c4c 100644 --- a/src/editor/model.js +++ b/src/editor/model.js @@ -244,6 +244,10 @@ export default class EditorModel { addLen += part.text.length - offset; index += 1; } + } else if (index < 0) { + // if position was not found (index: -1, as happens for empty editor) + // reset it to insert as first part + index = 0; } while (str) { const newPart = this._partCreator.createPartForInput(str);