aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-04-30 12:50:12 +0300
committerTulir Asokan <tulir@maunium.net>2018-04-30 12:50:12 +0300
commit8346f65e3dd707db8b294e6d2e3a9f95bcbfb54a (patch)
tree28dfbe6d62e189ad2988d19eeedcec1c92fce861 /ui
parentc5ec94a78f712332dcbe8002d2d1ae9bd288a2c2 (diff)
Fix autoscrolling in room list when using keyboard. Fixes #34
Diffstat (limited to 'ui')
-rw-r--r--ui/room-list.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/ui/room-list.go b/ui/room-list.go
index 3a43872..03d9862 100644
--- a/ui/room-list.go
+++ b/ui/room-list.go
@@ -223,9 +223,10 @@ func (list *RoomList) SetSelected(tag string, room *rooms.Room) {
list.selectedTag = tag
pos := list.index(tag, room)
_, _, _, height := list.GetRect()
- if pos < list.scrollOffset || pos > list.scrollOffset+height {
- // TODO this does weird stuff sometimes, needs to be fixed
- //list.scrollOffset = pos
+ if pos <= list.scrollOffset {
+ list.scrollOffset = pos-1
+ } else if pos >= list.scrollOffset+height {
+ list.scrollOffset = pos-height+1
}
debug.Print("Selecting", room.GetTitle(), "in", list.GetTagDisplayName(tag))
}
@@ -358,6 +359,7 @@ func (list *RoomList) index(tag string, room *rooms.Room) int {
if localIndex == -1 {
return -1
}
+ localIndex = len(list.items[tag]) - 1 - localIndex
// Tag header
localIndex += 1