From d7d654e2ec0a1d001f936b1575a3e6af3973a874 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 24 Apr 2018 22:49:41 +0300 Subject: Flatten calculateBufferWithText() and gofmt --- ui/messages/textbase.go | 20 ++++++++++++-------- ui/room-list.go | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ui/messages/textbase.go b/ui/messages/textbase.go index 79913f8..f44d5d5 100644 --- a/ui/messages/textbase.go +++ b/ui/messages/textbase.go @@ -72,14 +72,18 @@ func (msg *BaseTextMessage) calculateBufferWithText(text tstring.TString, width } matches := boundaryPattern.FindAllStringIndex(extract.String(), -1) - if len(matches) > 0 { - match := matches[len(matches)-1] - if len(match) > 1 { - until := match[1] - if until < len(extract) { - extract = extract[:until] - } - } + if len(matches) == 0 { + continue + } + + match := matches[len(matches)-1] + if len(match) < 2 { + continue + } + + until := match[1] + if until < len(extract) { + extract = extract[:until] } } msg.buffer = append(msg.buffer, extract) diff --git a/ui/room-list.go b/ui/room-list.go index d361a12..9444313 100644 --- a/ui/room-list.go +++ b/ui/room-list.go @@ -58,7 +58,7 @@ func NewRoomList() *RoomList { return &RoomList{ Box: tview.NewBox(), items: make(map[string][]*rooms.Room), - tags: []string{"m.favourite", "im.vector.fake.direct", "", "m.lowpriority"}, + tags: []string{"m.favourite", "im.vector.fake.direct", "", "m.lowpriority"}, mainTextColor: tcell.ColorWhite, selectedTextColor: tcell.ColorWhite, @@ -95,7 +95,7 @@ func (list *RoomList) CheckTag(tag string) { if ok && index == -1 { list.tags = append(list.tags, tag) - }/* TODO this doesn't work properly + } /* TODO this doesn't work properly else if index != -1 { list.tags = append(list.tags[0:index], list.tags[index+1:]...) }*/ -- cgit v1.2.3