mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-31 05:07:51 -06:00
Fix pasted type losing its layout bounds cache
Type pasted or imported from another app (Illustrator, PDF, SVG) arrives without cached_bounds, which is not serialized. TextObject::bounds() then falls back to estimate_bounds(), a rough 0.55 em per character, so the selection box came up short of the last character and alignment looked off until the file was saved and reopened (Session::add_document refreshes it). Refresh the bounds of pasted text in paste_clip, covering paste and paste in front/back/in place and every clipboard flavour, with a regression test.
This commit is contained in:
@@ -364,6 +364,9 @@ fn paste_clip(s: &mut Session, p: &Value, mode: PasteMode, clip: &Clipboard, cho
|
||||
}
|
||||
}
|
||||
sel.set(new_ids.iter().copied());
|
||||
// Pasted type arrives without the layout bounds cache: fill it so boxes and alignment are
|
||||
// right away (opening the file later would, but paste must not depend on a reopen).
|
||||
super::typecmd::refresh_bounds_of(d, &new_ids);
|
||||
Ok((new_ids, imported))
|
||||
})?;
|
||||
Ok(json!({
|
||||
|
||||
Reference in New Issue
Block a user