mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
See if this avoids the panic described in https://github.com/peco/peco/issues/359#issuecomment-255512262
This commit is contained in:
parent
5ad53b9f30
commit
72b05ececd
13
layout.go
13
layout.go
|
|
@ -640,7 +640,18 @@ func (l *BasicLayout) linesPerPage() int {
|
|||
reservedLines := 2 + extraOffset
|
||||
pp := height - reservedLines
|
||||
if pp < 1 {
|
||||
panic("linesPerPage is < 1 (height = " + strconv.Itoa(height) + ", reservedLines = " + strconv.Itoa(reservedLines) + ")")
|
||||
// This is an error condition, and while we probably should handle this
|
||||
// error more gracefully, the consumers of this method do not really
|
||||
// do anything with this error. I think it's just safe to "2", which just
|
||||
// means no space left to draw anything
|
||||
if pdebug.Enabled {
|
||||
pdebug.Printf(
|
||||
"linesPerPage is < 1 (height = %d, reservedLines = %d), forcing return value of 2",
|
||||
strconv.Itoa(height),
|
||||
strconv.Itoa(reservedLines),
|
||||
)
|
||||
}
|
||||
return 2
|
||||
}
|
||||
return pp
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue