1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-13 20:04:25 +02:00

support static boxes that go outside the available size

This commit is contained in:
Jesse Duffield
2021-04-11 12:12:26 +10:00
parent f2007f4d95
commit e3a14d546a
2 changed files with 26 additions and 0 deletions

View File

@@ -96,6 +96,11 @@ func ArrangeWindows(root *Box, x0, y0, width, height int) map[string]Dimensions
var boxSize int
if child.isStatic() {
boxSize = child.Size
// assuming that only one static child can have a size greater than the
// available space. In that case we just crop the size to what's available
if boxSize > availableSize {
boxSize = availableSize
}
} else {
// TODO: consider more evenly distributing the remainder
boxSize = unitSize * child.Weight

View File

@@ -179,6 +179,27 @@ func TestArrangeWindows(t *testing.T) {
)
},
},
{
"Box with static child with size too large",
&Box{Direction: COLUMN, Children: []*Box{{Size: 11, Window: "static"}, {Weight: 1, Window: "dynamic1"}, {Weight: 2, Window: "dynamic2"}}},
0,
0,
10,
10,
func(result map[string]Dimensions) {
assert.EqualValues(
t,
result,
map[string]Dimensions{
"static": {X0: 0, X1: 9, Y0: 0, Y1: 9},
// not sure if X0: 10, X1: 9 makes any sense, but testing this in the
// actual GUI it seems harmless
"dynamic1": {X0: 10, X1: 9, Y0: 0, Y1: 9},
"dynamic2": {X0: 10, X1: 9, Y0: 0, Y1: 9},
},
)
},
},
}
for _, s := range scenarios {