Undo: the open documents' histories share one budget of a quarter of installed memory

`Session::history_budget` (default `default_history_budget()`) caps the
memory the undo steps of all open documents keep together. After each
command, tool edit, interaction commit, direct edit, framed script run
and closed undo group, `Session::trim_histories` drops the oldest steps
of any document first, undo steps before redo steps. Each document keeps
its last eight undo steps and next eight redo steps, and a held history
keeps all of its steps. While a script runs or an undo group is open,
no steps are dropped, so a canceled group leaves the other documents'
steps in place. Closing a document frees its share. The steps are not
counted again while neither the budget nor any history changed. Each
document's own `byte_budget` stays as its ceiling.
This commit is contained in:
dotCooCoo
2026-11-10 12:31:14 -08:00
parent 2fb8c9e516
commit c8d0cdf6a1
10 changed files with 287 additions and 6 deletions
+5 -1
View File
@@ -1021,7 +1021,11 @@ impl Session {
self.script_key = Some(key);
None
}
Ok(Ok(Progress::Done(_))) => Some(self.script_commit(job)),
Ok(Ok(Progress::Done(_))) => {
let r = self.script_commit(job);
self.trim_histories();
Some(r)
}
}
}