Skip to content

Commit

Permalink
fix(viewport): properly truncate to size
Browse files Browse the repository at this point in the history
  • Loading branch information
knz committed Aug 31, 2022
1 parent afd6f58 commit 306637a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions viewport/viewport.go
Expand Up @@ -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"))
}

Expand Down

0 comments on commit 306637a

Please sign in to comment.