Fix crash on document switch (#690)

fix crash on unwrap
This commit is contained in:
mfish33 2022-06-26 22:25:28 -06:00 committed by Keavon Chambers
parent 581ed81747
commit 7f15cac5e2
1 changed files with 10 additions and 7 deletions

View File

@ -264,13 +264,16 @@ impl<'a> Selected<'a> {
pub fn revert_operation(&mut self) {
for path in self.selected {
self.responses.push_back(
DocumentOperation::SetLayerTransform {
path: path.to_vec(),
transform: (*self.original_transforms.get(*path).unwrap()).to_cols_array(),
}
.into(),
);
if let Some(transform) = self.original_transforms.get(*path) {
// Push front to stop document switching before sending the transform
self.responses.push_front(
DocumentOperation::SetLayerTransform {
path: path.to_vec(),
transform: transform.to_cols_array(),
}
.into(),
);
}
}
}
}