mirror of
https://github.com/walles/moar.git
synced 2024-11-27 01:05:23 +03:00
Don't crash searching in empty buffer
This commit is contained in:
parent
64ae443e1f
commit
60d3577b59
10
m/search.go
10
m/search.go
@ -15,10 +15,16 @@ func (p *Pager) scrollToSearchHits() {
|
||||
return
|
||||
}
|
||||
|
||||
firstHitPosition := p.findFirstHit(*p.scrollPosition.lineNumber(p), nil, false)
|
||||
lineNumber := p.scrollPosition.lineNumber(p)
|
||||
if lineNumber == nil {
|
||||
// No lines to search
|
||||
return
|
||||
}
|
||||
|
||||
firstHitPosition := p.findFirstHit(*lineNumber, nil, false)
|
||||
if firstHitPosition == nil {
|
||||
// Try again from the top
|
||||
firstHitPosition = p.findFirstHit(linenumbers.LineNumber{}, p.scrollPosition.lineNumber(p), false)
|
||||
firstHitPosition = p.findFirstHit(linenumbers.LineNumber{}, lineNumber, false)
|
||||
}
|
||||
if firstHitPosition == nil {
|
||||
// No match, give up
|
||||
|
Loading…
Reference in New Issue
Block a user