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.
This commit is contained in:
2025-09-26 19:38:45 +02:00
parent b5a0811cbd
commit 3ac725c2aa

View File

@@ -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