mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 09:42:34 +02:00
Change paginator dots when no entry
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -242,8 +242,13 @@ func (m Model) updateEditMode(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
|
||||
|
||||
func (m *Model) refreshListViewport() {
|
||||
if m.pager.PerPage > 0 {
|
||||
m.pager.Page = m.cursor / m.pager.PerPage
|
||||
m.pager.SetTotalPages(len(m.entries))
|
||||
if len(m.entries) == 0 {
|
||||
m.pager.Page = 0
|
||||
m.pager.TotalPages = 0
|
||||
} else {
|
||||
m.pager.Page = m.cursor / m.pager.PerPage
|
||||
m.pager.SetTotalPages(len(m.entries))
|
||||
}
|
||||
}
|
||||
m.listViewport.SetContent(m.renderList())
|
||||
}
|
||||
|
||||
@@ -37,7 +37,10 @@ func (m *Model) renderListPanel(w, h int) string {
|
||||
if m.editing {
|
||||
panelStyle = s.Panel
|
||||
}
|
||||
dots := s.Faint.Render(m.pager.View())
|
||||
var dots string
|
||||
if len(m.entries) > 0 {
|
||||
dots = s.Faint.Render(m.pager.View())
|
||||
}
|
||||
inner := lipgloss.JoinVertical(lipgloss.Left,
|
||||
m.listViewport.View(),
|
||||
lipgloss.PlaceHorizontal(m.listViewport.Width(), lipgloss.Center, dots),
|
||||
|
||||
Reference in New Issue
Block a user