🐛 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:
Belén Albeza 2026-10-19 17:17:35 +02:00 committed by GitHub
parent 7f53483a32
commit fd03ce2a63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
}
}