Type: closing the last document releases the hidden-character and spelling marks

On the Home screen and in the empty window, the canvas returned before the
marks were gathered, so the hidden-character and spelling memos and the list
of text objects kept the closed document's nodes until another document was
shown. The canvas now releases them on any frame with no active document.
This commit is contained in:
dotCooCoo committed 2026-11-25 13:34:17 -08:00
1 parent 694f66a7bd
commit 387b912010
3 files changed
+39 -3

No files matched your search

+4
View File
@@ -108,6 +108,10 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
if app.ui.home.is_some_and(|k| k != crate::menus::home_key(app)) {
app.ui.home = None;
}
// The Home screen and the empty window show no marks: a closed document's text nodes are not kept.
if app.session.active().is_none() {
marks::release_text_marks(app);
}
let full = ui.available_rect_before_wrap();
if crate::menus::home_showing(app) {
// No type editor shows to lose the keys: the marked text stays as typed.
+8 -3
View File
@@ -160,6 +160,13 @@ pub(crate) struct Marks {
artboard_marks: Vec<BezPath>,
}
/// Drops the hidden-character and spelling memos and the text nodes they hold.
pub(crate) fn release_text_marks(app: &mut VectorcraftApp) {
app.canvas.hidden_chars.marks.clear();
app.canvas.spelling = SpellingMarks::default();
app.canvas.text_nodes = TextNodes::default();
}
/// The marks of one canvas pass over `view`. The memos of [`crate::CanvasCache`] are kept while their
/// gate is on and dropped, with the text nodes they hold, when it is off.
pub(crate) fn marks_of(app: &mut VectorcraftApp, view: &CanvasView) -> Marks {
@@ -183,9 +190,7 @@ pub(crate) fn marks_of(app: &mut VectorcraftApp, view: &CanvasView) -> Marks {
let fades = artboards::fades_outside_artboards(app);
let shows_artboards = artboards::shows_artboards(app);
let Some(st) = app.session.active() else {
app.canvas.hidden_chars.marks.clear();
app.canvas.spelling = SpellingMarks::default();
app.canvas.text_nodes = TextNodes::default();
release_text_marks(app);
return m;
};
let key = (st.uid, st.revision);
+27
View File
@@ -122,6 +122,33 @@ fn hidden_characters_off_and_a_closed_document_release_the_text_nodes() {
assert!(app.canvas.text_nodes.list.is_none(), "no list of the closed document's text objects is kept");
}
/// Closing the last document drops the memos' text nodes on the canvas's next frame, whether it
/// shows the Home screen or, with Show The Home Screen When No Documents Are Open off, an empty window.
#[test]
fn a_canvas_frame_without_a_document_releases_the_text_nodes() {
let frame = |app: &mut VectorcraftApp| {
let ctx = crate::testing::ui_context();
let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, Vec2::new(800.0, 600.0))), ..Default::default() };
let mut out = ctx.run_ui(raw, |ui| crate::canvas::show(app, ui));
out.textures_delta.clear();
};
for home in [true, false] {
let mut app = app();
app.session.execute("prefs.set", &json!({"key": "showHomeScreen", "value": home})).unwrap();
text(&mut app, 20, 60, "one\ttwo qzxv\nthree");
app.ui.view.hidden_chars = true;
app.ui.view.auto_spell_check = true;
frame(&mut app);
assert!(app.canvas.text_nodes.list.is_some() && !app.canvas.hidden_chars.marks.is_empty(), "home {home}: the canvas keeps the memos");
app.session.execute("file.close", &json!({})).unwrap();
assert_eq!(crate::menus::home_showing(&app), home);
frame(&mut app);
assert!(app.canvas.text_nodes.list.is_none(), "home {home}: no list of the closed document's text objects is kept");
assert!(app.canvas.hidden_chars.marks.is_empty(), "home {home}: no hidden-character marks of the closed document are kept");
assert!(app.canvas.spelling.lines.is_empty(), "home {home}: no spelling marks of the closed document are kept");
}
}
/// `paths` small rectangles and three point type objects with hidden characters and words no
/// dictionary knows: the first on the first layer, the second in a group on that layer and the
/// third on a second layer. Show Hidden Characters and Auto Spell Check are on. Returns the type