fix oob in notes and viewport
This commit is contained in:
@@ -177,6 +177,9 @@ func (t *FsTree) PerformAction(action FsActionType, name string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *FsTree) getViewportBounds() (startLine, endLine int) {
|
func (t *FsTree) getViewportBounds() (startLine, endLine int) {
|
||||||
|
if t.selectedNode == nil {
|
||||||
|
return 0, 0 // doesn't amtter in this case
|
||||||
|
}
|
||||||
selectedLine := t.selectedNode.line
|
selectedLine := t.selectedNode.line
|
||||||
halfHeight := t.height / 2
|
halfHeight := t.height / 2
|
||||||
|
|
||||||
|
|||||||
@@ -310,6 +310,9 @@ func extractHints(content string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m NoteView) renderNote() 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
|
var titleText, contentText string
|
||||||
if len(m.sections) > 0 {
|
if len(m.sections) > 0 {
|
||||||
titleText = m.sections[m.currentSectionIndex].Title
|
titleText = m.sections[m.currentSectionIndex].Title
|
||||||
@@ -330,8 +333,10 @@ func (m NoteView) renderNote() string {
|
|||||||
case StateContent:
|
case StateContent:
|
||||||
body, err2 = m.mdRenderer.Render(contentText)
|
body, err2 = m.mdRenderer.Render(contentText)
|
||||||
case StateHints:
|
case StateHints:
|
||||||
var currentHints []string
|
currentHints := []string{}
|
||||||
currentHints = m.sections[m.currentSectionIndex].Hints
|
if m.currentSectionIndex < len(m.sections) {
|
||||||
|
currentHints = m.sections[m.currentSectionIndex].Hints
|
||||||
|
}
|
||||||
|
|
||||||
if len(currentHints) == 0 {
|
if len(currentHints) == 0 {
|
||||||
body = "No hints available."
|
body = "No hints available."
|
||||||
|
|||||||
Reference in New Issue
Block a user