Skip to content

Commit

Permalink
fix(viewport): honor width and height settings
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Aug 30, 2022
1 parent 776062e commit d44e242
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions viewport/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d44e242

Please sign in to comment.