mirror of
https://github.com/penpot/penpot.git
synced 2026-10-28 21:40:34 +00:00
🐛 Show text typed on a new line during the v3 layout preview (#12384)
A modified shape is a cached copy, and edits through get_mut did not reset it. After Enter the preview stops sending modifiers while the size holds, so the canvas kept painting the old text. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
7f53483a32
commit
fd03ce2a63
@ -144,6 +144,10 @@ impl ShapesPoolImpl {
|
||||
|
||||
pub fn get_mut(&mut self, id: &Uuid) -> Option<&mut Shape> {
|
||||
let idx = *self.uuid_to_idx.get(id)?;
|
||||
// The caller may change the shape, so its modified copy goes stale.
|
||||
if let Some(cell) = self.modified_shape_cache.get_mut(&idx) {
|
||||
*cell = OnceCell::new();
|
||||
}
|
||||
Some(&mut self.shapes[idx])
|
||||
}
|
||||
|
||||
@ -555,3 +559,22 @@ impl Clone for ShapesPoolImpl {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn get_mut_refreshes_the_modified_shape() {
|
||||
let mut pool = ShapesPool::new();
|
||||
pool.initialize(1);
|
||||
let id = Uuid::new_v4();
|
||||
pool.add_shape(id).set_opacity(1.0);
|
||||
|
||||
pool.set_modifiers(HashMap::from([(id, skia::Matrix::translate((10.0, 0.0)))]));
|
||||
assert_eq!(pool.get(&id).expect("shape").opacity, 1.0);
|
||||
|
||||
pool.get_mut(&id).expect("shape").set_opacity(0.5);
|
||||
assert_eq!(pool.get(&id).expect("shape").opacity, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user