ElyMark: an unasked end keeps the lock and points (M-06)

GPUI clears windows after the quit observers, so the desk's release
ran close() and wiped what on_app_quit had kept. hold() lets the
lock go unclosed; release then finds nothing to close.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-10 11:31:40 -04:00
1 parent c5f614d095
commit ad97f25ea4
4 files changed
+29 -2

No files matched your search

+1 -1
View File
@@ -257,7 +257,7 @@ pub fn open(app: AppId, window: &mut Window, cx: &mut App) -> Entity<Root> {
cx.on_app_quit(|desk, cx| {
// A system end skips asking: unsaved tabs keep points.
if desk.core.tabs.iter().any(|tab| tab.dirty(cx)) {
log::warn!("mark: quit with unsaved tabs; points stay");
desk.keeping.hold();
} else {
desk.keeping.close();
}
+26
View File
@@ -148,6 +148,13 @@ impl Keeping {
self.waiting[at].tab = Some(tab);
}
/// An end that never asked: the lock and points stay.
pub fn hold(&mut self) {
if self.crash.take().is_some() {
log::warn!("mark: the session ends unasked; its points stay");
}
}
/// A clean end: no crash next time, no stale points.
pub fn close(&mut self) {
let Some(crash) = self.crash.take() else {
@@ -415,4 +422,23 @@ mod tests {
assert_eq!(super::waiting_for(&waiting, None, 4), Some(0));
assert_eq!(super::waiting_for(&waiting, None, 9), None, "a new tab takes nothing");
}
#[test]
fn an_unasked_end_keeps_the_lock_and_points_past_release() {
let dir = tempfile::tempdir().expect("a temp dir");
let point = dir.path().join("recovery/s/point");
let (lock, slot) = (dir.path().join("session.lock"), point.parent().expect("a slot"));
let (mut held, ..) = super::Keeping::start(dir.path()).expect("a session");
std::fs::create_dir_all(slot).expect("a slot");
std::fs::write(&point, "unsaved").expect("a point");
held.hold();
held.close();
assert!(lock.exists() && point.exists(), "release after quit wiped them");
drop(held);
let (mut clean, ..) = super::Keeping::start(dir.path()).expect("a session");
std::fs::create_dir_all(slot).expect("a slot");
std::fs::write(&point, "unsaved").expect("a point");
clean.close();
assert!(!lock.exists() && !point.exists(), "a clean end clears");
}
}