From 1aaeec8e12ab221c68b68f1b249d9a310ad172e3 Mon Sep 17 00:00:00 2001 From: ruinivist Date: Sun, 4 Jan 2026 17:11:01 +0000 Subject: [PATCH] fix oob in notes and viewport --- fstree.go | 3 +++ notes.go | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fstree.go b/fstree.go index 7a65f96..b8f8c32 100644 --- a/fstree.go +++ b/fstree.go @@ -177,6 +177,9 @@ func (t *FsTree) PerformAction(action FsActionType, name string) error { } func (t *FsTree) getViewportBounds() (startLine, endLine int) { + if t.selectedNode == nil { + return 0, 0 // doesn't amtter in this case + } selectedLine := t.selectedNode.line halfHeight := t.height / 2 diff --git a/notes.go b/notes.go index e22164f..42dd19f 100644 --- a/notes.go +++ b/notes.go @@ -310,6 +310,9 @@ func extractHints(content string) []string { } func (m NoteView) renderNote() string { + if m.path == "" { + return "" // no note is loaded, don't need to bother with anything + } var titleText, contentText string if len(m.sections) > 0 { titleText = m.sections[m.currentSectionIndex].Title @@ -330,8 +333,10 @@ func (m NoteView) renderNote() string { case StateContent: body, err2 = m.mdRenderer.Render(contentText) case StateHints: - var currentHints []string - currentHints = m.sections[m.currentSectionIndex].Hints + currentHints := []string{} + if m.currentSectionIndex < len(m.sections) { + currentHints = m.sections[m.currentSectionIndex].Hints + } if len(currentHints) == 0 { body = "No hints available."