forge
Explore
Log in

Don't you dare go Hollow

The write-back a history step makes is pinned, and the plate's motive said right

Browse files at this commit

07d3b8b21f81ed2424541b13e19064e1c7c30b21Ahmet Kaan GümüşParent: dd8c9bb
  • test
    • the write-back a history step makes is pinned, and the plate's motive said right
Show full message
✅ test(player): the write-back a history step makes is pinned, and the plate's motive said right

The app-level half of a history step -- the three session caches, the pick, and
the drop of the plate -- lives in `Player::step_history`, which is unreachable
from this binary: `Player` needs a `TestAppContext` the test build cannot make
(gpui's own test module is behind `feature = "test-support"`, which nothing
enables). The verifier deleted the whole write-back and the suite stayed green,
so it is pinned the way this repo pins an unreachable surface: a source scan
that both keyboard doors route through `step_history` and that its body still
carries every one of those writes. Non-vacuous by the lane's own recipe --
deleting `self.proxies_on = caches.proxies_on;` turns it red by name.

`Player::sub_image` is keyed by *where* a cue sits (`(lane, start_us)`), never
by the pick, and the drop of it is conservative; three comments said the plate
"was drawn through the pick that no longer stands", which would send a reader
looking for a key that does not exist. Reworded to the real key and motive here,
at the removal door, in `sub_pick_after_removal` (which now names what actually
reads the pick: the dock's picked-row comparison, the heading and its notices),
and in the test that covers it.
crates/app/src/player/actions.rsmodified+8 -3
@@ -774,9 +774,14 @@ impl HistoryBefore {
774774 #[derive(Clone, Copy, Debug, PartialEq)]
775775 pub(crate) struct HistoryOutcome {
776776 pub(crate) sub_track: usize,
777- /// The plate the pick drew (`Player::sub_image`) was drawn through a pick
778- /// that no longer stands -- the palette moved under it, or it names another
779- /// row -- so it has to go.
777+ /// The plate over the picture (`Player::sub_image`) has to go. Its tile is
778+ /// keyed by *where* a cue sits ([`Player::sub_picture`]'s `(lane,
779+ /// start_us)`) and carries no track, so a step that moves captions, takes
780+ /// one off, or renumbers the track a placement names
781+ /// ([`engine::Project::remove_subtitles`] walks `SubClip::track` down)
782+ /// cannot be asked of that cache -- the tile at a key can be served for a
783+ /// cue it was not drawn from. Conservative on purpose: at most one plate is
784+ /// redrawn by the next repaint.
780785 pub(crate) drop_sub_image: bool,
781786 }
782787
crates/app/src/player/library.rsmodified+6 -2
@@ -1751,8 +1751,12 @@ impl Player {
17511751 .as_ref()
17521752 .map_or(0, |session| session.subtitles().len());
17531753 self.sub_track = sub_pick_after_removal(self.sub_track, track, left);
1754- // The drawn cue is keyed by that index ([`Player::sub_picture`])
1755- // and the index now stands for another track.
1754+ // The cue over the picture goes with the pick: its tile is
1755+ // keyed by *where* the cue sits ([`Player::sub_picture`]'s
1756+ // `(lane, start_us)`) and never by the track it shows, so the
1757+ // index that moved here is not something that cache can be
1758+ // asked about. Conservative, and the same drop a history step
1759+ // makes for the same reason ([`Player::step_history`]).
17561760 //
17571761 // corner-cut: its atlas tile is not released -- `close_session`'s
17581762 // note, for its reason and with its upgrade path.
crates/app/src/subs.rsmodified+9 -5
@@ -623,11 +623,15 @@ pub(crate) fn subtitle_rows(tracks: &[engine::subtitle::SubtitleTrack]) -> Vec<S
623623 /// last. Zero on an emptied list, which is the index the section is not drawn at
624624 /// all.
625625 ///
626-/// Its own function because the pick is what the overlay draws: left where it
627-/// was it would name a different track, and the plate over the picture would
628-/// change language on its own the moment a row above it went. What an export
629-/// writes is *not* this pick and cannot be desynced by a removal -- it is worked
630-/// out from the cues on the timeline each time ([`Player::export_subs`]).
626+/// Its own function because the pick is read as "which row" everywhere it is
627+/// echoed -- the dock highlights the picked row by comparing it
628+/// (`dock_stance`'s `track == player.sub_track`), and the section heading and
629+/// its notices name it -- so left where it was it would highlight one track and
630+/// name another the moment a row above it went. The plate over the picture is
631+/// not on that list: it is drawn from the *placements* on the shown lane
632+/// ([`Player::active_sub_lane`], and the session's own `sub_lane_cues`). What an export
633+/// writes is not this pick either -- it is worked out from the cues on the
634+/// timeline each time ([`Player::export_subs`]).
631635 pub(crate) fn sub_pick_after_removal(picked: usize, removed: usize, left: usize) -> usize {
632636 let picked = match removed < picked {
633637 true => picked - 1,
crates/app/src/tests/editing.rsmodified+47 -3
@@ -2018,9 +2018,9 @@ fn the_windows_settings_caches_follow_the_session_across_undo_and_redo() {
20182018 /// Rows above the picked subtitle move the pick down with them
20192019 /// ([`sub_pick_after_removal`]), and a `^z` of that removal has to move it back
20202020 /// up: the palette comes home out of the entry, the pick is an *index* into it,
2021-/// and an index left where it was names a different track -- the plate over the
2022-/// picture would change language on its own, and the one already drawn was
2023-/// drawn through the pick that no longer stands.
2021+/// and an index left where it was highlights one row and names another. The
2022+/// plate over the picture goes too, not because it is keyed by the pick -- it is
2023+/// keyed by where a cue sits -- but because the step moves the cues under it.
20242024 #[test]
20252025 fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() {
20262026 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() {
20952095 assert!(out.drop_sub_image, "and the plate goes with it");
20962096 }
20972097
2098+/// The app-level write-back of a history step is not reachable from this binary
2099+/// -- `Player` needs a `TestAppContext` this one has none of -- so the wiring is
2100+/// pinned where it can be read: both keyboard doors route through
2101+/// [`Player::step_history`], and its body still keeps the three session caches
2102+/// and the pick, and still drops the plate. What those values *are* is pinned
2103+/// against a real session by the two tests above ([`history_step`] is the free
2104+/// function they drive); this is the copy back into the window's own fields,
2105+/// which no test can call.
2106+#[test]
2107+fn a_history_step_still_takes_its_settings_and_its_pick_back_up() {
2108+ let actions = src_text("player/actions.rs");
2109+ for needle in [
2110+ "self.step_history(PlaybackSession::undo);",
2111+ "self.step_history(PlaybackSession::redo);",
2112+ ] {
2113+ assert!(
2114+ actions.contains(needle),
2115+ "a history door stopped routing through Player::step_history: {needle}"
2116+ );
2117+ }
2118+ let body = fn_body("step_history");
2119+ // The state the step is asked about, and the answer taken back up: every one
2120+ // of these deleted leaves a cache or the pick stale for the next cut, the
2121+ // next frame count, or the next repaint.
2122+ for needle in [
2123+ "let mut caches = SessionCaches {",
2124+ "HistoryBefore::of(",
2125+ "self.fps = caches.fps;",
2126+ "self.proxies_on = caches.proxies_on;",
2127+ "self.auto_proxies_on = caches.auto_proxies_on;",
2128+ "self.sub_track = outcome.sub_track;",
2129+ "if outcome.drop_sub_image {",
2130+ "self.sub_image = None;",
2131+ "self.reset_after_reseek();",
2132+ ] {
2133+ assert!(
2134+ body.contains(needle),
2135+ "Player::step_history no longer carries `{needle}` -- a history step \
2136+ leaves it behind (the app suite cannot see this: it has no \
2137+ TestAppContext to call the door)"
2138+ );
2139+ }
2140+}
2141+
20982142 /// The oracle side of trim-to-playhead (debt #42): needs a subject cut *and*
20992143 /// the playhead actually resting on it, unlike the nudge pair above it which
21002144 /// only needs a cut -- the "spot" a keyless drag would snap to has to be on