mirror of
https://github.com/walles/moar.git
synced 2024-11-30 12:42:26 +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
|
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 {
|
if firstHitPosition == nil {
|
||||||
// Try again from the top
|
// 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 {
|
if firstHitPosition == nil {
|
||||||
// No match, give up
|
// No match, give up
|
||||||
|
Loading…
Reference in New Issue
Block a user