aboutsummaryrefslogtreecommitdiff
path: root/internal/app/state.go
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-11 04:20:56 +0000
committerFuwn <[email protected]>2026-02-11 04:20:56 +0000
commitccb25641712cc61fe30438c64313c6a1434b7966 (patch)
tree2a8f456cbcdafb6658fd558f3a236dc1a4287219 /internal/app/state.go
parentdocs(README): Add instructions to run with Nix (diff)
downloadfaustus-main.tar.xz
faustus-main.zip
fix(list): Constrain session list to terminal heightHEADmain
Diffstat (limited to 'internal/app/state.go')
-rw-r--r--internal/app/state.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/internal/app/state.go b/internal/app/state.go
index 6b24d80..aa9fb77 100644
--- a/internal/app/state.go
+++ b/internal/app/state.go
@@ -88,14 +88,14 @@ func (m *Model) reloadSessions() {
}
func (m *Model) ensureVisible() {
- visibleHeight := m.listHeight()
+ visible := m.visibleItemCount()
if m.cursor < m.offset {
m.offset = m.cursor
}
- if m.cursor >= m.offset+visibleHeight {
- m.offset = m.cursor - visibleHeight + 1
+ if m.cursor >= m.offset+visible {
+ m.offset = m.cursor - visible + 1
}
}
@@ -120,3 +120,11 @@ func (m Model) listHeight() int {
return max(1, m.height-reserved)
}
+
+func (m Model) visibleItemCount() int {
+ if m.showPreview {
+ return m.listHeight() - 2
+ }
+
+ return max(1, m.listHeight()/2)
+}