message: fix autocompl. not always appearing/being updated when there is no part
diff: @@ -88,6 +88,7 @@ export default class EditorModel {
  this._addText(position, diff.added);
  }
  this._mergeAdjacentParts();
  + // TODO: now that parts can be outright deleted, this doesn't make sense anymore
  const caretOffset = diff.at + (diff.added ? diff.added.length : 0);
  const newPosition = this._positionForOffset(caretOffset, true);
  this._setActivePart(newPosition);
  @@ -97,9 +98,9 @@ export default class EditorModel {
  _setActivePart(pos) {
  const {index} = pos;
  const part = this._parts[index];
  - if (pos.index !== this._activePartIdx) {
  + if (part) {
  + if (index !== this._activePartIdx) {
  this._activePartIdx = index;
  - // if there is a hidden autocomplete for this part, show it again
  if (this._activePartIdx !== this._autoCompletePartIdx) {
  // else try to create one
  const ac = part.createAutoComplete(this._onAutoComplete);
  @@ -110,8 +111,14 @@ export default class EditorModel {
  }
  }
  }
  - if (this._autoComplete) {
  - this._autoComplete.onPartUpdate(part, pos.offset);
  + // not _autoComplete, only there if active part is autocomplete part
  + if (this.autoComplete) {
  + this.autoComplete.onPartUpdate(part, pos.offset);
  + }
  + } else {
  + this._activePartIdx = null;
  + this._autoComplete = null;
  + this._autoCompletePartIdx = null;
  }
  }
  @@ -181,6 +188,7 @@ export default class EditorModel {
  let {index, offset} = pos;
  const part = this._parts[index];
  if (part) {
  + if (part.canEdit) {
  if (part.insertAll(offset, str)) {
  str = null;
  } else {
  @@ -190,6 +198,10 @@ export default class EditorModel {
  index += 1;
  this._insertPart(index, splitPart);
  }
  + } else {
  + // insert str after this part
  + index += 1;
  + }
  }
  while (str) {
  const newPart = this._partCreator.createPartForInput(str);
  