diff --git a/src/editor/autocomplete.js b/src/editor/autocomplete.js index 67015b72e1..d3b8f713b9 100644 --- a/src/editor/autocomplete.js +++ b/src/editor/autocomplete.js @@ -65,10 +65,11 @@ export default class AutocompleteWrapperModel { this._getAutocompleterComponent().moveSelection(+1); } - onPartUpdate(part, offset) { + onPartUpdate(part, pos) { // cache the typed value and caret here // so we can restore it in onComponentSelectionChange when the value is undefined (meaning it should be the typed text) this._queryPart = part; + this._partIndex = pos.index; return this._updateQuery(part.text); } @@ -100,7 +101,9 @@ export default class AutocompleteWrapperModel { if (completionId === "@room") { return [this._partCreator.atRoomPill(completionId)]; } else { - return [this._partCreator.userPill(text, completionId), this._partCreator.plain(": ")]; + const pill = this._partCreator.userPill(text, completionId); + const postfix = this._partCreator.plain(this._partIndex === 0 ? ": " : " "); + return [pill, postfix]; } } case "#": diff --git a/src/editor/model.js b/src/editor/model.js index 4b8405adef..734d96393f 100644 --- a/src/editor/model.js +++ b/src/editor/model.js @@ -226,7 +226,7 @@ export default class EditorModel { } // not _autoComplete, only there if active part is autocomplete part if (this.autoComplete) { - return this.autoComplete.onPartUpdate(part, pos.offset); + return this.autoComplete.onPartUpdate(part, pos); } } else { this._activePartIdx = null;