Keep page in bounds after resetting terminal size

This commit is contained in:
Christian Rocha 2020-05-14 22:48:38 -04:00 committed by Christian Muehlhaeuser
commit 8bb2812a6b
2 changed files with 8 additions and 0 deletions

View file

@ -66,6 +66,12 @@ func (m *stashModel) SetSize(width, height int) {
// Update the paginator
perPage := (m.terminalHeight - topPadding - bottomPadding) / itemHeight
m.paginator.PerPage = perPage
m.paginator.SetTotalPages(len(m.documents))
// Make sure the page stays in bounds
if m.paginator.Page >= m.paginator.TotalPages-1 {
m.paginator.Page = m.paginator.TotalPages - 1
}
}
// INIT

View file

@ -151,6 +151,8 @@ func update(msg boba.Msg, mdl boba.Model) (boba.Model, boba.Cmd) {
m.terminalWidth = w
m.terminalHeight = h
m.stash.SetSize(w, h)
// TODO: load more stash pages if we've resized, are on the last page,
// and haven't loaded more pages yet.
return m, nil
case sshAuthErrMsg: