Skip to content

Commit

Permalink
Fix to list remove bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrusnetwork committed Oct 12, 2024
1 parent e37764f commit ca81c77
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions hydrus/core/HydrusData.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,23 @@ def __contains__( self, item ):

def __delitem__( self, index ):

item = self._list[ index ]
del self._list[ index ]
# only clean state is when we take what is the last item _at this point in time_
# previously this test was after the delete and it messed everything up hey
removing_last_item_in_list = index in ( -1, len( self._list ) - 1 )

if item in self._items_to_indices:
if removing_last_item_in_list:

del self._items_to_indices[ item ]
item = self._list[ index ]
del self._list[ index ]


if index not in ( -1, len( self._list ) - 1 ):
if item in self._items_to_indices:

del self._items_to_indices[ item ]


else:

del self._list[ index ]

self._DirtyIndices()

Expand Down Expand Up @@ -272,7 +280,7 @@ def extend( self, items ):
self._list.extend( items )


def index( self, item ):
def index( self, item, **kwargs ):
"""
This is fast!
"""
Expand Down

0 comments on commit ca81c77

Please sign in to comment.