Merge pull request #5830 from SimonBrandner/fix-trailing-colon

Fix inserting trailing colon after mention/pill
This commit is contained in:
Travis Ralston 2021-04-28 09:51:50 -06:00 committed by GitHub
commit 14f1388522
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 9 deletions

View file

@ -125,10 +125,8 @@ export default class AutocompleteWrapperModel {
case "at-room":
return [this.partCreator.atRoomPill(completionId), this.partCreator.plain(completion.suffix)];
case "user":
// not using suffix here, because we also need to calculate
// the suffix when clicking a display name to insert a mention,
// which happens in createMentionParts
return this.partCreator.createMentionParts(this.partIndex, text, completionId);
// Insert suffix only if the pill is the part with index 0 - we are at the start of the composer
return this.partCreator.createMentionParts(this.partIndex === 0, text, completionId);
case "command":
// command needs special handling for auto complete, but also renders as plain texts
return [(this.partCreator as CommandPartCreator).command(text)];

View file

@ -535,9 +535,9 @@ export class PartCreator {
return new UserPillPart(userId, displayName, member);
}
createMentionParts(partIndex: number, displayName: string, userId: string) {
createMentionParts(insertTrailingCharacter: boolean, displayName: string, userId: string) {
const pill = this.userPill(displayName, userId);
const postfix = this.plain(partIndex === 0 ? ": " : " ");
const postfix = this.plain(insertTrailingCharacter ? ": " : " ");
return [pill, postfix];
}
}