2
0
mirror of https://github.com/rivo/tview.git synced 2024-11-15 06:12:46 +00:00

Avoid div-by-0 in case Flex item sizes are all 0. Resolves #332, resolves #334

This commit is contained in:
Oliver 2019-10-17 11:33:25 +02:00
parent f8bc69b903
commit de7ae86b5b

10
flex.go
View File

@ -149,9 +149,13 @@ func (f *Flex) Draw(screen tcell.Screen) {
for _, item := range f.items {
size := item.FixedSize
if size <= 0 {
size = distSize * item.Proportion / proportionSum
distSize -= size
proportionSum -= item.Proportion
if proportionSum > 0 {
size = distSize * item.Proportion / proportionSum
distSize -= size
proportionSum -= item.Proportion
} else {
size = 0
}
}
if item.Item != nil {
if f.direction == FlexColumn {