From 7e5477ffc3ed27ea4bd3864b3daf265ba814614a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Anjos?= Date: Sun, 13 Apr 2025 15:01:47 +0100 Subject: [PATCH] Allow for negative indexing --- gimpformats/gimpXcfDocument.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gimpformats/gimpXcfDocument.py b/gimpformats/gimpXcfDocument.py index 5ac0d7c..4f6ac69 100644 --- a/gimpformats/gimpXcfDocument.py +++ b/gimpformats/gimpXcfDocument.py @@ -336,7 +336,8 @@ def getLayer(self, index: int) -> GimpLayer | GimpGroup: """Return a given layer.""" root_group = self.walkTree() - if 0 < index < len(root_group.children): + + if -len(root_group.children) < index < len(root_group.children): return root_group.children[index] msg = f"{index} is out of bounds for GimpDocument [{len(root_group.children)}]"