From 3ac725c2aa72881752dd7c82fe8893901f7eb174 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Fri, 26 Sep 2025 19:38:45 +0200 Subject: [PATCH] Enhance template selection logic in VideoEditor to handle current frame matches This commit updates the template selection logic in the VideoEditor to correctly identify and utilize templates that start at the current frame. The changes include additional checks to remove or use templates based on their start frames, improving the efficiency and accuracy of template management during video editing sessions. --- croppa/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/croppa/main.py b/croppa/main.py index b261f12..eb4d200 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -2419,6 +2419,11 @@ class VideoEditor: if i > 0: template_to_remove = i - 1 break + elif start_frame == current_frame: + # Found template with start_frame == current_frame + # Remove THIS template + template_to_remove = i + break if template_to_remove is not None: removed_template = self.templates.pop(template_to_remove) @@ -2442,6 +2447,10 @@ class VideoEditor: return i - 1 else: return None + elif start_frame == frame_number: + # Found template with start_frame == current_frame + # Use THIS template + return i # If no template found with start_frame > current_frame, use the last one return len(self.templates) - 1 if self.templates else None