From 607fc328ed775579579fe48170dafd30e701e4e2 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 19 Jun 2019 10:57:29 +0200 Subject: [PATCH] also process first part when processing empty and mergeable parts this was preventing clearing an emtpy plain part when inserting a pill-candidate at the beginning of the model, which prevented a caret node from being inserted before the pill. --- src/editor/model.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/editor/model.js b/src/editor/model.js index 7cc6041044..c8fa20efce 100644 --- a/src/editor/model.js +++ b/src/editor/model.js @@ -158,11 +158,11 @@ export default class EditorModel { } _mergeAdjacentParts(docPos) { - let prevPart = this._parts[0]; - for (let i = 1; i < this._parts.length; ++i) { + let prevPart; + for (let i = 0; i < this._parts.length; ++i) { let part = this._parts[i]; const isEmpty = !part.text.length; - const isMerged = !isEmpty && prevPart.merge(part); + const isMerged = !isEmpty && prevPart && prevPart.merge(part); if (isEmpty || isMerged) { // remove empty or merged part part = prevPart;