mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-09 09:49:09 +02:00
Keep page in bounds after resetting terminal size
This commit is contained in:
parent
7ea79793d7
commit
8bb2812a6b
2 changed files with 8 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
2
ui/ui.go
2
ui/ui.go
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue