Skip to content

Commit 8636bda

Browse files
committed
fixed undo delete
1 parent 97a69d0 commit 8636bda

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

TODOlist.pyw

+7-2
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ def delete_element():
794794
hierarchy_index = reference_key[1]
795795
section_id = reference_key[2]
796796

797-
augment_element_onto_list(None, 'DELETE', reference_element, hierarchy_index, section_id, None)
797+
augment_element_onto_list(None, 'DELETE', reference_element, hierarchy_index, section_id, metadata=' '.join(reference_key))
798798

799799

800800
def augment_element_onto_list(element, augment_type, reference_element, hierarchy_index, section_id, element_index=None, metadata=None):
@@ -808,7 +808,7 @@ def augment_element_onto_list(element, augment_type, reference_element, hierarch
808808
element_index: the index the element is supposed to be at. Used for undo and redo
809809
metadata: custom extra data that is needed for certin operations
810810
'''
811-
print(element, augment_type, reference_element, hierarchy_index, section_id, element_index)
811+
print(element, augment_type, reference_element, hierarchy_index, section_id, element_index, metadata)
812812
local_section_id = 0
813813

814814
for todolist in data:
@@ -822,6 +822,7 @@ def augment_element_onto_list(element, augment_type, reference_element, hierarch
822822
for task in [task for task in todolist if type(task) is dict]:
823823
if reference_element in task and hierarchy_index == '00':
824824
if augment_type == 'DELETE':
825+
add_to_last(('delete_element', metadata, task, todolist.index(task)))
825826
todolist.remove(task)
826827
elif augment_type == 'INSERT':
827828
todolist.insert(todolist.index(task), element)
@@ -844,6 +845,7 @@ def augment_element_onto_list(element, augment_type, reference_element, hierarch
844845
for section in [section for section in todolist if type(section) is list]:
845846
if reference_element in section[0] and hierarchy_index == '00':
846847
if augment_type == 'DELETE':
848+
add_to_last(('delete_element', metadata, section, todolist.index(section)))
847849
todolist.remove(section)
848850
elif augment_type == 'INSERT':
849851
todolist.insert(todolist.index(section), element)
@@ -872,6 +874,7 @@ def augment_element_onto_list(element, augment_type, reference_element, hierarch
872874
for task in [task for task in section if type(task) is dict]:
873875
if reference_element in task and int(section_id) == local_section_id:
874876
if augment_type == 'DELETE':
877+
add_to_last(('delete_element', metadata, task, section.index(task)))
875878
section.remove(task)
876879
elif augment_type == 'INSERT':
877880
section.insert(section.index(task), element)
@@ -898,6 +901,7 @@ def augment_element_onto_list(element, augment_type, reference_element, hierarch
898901
return create_new_window()
899902
if reference_element in subsection[0] and int(section_id) == local_section_id:
900903
if augment_type == 'DELETE':
904+
add_to_last(('delete_element', metadata, subsection, section.index(subsection)))
901905
section.remove(subsection)
902906
elif augment_type == 'INSERT':
903907
section.insert(section.index(subsection), element)
@@ -932,6 +936,7 @@ def augment_element_onto_list(element, augment_type, reference_element, hierarch
932936
subsection.insert(subsection.index(task), taskToInsert)
933937
else:
934938
if augment_type == 'DELETE':
939+
add_to_last(('delete_element', metadata, task, subsection.index(task)))
935940
subsection.remove(task)
936941
elif augment_type == 'INSERT':
937942
subsection.insert(subsection.index(task), element)

0 commit comments

Comments
 (0)