mirror of
https://github.com/walles/moar.git
synced 2024-11-22 21:50:43 +03:00
Handle a potential null value
I don't understand how this happens, but: * It's uncommon * It's been reported once during startup * I'm assuming this is a race condition during startup * Let's just treat the scroll position as zero if unset Then let's cross our fingers and hope we don't crash anywhere else in this situation. Fixes: https://github.com/walles/moar/issues/198
This commit is contained in:
parent
e92b01da07
commit
056c766bd3
@ -386,7 +386,12 @@ func numberPrefixLength(pager *Pager, scrollPosition scrollPositionInternal) int
|
||||
// recursion.
|
||||
//
|
||||
// Let's improve on demand.
|
||||
maxVisibleLineNumber := scrollPosition.lineNumber.NonWrappingAdd(
|
||||
var lineNumber linenumbers.LineNumber
|
||||
// Ref: https://github.com/walles/moar/issues/198
|
||||
if scrollPosition.lineNumber != nil {
|
||||
lineNumber = *scrollPosition.lineNumber
|
||||
}
|
||||
maxVisibleLineNumber := lineNumber.NonWrappingAdd(
|
||||
scrollPosition.deltaScreenLines +
|
||||
pager.visibleHeight() - 1)
|
||||
if maxVisibleLineNumber.IsAfter(maxPossibleLineNumber) {
|
||||
|
Loading…
Reference in New Issue
Block a user