diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-04-24 16:51:40 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-04-24 16:51:40 +0300 |
commit | e64df67ec397795b8c6ebd06b391d953afe5a766 (patch) | |
tree | 52cbb9d3d02ec1e89d0de09a05d343408c7d4aba /ui/room-list.go | |
parent | fcd9a932cb5542ed8980fc1daba7ee1f0041a3f2 (diff) |
Everything is no longer broken
Diffstat (limited to 'ui/room-list.go')
-rw-r--r-- | ui/room-list.go | 13 |
1 files changed, 10 insertions, 3 deletions
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++ } } |