Skip to content

Commit

Permalink
Fix for IndexError in delete_pair function
Browse files Browse the repository at this point in the history
Fixed an issue where deleting the last image caused an IndexError. Now, the index is adjusted to stay within the range of available images after deletion.
  • Loading branch information
Nenotriple authored Dec 1, 2023
1 parent e65f107 commit e12a73f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion img-txt_viewer.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -1517,10 +1517,11 @@ class ImgTxtViewer:
del file_list[self.current_index]
self.deleted_pairs.append(deleted_pair)
self.total_images_label.config(text=f"/{len(self.image_files)}")
if self.current_index >= len(self.image_files):
self.current_index = len(self.image_files) - 1
self.show_pair()
self.undo_state.set("normal")
self.toolsMenu.entryconfig("Undo Delete", state="normal")

else:
print("Index out of range. No more files to delete.")

Expand Down

0 comments on commit e12a73f

Please sign in to comment.