fix(viewport): honor width and height settings

This commit is contained in:
Christian Rocha 2022-08-17 14:42:55 -07:00
parent 776062e30c
commit d44e242f37

View File

@ -350,18 +350,10 @@ func (m Model) View() string {
return strings.Repeat("\n", max(0, m.Height-1)) 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(). return m.Style.Copy().
UnsetWidth(). Width(m.Width - m.Style.GetHorizontalFrameSize()).
UnsetHeight(). Height(m.Height - m.Style.GetVerticalFrameSize()).
Render(strings.Join(lines, "\n") + extraLines) Render(strings.Join(m.visibleLines(), "\n"))
} }
func clamp(v, low, high int) int { func clamp(v, low, high int) int {