From d44e242f37edf93a0178fe02bdac865b2e1529ab Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 17 Aug 2022 14:42:55 -0700 Subject: [PATCH] fix(viewport): honor width and height settings --- viewport/viewport.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/viewport/viewport.go b/viewport/viewport.go index c46df72..173c0b5 100644 --- a/viewport/viewport.go +++ b/viewport/viewport.go @@ -350,18 +350,10 @@ func (m Model) View() string { return strings.Repeat("\n", max(0, m.Height-1)) } - lines := m.visibleLines() - - // Fill empty space with newlines - extraLines := "" - if len(lines) < m.Height { - extraLines = strings.Repeat("\n", max(0, m.Height-len(lines))) - } - return m.Style.Copy(). - UnsetWidth(). - UnsetHeight(). - Render(strings.Join(lines, "\n") + extraLines) + Width(m.Width - m.Style.GetHorizontalFrameSize()). + Height(m.Height - m.Style.GetVerticalFrameSize()). + Render(strings.Join(m.visibleLines(), "\n")) } func clamp(v, low, high int) int {