1
1
mirror of https://github.com/walles/moar.git synced 2024-08-16 15:30:34 +03:00

Fix the warnings

This commit is contained in:
Johan Walles 2024-05-15 20:34:01 +02:00
parent 6325a1cd95
commit 5eb548a126
2 changed files with 4 additions and 31 deletions

View File

@ -446,7 +446,10 @@ func (p *Pager) StartPaging(screen twin.Screen, chromaStyle *chroma.Style, chrom
// Do nothing, we don't care about background color updates
case eventGoToLine:
p.scrollPosition = NewScrollPositionFromLineNumber(event.lineNumber, "goToLine")
line := NewScrollPositionFromLineNumber(event.lineNumber, "goToLine")
if !line.isVisible(p) {
p.scrollPosition = line
}
default:
log.Warnf("Unhandled event type: %v", event)

View File

@ -10,36 +10,6 @@ import (
"github.com/walles/moar/m/linenumbers"
)
func (p *Pager) scrollToSearchHits() {
if p.searchPattern == nil {
// This is not a search
return
}
lineNumber := p.scrollPosition.lineNumber(p)
if lineNumber == nil {
// No lines to search
return
}
firstHitPosition := p.findFirstHit(*lineNumber, nil, false)
if firstHitPosition == nil && (*lineNumber != linenumbers.LineNumber{}) {
// Try again from the top
firstHitPosition = p.findFirstHit(linenumbers.LineNumber{}, lineNumber, false)
}
if firstHitPosition == nil {
// No match, give up
return
}
if firstHitPosition.isVisible(p) {
// Already on-screen, never mind
return
}
p.scrollPosition = *firstHitPosition
}
// NOTE: When we search, we do that by looping over the *input lines*, not the
// screen lines. That's why startPosition is a LineNumber rather than a
// scrollPosition.