M1.15: one modal at a time, restore dialog follows outside restores
- Modal rule (ui/src/commands/modals.ts): palette, settings dialog and the
close question are exclusive; opening one closes the other. Running any
command but palette.open (keyboard, palette, uiCommand) closes the
palette. The restore dialog is queued: hidden while another modal is
open, back with its list intact afterwards.
- recovery.restore / recovery.discard emit recoveryResolved {paths}; the
restore dialog drops the settled paths and closes when none are left.
Rust was needed: discard gave the UI no signal, and a restored entry
stays in the journal as the buffer's own entry.
- Dimmed restored text (C2 screenshot 09) was the dialog overlay, not an
editor style; no editor change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d12a517009
commit
1a38e68480
13 changed files with 442 additions and 12 deletions
|
|
@ -273,6 +273,50 @@ fn restore_reports_missing_entries_and_newer_unsaved_buffers() {
|
|||
);
|
||||
}
|
||||
|
||||
fn resolved_paths(events: &[Event]) -> Vec<Vec<String>> {
|
||||
events
|
||||
.iter()
|
||||
.filter_map(|e| match e {
|
||||
Event::RecoveryResolved { paths } => Some(paths.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restore_and_discard_emit_the_resolved_paths() {
|
||||
let setup = Setup::new(&[("a.php", b"a"), ("b.php", b"b"), ("c.php", b"c")]);
|
||||
let (mut engine, _) = setup.engine();
|
||||
for path in ["a.php", "b.php", "c.php"] {
|
||||
let id = open(&mut engine, path);
|
||||
edit(&mut engine, id, 1, 1, "!");
|
||||
}
|
||||
engine.flush_journal().unwrap();
|
||||
drop(engine);
|
||||
|
||||
let (mut engine, _) = setup.engine();
|
||||
let c = open(&mut engine, "c.php");
|
||||
edit(&mut engine, c, 0, 0, "newer");
|
||||
let out = engine
|
||||
.execute(
|
||||
"recovery.restore",
|
||||
json!({"paths": ["c.php", "a.php", "nope.php"]}),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(resolved_paths(&out.events), vec![vec!["a.php".to_string()]]);
|
||||
let out = engine
|
||||
.execute("recovery.discard", json!({"paths": ["b.php"]}))
|
||||
.unwrap();
|
||||
assert_eq!(resolved_paths(&out.events), vec![vec!["b.php".to_string()]]);
|
||||
let out = engine
|
||||
.execute("recovery.discard", json!({"paths": ["nope.php"]}))
|
||||
.unwrap();
|
||||
assert!(
|
||||
resolved_paths(&out.events).is_empty(),
|
||||
"nothing settled, no event"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disk_changes_after_the_entry_are_flagged() {
|
||||
let setup = Setup::new(&[("a.php", b"a"), ("gone.php", b"g")]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue