Skip to content

Commit

Permalink
Fix linkage of filter documents with headers
Browse files Browse the repository at this point in the history
Fixes misalignment of line number linkage
when the filter document has a header.

Add nil check as a precaution.
  • Loading branch information
noborus committed Oct 30, 2024
1 parent d736170 commit 7c7eb8f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion oviewer/doclist.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,14 @@ func (root *Root) nextDoc(ctx context.Context) {
func (root *Root) previousDoc(ctx context.Context) {
fromNum := root.CurrentDoc
fromDoc := root.getDocument(fromNum)
if fromDoc == nil {
return
}
toNum := root.CurrentDoc - 1
toDoc := root.getDocument(toNum)
if toDoc == nil {
return
}

root.setDocumentNum(ctx, toNum)
root.input.Event = normal()
Expand All @@ -135,7 +141,7 @@ func (root *Root) linkLineNum(fromDoc, toDoc *Document) {
}
if n, ok := fromDoc.lineNumMap.LoadForward(fromDoc.topLN + fromDoc.firstLine()); ok {
root.debugMessage("Move parent line number")
toDoc.moveLine(n)
toDoc.moveLine(n - toDoc.firstLine())
}
}

Expand Down

0 comments on commit 7c7eb8f

Please sign in to comment.