Skip to content

Commit d5c5560

Browse files
caleb-adKeavon
authored andcommitted
Fix bug where duplication with Ctrl+D doesn't properly duplicate (#423)
* bug fix: duplication didn't properly duplicate * cargo fmt * changed the formatting slightly for readability
1 parent 7dd8552 commit d5c5560

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

graphene/src/document.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,19 @@ impl Document {
525525
let layer = self.layer(path)?.clone();
526526
let (folder_path, _) = split_path(path.as_slice()).unwrap_or_else(|_| (&[], 0));
527527
let folder = self.folder_mut(folder_path)?;
528-
folder.add_layer(layer, None, -1).ok_or(DocumentError::IndexOutOfBounds)?;
529-
self.mark_as_dirty(&path[..path.len() - 1])?;
530-
Some(vec![DocumentChanged, FolderChanged { path: folder_path.to_vec() }])
528+
if let Some(new_layer_id) = folder.add_layer(layer, None, -1) {
529+
let new_path = [folder_path, &[new_layer_id]].concat();
530+
self.mark_as_dirty(folder_path)?;
531+
Some(
532+
[
533+
vec![DocumentChanged, CreatedLayer { path: new_path }, FolderChanged { path: folder_path.to_vec() }],
534+
update_thumbnails_upstream(path.as_slice()),
535+
]
536+
.concat(),
537+
)
538+
} else {
539+
return Err(DocumentError::IndexOutOfBounds);
540+
}
531541
}
532542
Operation::RenameLayer { path, name } => {
533543
self.layer_mut(path)?.name = Some(name.clone());

0 commit comments

Comments
 (0)