From 81720d51e6b52a539dbd29c4d01881bb3a4442cd Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Fri, 19 May 2023 00:38:32 -0400 Subject: [PATCH] Safety --- src/textual_paint/paint.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/textual_paint/paint.py b/src/textual_paint/paint.py index ddd3875..0da5ac7 100755 --- a/src/textual_paint/paint.py +++ b/src/textual_paint/paint.py @@ -1403,7 +1403,10 @@ class AnsiArtDocument: x = int((x - min_x) / cell_width) y = int((y - min_y) / cell_height) if fill is not None: - document.bg[y][x] = fill + try: + document.bg[y][x] = fill + except IndexError: + print("Warning: rect out of bounds: " + ET.tostring(rect, encoding="unicode")) # Find text elements to define the foreground. texts = root.findall(".//{http://www.w3.org/2000/svg}text")