From e64df67ec397795b8c6ebd06b391d953afe5a766 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 24 Apr 2018 16:51:40 +0300 Subject: Everything is no longer broken --- ui/room-list.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ui/room-list.go') diff --git a/ui/room-list.go b/ui/room-list.go index a70fd68..19202f8 100644 --- a/ui/room-list.go +++ b/ui/room-list.go @@ -210,7 +210,7 @@ func (list *RoomList) Clear() { func (list *RoomList) SetSelected(tag string, room *rooms.Room) { list.selected = room - list.selectedTag = "" + list.selectedTag = tag } func (list *RoomList) HasSelected() bool { @@ -264,7 +264,9 @@ func (list *RoomList) Previous() (string, *rooms.Room) { items := list.items[list.selectedTag] index := list.indexInTag(list.selectedTag, list.selected) - if index == len(items)-1 { + if index == -1 { + return list.First() + } else if index == len(items)-1 { tagIndex := list.IndexTag(list.selectedTag) tagIndex++ for ; tagIndex < len(list.tags); tagIndex++ { @@ -288,7 +290,9 @@ func (list *RoomList) Next() (string, *rooms.Room) { items := list.items[list.selectedTag] index := list.indexInTag(list.selectedTag, list.selected) - if index == 0 { + if index == -1 { + return list.Last() + } else if index == 0 { tagIndex := list.IndexTag(list.selectedTag) tagIndex-- for ; tagIndex >= 0; tagIndex-- { @@ -332,6 +336,8 @@ func (list *RoomList) Get(n int) (string, *rooms.Room) { // Tag items n -= len(items) + // Tag footer + n-- } return "", nil } @@ -420,5 +426,6 @@ func (list *RoomList) Draw(screen tcell.Screen) { break } } + y++ } } -- cgit v1.2.3