From 6ca8b70e66c657396007276fd3749801d23180f0 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Tue, 24 Dec 2024 16:45:52 +0200 Subject: Fixed a bug where headers won't render as "selected" when you hover over them --- internal/client/ui/core/chat/chat.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'internal/client/ui') diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go index 9d67468..16eeed2 100644 --- a/internal/client/ui/core/chat/chat.go +++ b/internal/client/ui/core/chat/chat.go @@ -473,18 +473,19 @@ func (m *Model) renderMessageGroup(group []data.Message, remaining *int, height buf = append(buf, '\n') } + buf = append(buf, '\n') // Gap between each message group + *remaining-- // For gap + selectedIndex := -1 for i, h := range heights { bottom := height - *remaining top := bottom + h *remaining -= h - if bottom < m.index && m.index <= top { + if bottom <= m.index && m.index <= top { selectedIndex = i } } - *remaining-- // For the header - buf = append(buf, '\n') // Gap between each message group - *remaining-- // For gap + *remaining-- // For the header if selectedIndex != -1 { if selectedIndex == len(group)-1 { @@ -566,6 +567,7 @@ func (m *Model) renderHeader(message data.Message, selected bool) []byte { } func (m *Model) Scroll(amount int) { + log.Println("SCROLL", m.index, amount) if m.index == -1 { if amount <= 0 { return @@ -588,7 +590,7 @@ func (m *Model) Scroll(amount int) { maxHeight = m.messagesHeight } if m.index >= maxHeight-1 { - m.offset = m.index+2 + m.offset = m.index + 2 } } else { // Scrolling down -- cgit v1.3.1