From 3750d5007fe31b1a4d706357f43774d08944213e Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 18 Apr 2018 13:38:33 +0300 Subject: Create pills when tab-completing or clicking nicks --- ui/view-main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ui/view-main.go') diff --git a/ui/view-main.go b/ui/view-main.go index d4ffd39..018fb1a 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -104,17 +104,22 @@ func findWordToTabComplete(text string) string { func (view *MainView) InputTabComplete(roomView *RoomView, text string, cursorOffset int) string { str := runewidth.Truncate(text, cursorOffset, "") word := findWordToTabComplete(str) + userCompletions := roomView.AutocompleteUser(word) if len(userCompletions) == 1 { startIndex := len(str) - len(word) - completion := userCompletions[0] + member := userCompletions[0] + completion := fmt.Sprintf("[%s](https://matrix.to/#/%s)", member.DisplayName, member.UserID) if startIndex == 0 { completion = completion + ": " } text = str[0:startIndex] + completion + text[len(str):] - } else if len(userCompletions) > 1 && len(userCompletions) < 6 { - roomView.SetStatus(fmt.Sprintf("Completions: %s", strings.Join(userCompletions, ", "))) + } else if len(userCompletions) > 1 && len(userCompletions) <= 5 { + // roomView.SetStatus(fmt.Sprintf("Completions: %s", strings.Join(userCompletions, ", "))) + } else if len(userCompletions) > 5 { + roomView.SetStatus("Over 5 completion options.") } + return text } -- cgit v1.2.3