diff --git a/src/editor/model.js b/src/editor/model.js index a121c67b48..3b4f1ce460 100644 --- a/src/editor/model.js +++ b/src/editor/model.js @@ -388,7 +388,11 @@ export default class EditorModel { currentOffset += partLen; return false; }); - return new DocumentPosition(index, totalOffset - currentOffset); + if (index === -1) { + return this.getPositionAtEnd(); + } else { + return new DocumentPosition(index, totalOffset - currentOffset); + } } /**