From 350503fbff2dc0036e9d4abf6ce1f6db7ff34a60 Mon Sep 17 00:00:00 2001 From: 0SlowPoke0 Date: Mon, 18 Nov 2024 02:31:18 +0530 Subject: [PATCH 1/2] filtering empty selections --- .../document/utility_types/network_interface.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/editor/src/messages/portfolio/document/utility_types/network_interface.rs b/editor/src/messages/portfolio/document/utility_types/network_interface.rs index 95dca57036..912e9b9666 100644 --- a/editor/src/messages/portfolio/document/utility_types/network_interface.rs +++ b/editor/src/messages/portfolio/document/utility_types/network_interface.rs @@ -1607,7 +1607,12 @@ impl NodeNetworkInterface { return; }; - if let Some(selection_state) = network_metadata.persistent_metadata.selection_undo_history.pop_back() { + let mut non_empty_selections:VecDeque = network_metadata.persistent_metadata.selection_redo_history.iter(). + filter(|selected_nodes| selected_nodes.has_selected_nodes()). + cloned(). + collect(); + + if let Some(selection_state) = non_empty_selections.pop_back() { network_metadata.persistent_metadata.selection_redo_history.push_front(selection_state); } } @@ -1618,7 +1623,12 @@ impl NodeNetworkInterface { return; }; - if let Some(selection_state) = network_metadata.persistent_metadata.selection_redo_history.pop_front() { + let mut non_empty_selections:VecDeque = network_metadata.persistent_metadata.selection_redo_history.iter(). + filter(|selected_nodes| selected_nodes.has_selected_nodes()). + cloned(). + collect(); + + if let Some(selection_state) = non_empty_selections.pop_front() { network_metadata.persistent_metadata.selection_undo_history.push_back(selection_state); } } From c480ae5c4fdbd643700ddf8f88d630e180ad8121 Mon Sep 17 00:00:00 2001 From: 0SlowPoke0 Date: Wed, 20 Nov 2024 11:58:12 +0530 Subject: [PATCH 2/2] used retain instead of putting in heap --- .../document/utility_types/network_interface.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/editor/src/messages/portfolio/document/utility_types/network_interface.rs b/editor/src/messages/portfolio/document/utility_types/network_interface.rs index 912e9b9666..3784868e10 100644 --- a/editor/src/messages/portfolio/document/utility_types/network_interface.rs +++ b/editor/src/messages/portfolio/document/utility_types/network_interface.rs @@ -1607,12 +1607,9 @@ impl NodeNetworkInterface { return; }; - let mut non_empty_selections:VecDeque = network_metadata.persistent_metadata.selection_redo_history.iter(). - filter(|selected_nodes| selected_nodes.has_selected_nodes()). - cloned(). - collect(); + network_metadata.persistent_metadata.selection_redo_history.retain(|selected_nodes| selected_nodes.has_selected_nodes()); - if let Some(selection_state) = non_empty_selections.pop_back() { + if let Some(selection_state) = network_metadata.persistent_metadata.selection_redo_history.pop_back() { network_metadata.persistent_metadata.selection_redo_history.push_front(selection_state); } } @@ -1623,12 +1620,9 @@ impl NodeNetworkInterface { return; }; - let mut non_empty_selections:VecDeque = network_metadata.persistent_metadata.selection_redo_history.iter(). - filter(|selected_nodes| selected_nodes.has_selected_nodes()). - cloned(). - collect(); + network_metadata.persistent_metadata.selection_redo_history.retain(|selected_nodes| selected_nodes.has_selected_nodes()); - if let Some(selection_state) = non_empty_selections.pop_front() { + if let Some(selection_state) = network_metadata.persistent_metadata.selection_redo_history.pop_front() { network_metadata.persistent_metadata.selection_undo_history.push_back(selection_state); } }