diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index 82bd7d6..3edc3d9 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -774,9 +774,14 @@ impl HistoryBefore { #[derive(Clone, Copy, Debug, PartialEq)] pub(crate) struct HistoryOutcome { pub(crate) sub_track: usize, - /// The plate the pick drew (`Player::sub_image`) was drawn through a pick - /// that no longer stands -- the palette moved under it, or it names another - /// row -- so it has to go. + /// The plate over the picture (`Player::sub_image`) has to go. Its tile is + /// keyed by *where* a cue sits ([`Player::sub_picture`]'s `(lane, + /// start_us)`) and carries no track, so a step that moves captions, takes + /// one off, or renumbers the track a placement names + /// ([`engine::Project::remove_subtitles`] walks `SubClip::track` down) + /// cannot be asked of that cache -- the tile at a key can be served for a + /// cue it was not drawn from. Conservative on purpose: at most one plate is + /// redrawn by the next repaint. pub(crate) drop_sub_image: bool, } diff --git a/crates/app/src/player/library.rs b/crates/app/src/player/library.rs index 716047b..16efa54 100644 --- a/crates/app/src/player/library.rs +++ b/crates/app/src/player/library.rs @@ -1751,8 +1751,12 @@ impl Player { .as_ref() .map_or(0, |session| session.subtitles().len()); self.sub_track = sub_pick_after_removal(self.sub_track, track, left); - // The drawn cue is keyed by that index ([`Player::sub_picture`]) - // and the index now stands for another track. + // The cue over the picture goes with the pick: its tile is + // keyed by *where* the cue sits ([`Player::sub_picture`]'s + // `(lane, start_us)`) and never by the track it shows, so the + // index that moved here is not something that cache can be + // asked about. Conservative, and the same drop a history step + // makes for the same reason ([`Player::step_history`]). // // corner-cut: its atlas tile is not released -- `close_session`'s // note, for its reason and with its upgrade path. diff --git a/crates/app/src/subs.rs b/crates/app/src/subs.rs index dd482f5..10e42b6 100644 --- a/crates/app/src/subs.rs +++ b/crates/app/src/subs.rs @@ -623,11 +623,15 @@ pub(crate) fn subtitle_rows(tracks: &[engine::subtitle::SubtitleTrack]) -> Vec usize { let picked = match removed < picked { true => picked - 1, diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index 88d9988..e3dcec0 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -2018,9 +2018,9 @@ fn the_windows_settings_caches_follow_the_session_across_undo_and_redo() { /// Rows above the picked subtitle move the pick down with them /// ([`sub_pick_after_removal`]), and a `^z` of that removal has to move it back /// up: the palette comes home out of the entry, the pick is an *index* into it, -/// and an index left where it was names a different track -- the plate over the -/// picture would change language on its own, and the one already drawn was -/// drawn through the pick that no longer stands. +/// and an index left where it was highlights one row and names another. The +/// plate over the picture goes too, not because it is keyed by the pick -- it is +/// keyed by where a cue sits -- but because the step moves the cues under it. #[test] fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() { use crate::player::actions::{history_step, HistoryBefore, SessionCaches}; @@ -2095,6 +2095,50 @@ fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() { assert!(out.drop_sub_image, "and the plate goes with it"); } +/// The app-level write-back of a history step is not reachable from this binary +/// -- `Player` needs a `TestAppContext` this one has none of -- so the wiring is +/// pinned where it can be read: both keyboard doors route through +/// [`Player::step_history`], and its body still keeps the three session caches +/// and the pick, and still drops the plate. What those values *are* is pinned +/// against a real session by the two tests above ([`history_step`] is the free +/// function they drive); this is the copy back into the window's own fields, +/// which no test can call. +#[test] +fn a_history_step_still_takes_its_settings_and_its_pick_back_up() { + let actions = src_text("player/actions.rs"); + for needle in [ + "self.step_history(PlaybackSession::undo);", + "self.step_history(PlaybackSession::redo);", + ] { + assert!( + actions.contains(needle), + "a history door stopped routing through Player::step_history: {needle}" + ); + } + let body = fn_body("step_history"); + // The state the step is asked about, and the answer taken back up: every one + // of these deleted leaves a cache or the pick stale for the next cut, the + // next frame count, or the next repaint. + for needle in [ + "let mut caches = SessionCaches {", + "HistoryBefore::of(", + "self.fps = caches.fps;", + "self.proxies_on = caches.proxies_on;", + "self.auto_proxies_on = caches.auto_proxies_on;", + "self.sub_track = outcome.sub_track;", + "if outcome.drop_sub_image {", + "self.sub_image = None;", + "self.reset_after_reseek();", + ] { + assert!( + body.contains(needle), + "Player::step_history no longer carries `{needle}` -- a history step \ + leaves it behind (the app suite cannot see this: it has no \ + TestAppContext to call the door)" + ); + } +} + /// The oracle side of trim-to-playhead (debt #42): needs a subject cut *and* /// the playhead actually resting on it, unlike the nudge pair above it which /// only needs a cut -- the "spot" a keyless drag would snap to has to be on