only append colon to user-pill when at start of composer
by passing position to autocomplete, so completion can depend on where the pill-candidate appears.
This commit is contained in:
parent
2ff2ff0e75
commit
c9572250be
2 changed files with 6 additions and 3 deletions
|
@ -65,10 +65,11 @@ export default class AutocompleteWrapperModel {
|
||||||
this._getAutocompleterComponent().moveSelection(+1);
|
this._getAutocompleterComponent().moveSelection(+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
onPartUpdate(part, offset) {
|
onPartUpdate(part, pos) {
|
||||||
// cache the typed value and caret here
|
// 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)
|
// so we can restore it in onComponentSelectionChange when the value is undefined (meaning it should be the typed text)
|
||||||
this._queryPart = part;
|
this._queryPart = part;
|
||||||
|
this._partIndex = pos.index;
|
||||||
return this._updateQuery(part.text);
|
return this._updateQuery(part.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +101,9 @@ export default class AutocompleteWrapperModel {
|
||||||
if (completionId === "@room") {
|
if (completionId === "@room") {
|
||||||
return [this._partCreator.atRoomPill(completionId)];
|
return [this._partCreator.atRoomPill(completionId)];
|
||||||
} else {
|
} 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 "#":
|
case "#":
|
||||||
|
|
|
@ -226,7 +226,7 @@ export default class EditorModel {
|
||||||
}
|
}
|
||||||
// not _autoComplete, only there if active part is autocomplete part
|
// not _autoComplete, only there if active part is autocomplete part
|
||||||
if (this.autoComplete) {
|
if (this.autoComplete) {
|
||||||
return this.autoComplete.onPartUpdate(part, pos.offset);
|
return this.autoComplete.onPartUpdate(part, pos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this._activePartIdx = null;
|
this._activePartIdx = null;
|
||||||
|
|
Loading…
Reference in a new issue