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
This commit is contained in:
parent
04c1b2ed03
commit
ff39ebfdbb
|
|
@ -525,9 +525,19 @@ impl Document {
|
||||||
let layer = self.layer(path)?.clone();
|
let layer = self.layer(path)?.clone();
|
||||||
let (folder_path, _) = split_path(path.as_slice()).unwrap_or_else(|_| (&[], 0));
|
let (folder_path, _) = split_path(path.as_slice()).unwrap_or_else(|_| (&[], 0));
|
||||||
let folder = self.folder_mut(folder_path)?;
|
let folder = self.folder_mut(folder_path)?;
|
||||||
folder.add_layer(layer, None, -1).ok_or(DocumentError::IndexOutOfBounds)?;
|
if let Some(new_layer_id) = folder.add_layer(layer, None, -1) {
|
||||||
self.mark_as_dirty(&path[..path.len() - 1])?;
|
let new_path = [folder_path, &[new_layer_id]].concat();
|
||||||
Some(vec![DocumentChanged, FolderChanged { path: folder_path.to_vec() }])
|
self.mark_as_dirty(folder_path)?;
|
||||||
|
Some(
|
||||||
|
[
|
||||||
|
vec![DocumentChanged, CreatedLayer { path: new_path }, FolderChanged { path: folder_path.to_vec() }],
|
||||||
|
update_thumbnails_upstream(path.as_slice()),
|
||||||
|
]
|
||||||
|
.concat(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return Err(DocumentError::IndexOutOfBounds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Operation::RenameLayer { path, name } => {
|
Operation::RenameLayer { path, name } => {
|
||||||
self.layer_mut(path)?.name = Some(name.clone());
|
self.layer_mut(path)?.name = Some(name.clone());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue