summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Slenders <jonathan@slenders.be>2015-12-07 20:44:27 +0100
committerJonathan Slenders <jonathan@slenders.be>2015-12-07 20:44:27 +0100
commitce20bcbac9519a065e9f2e58e6f257470ece9397 (patch)
tree327dc77f197d5e7f259e10fe7843720e549adcb6
parent34b4c82c2e38aa977d8482b4578303505b67f89e (diff)
Correctly handle HSplit/VSplit instances without children.
-rw-r--r--prompt_toolkit/layout/containers.py6
-rw-r--r--prompt_toolkit/utils.py1
2 files changed, 7 insertions, 0 deletions
diff --git a/prompt_toolkit/layout/containers.py b/prompt_toolkit/layout/containers.py
index 2b0e20d7..035af995 100644
--- a/prompt_toolkit/layout/containers.py
+++ b/prompt_toolkit/layout/containers.py
@@ -157,6 +157,9 @@ class HSplit(Container):
Return the heights for all rows.
Or None when there is not enough space.
"""
+ if not self.children:
+ return []
+
# Calculate heights.
given_dimensions = self.get_dimensions(cli) if self.get_dimensions else None
@@ -260,6 +263,9 @@ class VSplit(Container):
Return the widths for all columns.
Or None when there is not enough space.
"""
+ if not self.children:
+ return []
+
# Calculate widths.
given_dimensions = self.get_dimensions(cli) if self.get_dimensions else None
diff --git a/prompt_toolkit/utils.py b/prompt_toolkit/utils.py
index 0c49bb3f..d2f8606d 100644
--- a/prompt_toolkit/utils.py
+++ b/prompt_toolkit/utils.py
@@ -194,6 +194,7 @@ def take_using_weights(items, weights):
assert isinstance(weights, list)
assert all(isinstance(i, int) for i in weights)
assert len(items) == len(weights)
+ assert len(items) > 0
already_taken = [0 for i in items]
item_count = len(items)