mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Fix group creation parenting (#455)
* WIP fix of folder crash / indent * Fixed most crashes * Known cases of crash / incorrect behavior resolved * Removed todo & readability tweak * Removed left over test * Resolved clippy issue resulting from merging master * Replace recursive tree traversal with prefix matching * Reverted changes for #453 and added undo functionality to Paste * Make uuid generator thread local for tests * Maintain layer order, test still failing 50% of the time * Reverting back to known working with the knowledge we can optimize later. This reverts commit1aaf5c0d7d. * Revert "Make uuid generator thread local for tests" This reverts commitd68e3b9c4e. * Revert "Reverted changes for #453 and added undo functionality to Paste" This reverts commitd66992ac94. * Revert "Replace recursive tree traversal with prefix matching" This reverts commit6bcbb9f82f. * Reverted to working state and added comment back to optimized commit hash * Re-removed the changes involving #453 Co-authored-by: Dennis <dennis@kobert.dev>
This commit is contained in:
committed by
Keavon Chambers
parent
26f0f70023
commit
70d3283196
@@ -352,15 +352,18 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
|
||||
responses.push_back(DocumentsMessage::SelectDocument(prev_id).into());
|
||||
}
|
||||
Copy(clipboard) => {
|
||||
let paths = self.active_document().selected_layers_sorted();
|
||||
self.copy_buffer[clipboard as usize].clear();
|
||||
for path in paths {
|
||||
let document = self.active_document();
|
||||
match (document.graphene_document.layer(&path).map(|t| t.clone()), *document.layer_metadata(&path)) {
|
||||
// We can't use `self.active_document()` because it counts as an immutable borrow of the entirety of `self`
|
||||
let active_document = self.documents.get(&self.active_document_id).unwrap();
|
||||
|
||||
let copy_buffer = &mut self.copy_buffer;
|
||||
copy_buffer[clipboard as usize].clear();
|
||||
|
||||
for layer_path in active_document.selected_layers_without_children() {
|
||||
match (active_document.graphene_document.layer(&layer_path).map(|t| t.clone()), *active_document.layer_metadata(&layer_path)) {
|
||||
(Ok(layer), layer_metadata) => {
|
||||
self.copy_buffer[clipboard as usize].push(CopyBufferEntry { layer, layer_metadata });
|
||||
copy_buffer[clipboard as usize].push(CopyBufferEntry { layer, layer_metadata });
|
||||
}
|
||||
(Err(e), _) => warn!("Could not access selected layer {:?}: {:?}", path, e),
|
||||
(Err(e), _) => warn!("Could not access selected layer {:?}: {:?}", layer_path, e),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -372,9 +375,9 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
|
||||
let document = self.active_document();
|
||||
let shallowest_common_folder = document
|
||||
.graphene_document
|
||||
.deepest_common_folder(document.selected_layers())
|
||||
.shallowest_common_folder(document.selected_layers())
|
||||
.expect("While pasting, the selected layers did not exist while attempting to find the appropriate folder path for insertion");
|
||||
|
||||
responses.push_back(StartTransaction.into());
|
||||
responses.push_back(
|
||||
PasteIntoFolder {
|
||||
clipboard,
|
||||
@@ -383,6 +386,7 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(CommitTransaction.into());
|
||||
}
|
||||
PasteIntoFolder { clipboard, path, insert_index } => {
|
||||
let paste = |entry: &CopyBufferEntry, responses: &mut VecDeque<_>| {
|
||||
|
||||
Reference in New Issue
Block a user