mirror of
https://github.com/walles/moar.git
synced 2024-10-26 13:00:40 +03:00
Fix the warnings
This commit is contained in:
parent
f0e11a4e0e
commit
b835e9a23d
@ -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)
|
||||
|
24
m/search.go
24
m/search.go
@ -6,30 +6,6 @@ import (
|
||||
"github.com/walles/moar/m/linenumbers"
|
||||
)
|
||||
|
||||
func (p *Pager) scrollToSearchHits() {
|
||||
if p.searchPattern == nil {
|
||||
// This is not a search
|
||||
return
|
||||
}
|
||||
|
||||
firstHitPosition := p.findFirstHit(*p.scrollPosition.lineNumber(p), nil, false)
|
||||
if firstHitPosition == nil {
|
||||
// Try again from the top
|
||||
firstHitPosition = p.findFirstHit(linenumbers.LineNumber{}, p.scrollPosition.lineNumber(p), 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 we're using a line number rather than a
|
||||
// scrollPosition for searching.
|
||||
|
Loading…
Reference in New Issue
Block a user