diff options
| author | Kyren223 <Kyren223@proton.me> | 2024-12-23 16:51:33 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2024-12-23 16:51:33 +0200 |
| commit | 25f6fbc47648ff6b049f46946abcfc64ca4c2cc5 (patch) | |
| tree | 3983cf3d002e6516b8df005904b356c96d1ab0ce /internal/client/ui | |
| parent | 8d1174a2e1def95071f3d47ed99b8dae36a9caed (diff) | |
Excess messages now truncate instead of overflow viewport height
Diffstat (limited to 'internal/client/ui')
| -rw-r--r-- | internal/client/ui/core/chat/chat.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go index ab19069..d17b500 100644 --- a/internal/client/ui/core/chat/chat.go +++ b/internal/client/ui/core/chat/chat.go @@ -375,7 +375,25 @@ func (m *Model) renderMessages(height int) string { builder.WriteString(renderedGroups[i]) } - return builder.String() + result := builder.String() + + // Truncate any excess and show only the bottom + newlines := 0 + index := -1 + for i := len(result) - 1; i >= 0; i-- { + if result[i] == '\n' { + newlines++ + } + if newlines == height { + index = i + break + } + } + if index != -1 { + return result[index+1:] + } + + return result } func (m *Model) renderMessageGroup(group []data.Message, remaining *int, height int) string { |
