From 306637a26c1c0d789b6a3bcc7fbde20df3d4e222 Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Wed, 31 Aug 2022 19:24:15 +0200 Subject: [PATCH] fix(viewport): properly truncate to size --- viewport/viewport.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/viewport/viewport.go b/viewport/viewport.go index 173c0b51..a2f708e9 100644 --- a/viewport/viewport.go +++ b/viewport/viewport.go @@ -349,10 +349,11 @@ func (m Model) View() string { // position anything below this view properly. return strings.Repeat("\n", max(0, m.Height-1)) } - + contentWidth := m.Width - m.Style.GetHorizontalFrameSize() + contentHeight := m.Height - m.Style.GetVerticalFrameSize() return m.Style.Copy(). - Width(m.Width - m.Style.GetHorizontalFrameSize()). - Height(m.Height - m.Style.GetVerticalFrameSize()). + UnsetWidth().MaxWidth(contentWidth). // truncate long lines. + Height(contentHeight).MaxHeight(contentHeight). // pad to height then truncate. Render(strings.Join(m.visibleLines(), "\n")) }