forge
Explore
Log in

Don't you dare go Hollow

A history step takes its settings and its pick back with it

Browse files at this commit

7023001542aa03adca3fbfce0d4ec5ebe40c965bAhmet Kaan GümüşParent: 43e146d
  • fix
    • a history step takes its settings and its pick back with it
Show full message
🐛 fix(player): a history step takes its settings and its pick back with it

Four refuted claims from the bughunt review, each a thing an undo restored in
the session and left stale in everything that reads it.

Engine, the order a restored step runs in: `restored_step` reseeked inside
`edit` and adopted the entry's settings only afterwards, so the landing was
computed from the values the step had just undone -- a rate undo clamped the
playhead to the pre-undo rate's idea of the timeline's end and handed the
worker the last frame for a playhead at three seconds. The closure, then
`adopt_settings`, then the reseek; the same ordering reopens a proxy undo
through the switch that just went back.

Engine, the sweep's shape: `parts()` left the palette out, so the D4
round-trip's `parts` equality passed with `self.subtitles = prev.subtitles`
deleted outright. `SubtitleTrack` compares now and `parts` carries the
palette; the D4 test asserts the palette itself, which is the assertion that
cannot go vacuous.

App, the window's own copies: `^z`/`^y` refresh neither `self.fps` nor the two
proxy switches, so after a rate undo every cut, step and fade in this window
was counted at the rate just undone, the Settings rows showed a project the
session no longer had, and the stale switch was pushed at the next session
made. `history_step` re-reads all three off the session, which is a free
function over the session because this binary has no `TestAppContext` to build
a `Player` in -- `Player::undo` is the call plus the repaint.

App, the subtitle pick: a `^z` of a removal restores the palette and left the
pick where it was, so it named a different track than the one on screen -- the
desync `sub_pick_after_removal` prevents at the removal door. The pick follows
the track it names across the step (`sub_pick_after_restore`), the drawn
plate is dropped when the palette or the pick moved under it, and the two
docs claiming a subtitle removal is not an undo step say what it does now.
crates/app/src/player/actions.rsmodified+122 -6
@@ -685,20 +685,136 @@ impl Player {
685 }685 }
686 686
687 pub(crate) fn undo(&mut self, cx: &mut Context<Self>) {687 pub(crate) fn undo(&mut self, cx: &mut Context<Self>) {
688- if self.session.as_mut().is_some_and(PlaybackSession::undo) {688+ self.step_history(PlaybackSession::undo);
689- self.reset_after_reseek();
690- }
691 self.selected.clear();689 self.selected.clear();
692 cx.notify();690 cx.notify();
693 }691 }
694 692
695 pub(crate) fn redo(&mut self, cx: &mut Context<Self>) {693 pub(crate) fn redo(&mut self, cx: &mut Context<Self>) {
696- if self.session.as_mut().is_some_and(PlaybackSession::redo) {694+ self.step_history(PlaybackSession::redo);
697- self.reset_after_reseek();
698- }
699 self.selected.clear();695 self.selected.clear();
700 cx.notify();696 cx.notify();
701 }697 }
698+
699+ /// One step of the session's own history through the door both `^z` and
700+ /// `^y` go through, and the window-side state it moves taken back up
701+ /// afterwards ([`history_step`]).
702+ ///
703+ /// The plate the pick drew goes with the pick
704+ /// ([`Player::remove_subtitle_track`]'s own drop, for its own reason) and
705+ /// the frame owed to the screen is cleared
706+ /// ([`Player::reset_after_reseek`]): an undo reseeks inside the engine, and
707+ /// a picture left where it was is the frame before the step.
708+ fn step_history(&mut self, step: fn(&mut PlaybackSession) -> bool) {
709+ let mut caches = SessionCaches {
710+ fps: self.fps,
711+ proxies_on: self.proxies_on,
712+ auto_proxies_on: self.auto_proxies_on,
713+ };
714+ let before = HistoryBefore::of(
715+ self.session.as_ref().map_or(&[][..], |s| s.subtitles()),
716+ self.sub_track,
717+ );
718+ let Some(outcome) = self
719+ .session
720+ .as_mut()
721+ .and_then(|session| history_step(&before, &mut caches, session, step))
722+ else {
723+ return;
724+ };
725+ self.fps = caches.fps;
726+ self.proxies_on = caches.proxies_on;
727+ self.auto_proxies_on = caches.auto_proxies_on;
728+ self.sub_track = outcome.sub_track;
729+ if outcome.drop_sub_image {
730+ // corner-cut: its atlas tile is not released -- `close_session`'s
731+ // note, for its reason and with its upgrade path.
732+ self.sub_image = None;
733+ }
734+ self.reset_after_reseek();
735+ }
736+}
737+
738+/// The three session settings a window keeps its own copy of, as a value so
739+/// that [`history_step`] can re-read them in place: the rate every
740+/// frame↔second conversion in the window counts in (`Player::timeline_at`,
741+/// `Scale::snap_frames`) and the two switches a project carries and the
742+/// Settings rows *show* (`settings_stance`).
743+#[derive(Clone, Copy, Debug, PartialEq)]
744+pub(crate) struct SessionCaches {
745+ pub(crate) fps: f64,
746+ pub(crate) proxies_on: bool,
747+ pub(crate) auto_proxies_on: bool,
748+}
749+
750+/// The window-side state of the palette as a history step finds it: the pick,
751+/// how many rows there are, and which row the pick names.
752+#[derive(Clone, Debug, PartialEq)]
753+pub(crate) struct HistoryBefore {
754+ pub(crate) sub_track: usize,
755+ pub(crate) sub_rows: usize,
756+ pub(crate) sub_row: Option<SubPickKey>,
757+}
758+
759+impl HistoryBefore {
760+ /// `tracks` as they stand and the index picked there -- an empty palette
761+ /// for a window with no session, which is the state a step cannot happen in
762+ /// anyway.
763+ pub(crate) fn of(tracks: &[engine::subtitle::SubtitleTrack], sub_track: usize) -> Self {
764+ Self {
765+ sub_track,
766+ sub_rows: tracks.len(),
767+ sub_row: SubPickKey::of(tracks, sub_track),
768+ }
769+ }
770+}
771+
772+/// What a history step leaves this window to take up beside the session's own
773+/// lanes.
774+#[derive(Clone, Copy, Debug, PartialEq)]
775+pub(crate) struct HistoryOutcome {
776+ 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.
780+ pub(crate) drop_sub_image: bool,
781+}
782+
783+/// One step of the session's own history ([`PlaybackSession::undo`],
784+/// [`PlaybackSession::redo`]) with everything this window caches re-read after
785+/// it. `None` when the step did not happen -- nothing to undo, nothing to redo
786+/// -- and then nothing here moves either.
787+///
788+/// A free function over the session and the caches rather than a [`Player`]
789+/// method: this test binary has no `TestAppContext` to build a `Player` in, so
790+/// what `^z` does to the session *and* to the caches beside it is pinned here,
791+/// and [`Player::step_history`] is this call plus the repaint.
792+///
793+/// The rate and the two switches are read off the *session*, exactly as the
794+/// doors that own them do ([`Player::apply_frame_rate`], the `.edith` load): a
795+/// history entry carries the project's settings beside its lanes
796+/// (`Project::snapshot`), so a step puts them back -- and a window that kept
797+/// its old copies counts a cut at the rate just undone, keeps reporting a
798+/// switch the session no longer has, and pushes that switch at the next session
799+/// it makes.
800+pub(crate) fn history_step(
801+ before: &HistoryBefore,
802+ caches: &mut SessionCaches,
803+ session: &mut PlaybackSession,
804+ step: fn(&mut PlaybackSession) -> bool,
805+) -> Option<HistoryOutcome> {
806+ if !step(session) {
807+ return None;
808+ }
809+ caches.fps = session.meta().frame_rate;
810+ caches.proxies_on = session.proxies();
811+ caches.auto_proxies_on = session.auto_proxies();
812+ let tracks = session.subtitles();
813+ let sub_track = sub_pick_after_restore(before.sub_track, before.sub_row.as_ref(), tracks);
814+ Some(HistoryOutcome {
815+ sub_track,
816+ drop_sub_image: tracks.len() != before.sub_rows || sub_track != before.sub_track,
817+ })
702 }818 }
703 819
704 /// The half-open range a mark and a mark make, in either order: a person's two820 /// The half-open range a mark and a mark make, in either order: a person's two
crates/app/src/player/library.rsmodified+7 -5
@@ -1711,11 +1711,13 @@ impl Player {
1711 /// would name a *different* track -- and the pick is what an export writes1711 /// would name a *different* track -- and the pick is what an export writes
1712 /// into the file.1712 /// into the file.
1713 ///1713 ///
1714- /// Not an undo step: subtitles are not on the history's snapshots, so the1714+ /// One undo step, and the palette comes back with the reindex
1715- /// way back is putting the file's subtitles on again -- which is a door of1715+ /// ([`engine::Project::remove_subtitles`]), so `^z` is a way back that
1716- /// its own ([`Player::pick_and_add_subtitles`]) and reads the subtitles1716+ /// works -- [`Player::step_history`] moves the pick back with it and drops
1717- /// alone, never the media. The notice says that rather than promising a1717+ /// the plate the old index drew. The second way back, for a caller that
1718- /// ctrl+z that would do nothing.1718+ /// wants the *file's* tracks again, is putting them on
1719+ /// ([`Player::pick_and_add_subtitles`]): a door of its own that reads the
1720+ /// subtitles alone, never the media, which is what the notice names.
1719 pub(crate) fn remove_subtitle_track(&mut self, track: usize, cx: &mut Context<Self>) {1721 pub(crate) fn remove_subtitle_track(&mut self, track: usize, cx: &mut Context<Self>) {
1720 // The one availability oracle, for the same reason the × on a row and1722 // The one availability oracle, for the same reason the × on a row and
1721 // the stroke are one call: an empty list is not a failure, it is an1723 // the stroke are one call: an empty list is not a failure, it is an
crates/app/src/subs.rsmodified+59 -0
@@ -636,6 +636,65 @@ pub(crate) fn sub_pick_after_removal(picked: usize, removed: usize, left: usize)
636 picked.min(left.saturating_sub(1))636 picked.min(left.saturating_sub(1))
637 }637 }
638 638
639+/// What a palette row *is*, apart from where it sits: the file it came out of,
640+/// which track of it, and the two words a row shows. Cloned out of the palette
641+/// once per history step -- a path and three short strings, against a palette
642+/// whose cues are the whole film's subtitles. Not [`SubRow`], which is a row as
643+/// the column *draws* it.
644+#[derive(Clone, Debug, PartialEq, Eq)]
645+pub(crate) struct SubPickKey {
646+ path: PathBuf,
647+ track: Option<u64>,
648+ language: String,
649+ label: String,
650+}
651+
652+impl SubPickKey {
653+ /// The row `track` of this palette names, `None` for an index no track
654+ /// answers to -- the same silence [`sub_pick_name`] gives.
655+ pub(crate) fn of(tracks: &[engine::subtitle::SubtitleTrack], track: usize) -> Option<Self> {
656+ let track = tracks.get(track)?;
657+ Some(Self {
658+ path: track.path.clone(),
659+ track: track.track,
660+ language: track.language.clone(),
661+ label: track.label.clone(),
662+ })
663+ }
664+
665+ /// Whether `track` is this row: the four fields a palette would have had to
666+ /// change for a pick left where it was to name a different track.
667+ fn is(&self, track: &engine::subtitle::SubtitleTrack) -> bool {
668+ track.path == self.path
669+ && track.track == self.track
670+ && track.language == self.language
671+ && track.label == self.label
672+ }
673+}
674+
675+/// Where the pick lands once a *restored* palette is back in place: the row
676+/// that was picked, found by what it is rather than by where it sat.
677+///
678+/// A history step moves rows without saying which one moved -- an undo of a
679+/// removal puts a column back above the pick as often as below it -- so an
680+/// index left where it was names a different track, which is the desync
681+/// [`sub_pick_after_removal`] prevents at the door where the row that moved is
682+/// known. That door's arithmetic is this map's one-row-moved case.
683+///
684+/// A row the restored palette does not have (it went again, or the pick named
685+/// nothing) falls back to the old index clamped into the new list -- that same
686+/// door's own fallback, and the zero the section is not drawn at all for an
687+/// emptied palette.
688+pub(crate) fn sub_pick_after_restore(
689+ picked: usize,
690+ before: Option<&SubPickKey>,
691+ after: &[engine::subtitle::SubtitleTrack],
692+) -> usize {
693+ before
694+ .and_then(|was| after.iter().position(|track| was.is(track)))
695+ .unwrap_or_else(|| picked.min(after.len().saturating_sub(1)))
696+}
697+
639 pub(crate) fn sub_pick_name(698 pub(crate) fn sub_pick_name(
640 tracks: &[engine::subtitle::SubtitleTrack],699 tracks: &[engine::subtitle::SubtitleTrack],
641 track: usize,700 track: usize,
crates/app/src/tests/editing.rsmodified+161 -0
@@ -1934,6 +1934,167 @@ fn trim_to_playhead_moves_the_selected_clips_edge_and_undoes_in_one_step() {
1934 assert_eq!(session.lane_clips(Lane::V1)[0], whole, "the tail is back");1934 assert_eq!(session.lane_clips(Lane::V1)[0], whole, "the tail is back");
1935 }1935 }
1936 1936
1937+/// The window's own copy of the rate and the two switches follows the
1938+/// *session* across `^z` and `^y`: a history entry carries the project's
1939+/// settings beside its lanes ([`engine::Project::snapshot`]), so a step puts
1940+/// them back -- and a window that kept its old copies counts every cut, step
1941+/// and fade in the rate it just undid, keeps showing a switch the session no
1942+/// longer has (`settings_stance`), and pushes that switch at the next session
1943+/// it makes.
1944+#[test]
1945+fn the_windows_settings_caches_follow_the_session_across_undo_and_redo() {
1946+ use crate::player::actions::{history_step, HistoryBefore, SessionCaches};
1947+
1948+ let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
1949+ session.set_gain(0.0);
1950+ let native = session.meta().frame_rate;
1951+ let (proxies, auto) = (!session.proxies(), !session.auto_proxies());
1952+
1953+ // The three picks as the window makes them, with the copies it keeps beside
1954+ // them (`Player::apply_frame_rate`'s own write, both toggle doors').
1955+ assert!(session.set_frame_rate(native * 2.0), "the rate pick");
1956+ session.set_proxies(proxies);
1957+ session.set_auto_proxies(auto);
1958+ let mut caches = SessionCaches {
1959+ fps: session.meta().frame_rate,
1960+ proxies_on: proxies,
1961+ auto_proxies_on: auto,
1962+ };
1963+ assert_ne!(
1964+ caches.fps, native,
1965+ "the test needs a rate that really moved"
1966+ );
1967+
1968+ // Back, one step at a time: after each one the window's copies are the
1969+ // session's, never the pick's.
1970+ for step in 0..3 {
1971+ let before = HistoryBefore::of(session.subtitles(), 0);
1972+ let out = history_step(&before, &mut caches, &mut session, PlaybackSession::undo)
1973+ .expect("a pick behind this one");
1974+ assert_eq!(
1975+ caches.fps,
1976+ session.meta().frame_rate,
1977+ "undo {step}: the rate"
1978+ );
1979+ assert_eq!(
1980+ caches.proxies_on,
1981+ session.proxies(),
1982+ "undo {step}: the switch"
1983+ );
1984+ assert_eq!(
1985+ caches.auto_proxies_on,
1986+ session.auto_proxies(),
1987+ "undo {step}: the auto switch"
1988+ );
1989+ assert!(!out.drop_sub_image, "undo {step}: no palette moved");
1990+ }
1991+ assert_eq!(caches.fps, native, "the rate pick is undone");
1992+ assert_eq!(
1993+ (caches.proxies_on, caches.auto_proxies_on),
1994+ (!proxies, !auto),
1995+ "and both switches are back where they were"
1996+ );
1997+
1998+ // ...and forward again, where the picks come home.
1999+ for step in 0..3 {
2000+ let before = HistoryBefore::of(session.subtitles(), 0);
2001+ history_step(&before, &mut caches, &mut session, PlaybackSession::redo)
2002+ .expect("a pick in front of this one");
2003+ assert_eq!(
2004+ caches.fps,
2005+ session.meta().frame_rate,
2006+ "redo {step}: the rate"
2007+ );
2008+ assert_eq!(
2009+ caches.proxies_on,
2010+ session.proxies(),
2011+ "redo {step}: the switch"
2012+ );
2013+ }
2014+ assert_eq!(caches.fps, native * 2.0, "the pick's own rate is back");
2015+ assert_eq!(caches.proxies_on, proxies, "and its switch");
2016+}
2017+
2018+/// Rows above the picked subtitle move the pick down with them
2019+/// ([`sub_pick_after_removal`]), and a `^z` of that removal has to move it back
2020+/// 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.
2024+#[test]
2025+fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() {
2026+ use crate::player::actions::{history_step, HistoryBefore, SessionCaches};
2027+
2028+ let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
2029+ session.set_gain(0.0);
2030+ assert_eq!(
2031+ session.add_subtitle_tracks(vec![
2032+ sub("/subs/one.srt", None, "one.srt"),
2033+ sub("/subs/two.srt", None, "two.srt"),
2034+ sub("/subs/three.srt", None, "three.srt"),
2035+ ]),
2036+ 3,
2037+ "the palette"
2038+ );
2039+ let mut caches = SessionCaches {
2040+ fps: session.meta().frame_rate,
2041+ proxies_on: session.proxies(),
2042+ auto_proxies_on: session.auto_proxies(),
2043+ };
2044+ // The last row picked, which is where a click on it leaves the pick.
2045+ let pick = 2;
2046+ let picked = sub_pick_name(session.subtitles(), pick).expect("a name for the pick");
2047+
2048+ // The row *above* it goes, through the removal door's own fixup.
2049+ session
2050+ .remove_subtitles(0)
2051+ .expect("a row with nothing on it");
2052+ let pick = sub_pick_after_removal(pick, 0, session.subtitles().len());
2053+ assert_eq!(pick, 1, "the pick slid down with the rows");
2054+ assert_eq!(
2055+ sub_pick_name(session.subtitles(), pick).as_deref(),
2056+ Some(picked.as_str()),
2057+ "and still names the same track"
2058+ );
2059+
2060+ let before = HistoryBefore::of(session.subtitles(), pick);
2061+ let out = history_step(&before, &mut caches, &mut session, PlaybackSession::undo)
2062+ .expect("the removal is a step like any other cut");
2063+ assert_eq!(session.subtitles().len(), 3, "the palette is back");
2064+ assert_eq!(
2065+ out.sub_track, 2,
2066+ "the row came back above the pick, so the pick moves up"
2067+ );
2068+ assert_eq!(
2069+ sub_pick_name(session.subtitles(), out.sub_track).as_deref(),
2070+ Some(picked.as_str()),
2071+ "and still names the same track"
2072+ );
2073+ assert_ne!(
2074+ sub_pick_name(session.subtitles(), pick).as_deref(),
2075+ Some(picked.as_str()),
2076+ "which is what the index left where it was would have named"
2077+ );
2078+ assert!(
2079+ out.drop_sub_image,
2080+ "the drawn plate went through the pick that moved"
2081+ );
2082+
2083+ // ...and forward again: the removal, with the fixup it does at its own door.
2084+ let before = HistoryBefore::of(session.subtitles(), out.sub_track);
2085+ let out = history_step(&before, &mut caches, &mut session, PlaybackSession::redo)
2086+ .expect("the removal is in front of this one");
2087+ assert_eq!(
2088+ out.sub_track, 1,
2089+ "the removal slides the pick down with the rows"
2090+ );
2091+ assert_eq!(
2092+ sub_pick_name(session.subtitles(), out.sub_track).as_deref(),
2093+ Some(picked.as_str())
2094+ );
2095+ assert!(out.drop_sub_image, "and the plate goes with it");
2096+}
2097+
1937 /// The oracle side of trim-to-playhead (debt #42): needs a subject cut *and*2098 /// The oracle side of trim-to-playhead (debt #42): needs a subject cut *and*
1938 /// the playhead actually resting on it, unlike the nudge pair above it which2099 /// the playhead actually resting on it, unlike the nudge pair above it which
1939 /// only needs a cut -- the "spot" a keyless drag would snap to has to be on2100 /// only needs a cut -- the "spot" a keyless drag would snap to has to be on
crates/app/src/tests/layout.rsmodified+153 -57
@@ -351,7 +351,7 @@ fn a_lane_row_is_a_fixed_header_and_a_bed_that_can_be_hit() {
351 /// strip's row at the zoom boundary without the strip to show for it.351 /// strip's row at the zoom boundary without the strip to show for it.
352 #[test]352 #[test]
353 fn the_scroll_strip_row_comes_and_goes_with_the_zoom() {353 fn the_scroll_strip_row_comes_and_goes_with_the_zoom() {
354- use crate::{SCROLL_HIT, Split, lanes_h, split_size, timeline_fixed_h, timeline_h};354+ use crate::{lanes_h, split_size, timeline_fixed_h, timeline_h, Split, SCROLL_HIT};
355 use gpui::{px, size};355 use gpui::{px, size};
356 356
357 // The strip's row, and only the strip's row, is what the two faces differ357 // The strip's row, and only the strip's row, is what the two faces differ
@@ -398,8 +398,8 @@ fn the_scroll_strip_row_comes_and_goes_with_the_zoom() {
398 /// on the track, the time axis's own thumb turned through a right angle.398 /// on the track, the time axis's own thumb turned through a right angle.
399 #[test]399 #[test]
400 fn the_lane_thumb_is_the_visible_share_of_the_stack() {400 fn the_lane_thumb_is_the_visible_share_of_the_stack() {
401- use crate::SCROLL_THUMB_MIN;
402 use crate::lanes_thumb;401 use crate::lanes_thumb;
402+ use crate::SCROLL_THUMB_MIN;
403 403
404 // Whole stack on screen: the track fills and there is nothing to scroll.404 // Whole stack on screen: the track fills and there is nothing to scroll.
405 assert_eq!(lanes_thumb(200., 104., 200., 0.), (0., 200.));405 assert_eq!(lanes_thumb(200., 104., 200., 0.), (0., 200.));
@@ -1301,7 +1301,7 @@ fn the_darkroom_subtitle_palette_drags_tracks_to_subtitle_lanes() {
1301 /// arrival order, at the end.1301 /// arrival order, at the end.
1302 #[test]1302 #[test]
1303 fn a_file_subtitle_group_follows_its_own_row() {1303 fn a_file_subtitle_group_follows_its_own_row() {
1304- use crate::ui::dock_stance::{Slot, source_list_order};1304+ use crate::ui::dock_stance::{source_list_order, Slot};
1305 let film = PathBuf::from("/films/a.mkv");1305 let film = PathBuf::from("/films/a.mkv");
1306 let other = PathBuf::from("/rec/b.mp4");1306 let other = PathBuf::from("/rec/b.mp4");
1307 let loose = PathBuf::from("/subs/late.srt");1307 let loose = PathBuf::from("/subs/late.srt");
@@ -1320,7 +1320,12 @@ fn a_file_subtitle_group_follows_its_own_row() {
1320 &[film.clone(), other.clone(), film.clone()],1320 &[film.clone(), other.clone(), film.clone()],
1321 &[film.clone()]1321 &[film.clone()]
1322 ),1322 ),
1323- [Slot::Media(0), Slot::Media(1), Slot::Media(2), Slot::Subs(0)],1323+ [
1324+ Slot::Media(0),
1325+ Slot::Media(1),
1326+ Slot::Media(2),
1327+ Slot::Subs(0)
1328+ ],
1324 );1329 );
1325 // Nobody's `.srt`: still a top-level row, still last.1330 // Nobody's `.srt`: still a top-level row, still last.
1326 assert_eq!(1331 assert_eq!(
@@ -1366,7 +1371,9 @@ fn same_named_files_are_told_apart_on_the_metadata_line() {
1366 .collect();1371 .collect();
1367 let rows = library_rows(&three, &HashMap::new(), &HashMap::new(), None, |_| 90);1372 let rows = library_rows(&three, &HashMap::new(), &HashMap::new(), None, |_| 90);
1368 assert_eq!(1373 assert_eq!(
1369- rows.iter().map(|row| row.detail.as_str()).collect::<Vec<_>>(),1374+ rows.iter()
1375+ .map(|row| row.detail.as_str())
1376+ .collect::<Vec<_>>(),
1370 ["a", "b", ""],1377 ["a", "b", ""],
1371 "twins say which folder they came out of"1378 "twins say which folder they came out of"
1372 );1379 );
@@ -1379,7 +1386,9 @@ fn same_named_files_are_told_apart_on_the_metadata_line() {
1379 .collect();1386 .collect();
1380 let rows = library_rows(&twins, &HashMap::new(), &HashMap::new(), None, |_| 90);1387 let rows = library_rows(&twins, &HashMap::new(), &HashMap::new(), None, |_| 90);
1381 assert_eq!(1388 assert_eq!(
1382- rows.iter().map(|row| row.detail.as_str()).collect::<Vec<_>>(),1389+ rows.iter()
1390+ .map(|row| row.detail.as_str())
1391+ .collect::<Vec<_>>(),
1383 ["#1", "#2"],1392 ["#1", "#2"],
1384 "one folder, one stem: arrival order tells them apart"1393 "one folder, one stem: arrival order tells them apart"
1385 );1394 );
@@ -1483,6 +1492,45 @@ fn removing_a_subtitle_row_carries_the_pick_with_it() {
1483 assert_eq!(sub_pick_after_removal(0, 0, 0), 0);1492 assert_eq!(sub_pick_after_removal(0, 0, 0), 0);
1484 }1493 }
1485 1494
1495+/// A `^z` moves rows without saying which one moved, so the pick is followed by
1496+/// what it *names* ([`sub_pick_after_restore`]) rather than by its index: the
1497+/// same three rows as the removal test above, restored instead of taken away,
1498+/// where the index is the wrong answer in the first case and the right one in
1499+/// the second.
1500+#[test]
1501+fn a_restored_palette_carries_the_pick_by_what_it_names() {
1502+ let palette = [
1503+ sub("/films/a.mkv", Some(1), "eng"),
1504+ sub("/films/a.mkv", Some(2), "fre"),
1505+ sub("/films/a.mkv", Some(3), "ger"),
1506+ ];
1507+ // The pick on "ger" at index 1 of the two rows a removal of the first left.
1508+ let short = [palette[1].clone(), palette[2].clone()];
1509+ let picked = SubPickKey::of(&short, 1).expect("a row the pick names");
1510+ assert_eq!(
1511+ sub_pick_after_restore(1, Some(&picked), &palette),
1512+ 2,
1513+ "the row above it came back"
1514+ );
1515+ // The row that came back *below* the pick leaves it where it was.
1516+ let short = [palette[0].clone(), palette[1].clone()];
1517+ let picked = SubPickKey::of(&short, 1).expect("a row the pick names");
1518+ assert_eq!(
1519+ sub_pick_after_restore(1, Some(&picked), &palette),
1520+ 1,
1521+ "a row after it is not its business"
1522+ );
1523+ // The picked row itself gone from the restored palette: the old index
1524+ // clamped into it, which is the removal door's own fallback.
1525+ let picked = SubPickKey::of(&palette, 2).expect("a row the pick names");
1526+ assert_eq!(sub_pick_after_restore(2, Some(&picked), &palette[..2]), 1);
1527+ assert_eq!(
1528+ sub_pick_after_restore(0, None, &[]),
1529+ 0,
1530+ "an emptied palette is a state, not a panic"
1531+ );
1532+}
1533+
1486 /// The same claim from the click's end, on the order imports actually1534 /// The same claim from the click's end, on the order imports actually
1487 /// arrive in: two films opened one after the other and an `.srt` dropped1535 /// arrive in: two films opened one after the other and an `.srt` dropped
1488 /// last interleave in the flat list, and the display reorders them. What a1536 /// last interleave in the flat list, and the display reorders them. What a
@@ -1707,7 +1755,11 @@ fn darkroom_lane_header_verbs_are_targeted_and_visible() {
1707 // `overlays.rs` routes those rows through the same `act_lane` door the1755 // `overlays.rs` routes those rows through the same `act_lane` door the
1708 // head's buttons used.1756 // head's buttons used.
1709 let bench = src_text("ui/bench_stance.rs");1757 let bench = src_text("ui/bench_stance.rs");
1710- for gone in ["\"bench-mix-lane\"", "\"bench-remove-lane\"", "lane.{}.remove"] {1758+ for gone in [
1759+ "\"bench-mix-lane\"",
1760+ "\"bench-remove-lane\"",
1761+ "lane.{}.remove",
1762+ ] {
1711 assert!(!bench.contains(gone), "the lane head still wears {gone}");1763 assert!(!bench.contains(gone), "the lane head still wears {gone}");
1712 }1764 }
1713 for door in ["\"bench-show-sub-lane\"", "this.show_sub_lane(lane, cx)"] {1765 for door in ["\"bench-show-sub-lane\"", "this.show_sub_lane(lane, cx)"] {
@@ -1746,8 +1798,8 @@ fn darkroom_lane_header_verbs_are_targeted_and_visible() {
1746 fn a_dragged_divider_stops_before_either_panel_disappears() {1798 fn a_dragged_divider_stops_before_either_panel_disappears() {
1747 use crate::ui::theme::INSPECTOR_MIN_W;1799 use crate::ui::theme::INSPECTOR_MIN_W;
1748 use crate::{1800 use crate::{
1749- SIDE_MAX_FRAC, SPLIT_W, Split, TIMELINE_MAX_SHARE, TOOLBAR_H, inspector_w, library_w,1801+ inspector_w, library_w, split_drag_size, split_size, timeline_fixed_h, timeline_h, Split,
1750- split_drag_size, split_size, timeline_fixed_h, timeline_h,1802+ SIDE_MAX_FRAC, SPLIT_W, TIMELINE_MAX_SHARE, TOOLBAR_H,
1751 };1803 };
1752 use gpui::{point, px, size};1804 use gpui::{point, px, size};
1753 1805
@@ -1867,7 +1919,7 @@ fn a_dragged_divider_stops_before_either_panel_disappears() {
1867 fn the_darkroom_seams_stop_before_either_side_disappears() {1919 fn the_darkroom_seams_stop_before_either_side_disappears() {
1868 use crate::ui::theme::INSPECTOR_MIN_W;1920 use crate::ui::theme::INSPECTOR_MIN_W;
1869 use crate::{1921 use crate::{
1870- BENCH_MIN_H, SIDE_MAX_FRAC, SPLIT_W, Split, split_bounds, split_drag_size, split_size,1922+ split_bounds, split_drag_size, split_size, Split, BENCH_MIN_H, SIDE_MAX_FRAC, SPLIT_W,
1871 };1923 };
1872 use gpui::{point, px, size};1924 use gpui::{point, px, size};
1873 1925
@@ -1926,9 +1978,9 @@ fn the_darkroom_seams_stop_before_either_side_disappears() {
1926 /// ~2px at the old `BENCH_MIN_H = 80.`).1978 /// ~2px at the old `BENCH_MIN_H = 80.`).
1927 #[test]1979 #[test]
1928 fn both_default_lanes_fit_the_bench_at_its_floor() {1980 fn both_default_lanes_fit_the_bench_at_its_floor() {
1929- use crate::BENCH_MIN_H;1981+ use crate::ui::bench_stance::{row_h, LANE_MIN_H, ROW_GAP, RULER_H};
1930- use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H, row_h};
1931 use crate::ui::stance::BENCH_CHROME_H;1982 use crate::ui::stance::BENCH_CHROME_H;
1983+ use crate::BENCH_MIN_H;
1932 1984
1933 let box_h = BENCH_MIN_H - BENCH_CHROME_H;1985 let box_h = BENCH_MIN_H - BENCH_CHROME_H;
1934 let avail = box_h - RULER_H - ROW_GAP;1986 let avail = box_h - RULER_H - ROW_GAP;
@@ -1968,9 +2020,9 @@ fn both_default_lanes_fit_the_bench_at_its_floor() {
1968 /// painted bounds back, so it stays geometry-only, same as its neighbours.2020 /// painted bounds back, so it stays geometry-only, same as its neighbours.
1969 #[test]2021 #[test]
1970 fn the_whole_bench_stack_fits_its_own_floor_with_the_ledger_seam_clear() {2022 fn the_whole_bench_stack_fits_its_own_floor_with_the_ledger_seam_clear() {
1971- use crate::BENCH_MIN_H;
1972 use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H};2023 use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H};
1973 use crate::ui::stance::BENCH_CHROME_H;2024 use crate::ui::stance::BENCH_CHROME_H;
2025+ use crate::BENCH_MIN_H;
1974 2026
1975 const BENCH_BORDER_T: f32 = 1.;2027 const BENCH_BORDER_T: f32 = 1.;
1976 const BENCH_PY_TOP: f32 = 4.;2028 const BENCH_PY_TOP: f32 = 4.;
@@ -2040,9 +2092,9 @@ fn a_lane_row_fits_what_its_own_head_draws() {
2040 #[test]2092 #[test]
2041 fn a_saved_seam_survives_a_reload() {2093 fn a_saved_seam_survives_a_reload() {
2042 use crate::{2094 use crate::{
2043- BENCH_MIN_H, SIDE_MAX_FRAC, Split, Splits, load_stance_splits_from, save_stance_splits_to,2095+ load_stance_splits_from, save_stance_splits_to, Split, Splits, BENCH_MIN_H, SIDE_MAX_FRAC,
2044 };2096 };
2045- use gpui::{Pixels, Size, px, size};2097+ use gpui::{px, size, Pixels, Size};
2046 2098
2047 let dir = engine::scratch::Scratch::dir("edith-stance-splits");2099 let dir = engine::scratch::Scratch::dir("edith-stance-splits");
2048 let path = dir.join("stance-splits");2100 let path = dir.join("stance-splits");
@@ -2085,7 +2137,7 @@ fn a_saved_seam_survives_a_reload() {
2085 /// drag that never started (`None`) owes nothing.2137 /// drag that never started (`None`) owes nothing.
2086 #[test]2138 #[test]
2087 fn only_the_persisted_seams_owe_a_save_when_a_drag_loses_the_window() {2139 fn only_the_persisted_seams_owe_a_save_when_a_drag_loses_the_window() {
2088- use crate::{Split, player::timeline_edit::split_drag_owes_save};2140+ use crate::{player::timeline_edit::split_drag_owes_save, Split};
2089 2141
2090 assert!(split_drag_owes_save(Some(Split::Dock)));2142 assert!(split_drag_owes_save(Some(Split::Dock)));
2091 assert!(split_drag_owes_save(Some(Split::Bench)));2143 assert!(split_drag_owes_save(Some(Split::Bench)));
@@ -2099,8 +2151,8 @@ fn only_the_persisted_seams_owe_a_save_when_a_drag_loses_the_window() {
2099 /// `load_stance_splits`'s doc comment promises.2151 /// `load_stance_splits`'s doc comment promises.
2100 #[test]2152 #[test]
2101 fn a_missing_stance_splits_file_leaves_every_region_at_its_default() {2153 fn a_missing_stance_splits_file_leaves_every_region_at_its_default() {
2102- use crate::{Split, load_stance_splits_from};2154+ use crate::{load_stance_splits_from, Split};
2103- use gpui::{Pixels, Size, px, size};2155+ use gpui::{px, size, Pixels, Size};
2104 2156
2105 let dir = engine::scratch::Scratch::dir("edith-stance-splits-missing");2157 let dir = engine::scratch::Scratch::dir("edith-stance-splits-missing");
2106 let window: Size<Pixels> = size(px(1280.), px(720.));2158 let window: Size<Pixels> = size(px(1280.), px(720.));
@@ -2182,13 +2234,7 @@ fn the_stance_renders_its_five_regions_in_the_documented_order() {
2182 // Open paren only, no close: DESIGN §12 steps 3 and 4 hand most of the2234 // Open paren only, no close: DESIGN §12 steps 3 and 4 hand most of the
2183 // regions player/window state to read, so their call sites carry2235 // regions player/window state to read, so their call sites carry
2184 // arguments now. Order is what this asserts, not arity.2236 // arguments now. Order is what this asserts, not arity.
2185- let calls = [2237+ let calls = ["screen(", "time_band(", "bench(", "ledger(", "dock("];
2186- "screen(",
2187- "time_band(",
2188- "bench(",
2189- "ledger(",
2190- "dock(",
2191- ];
2192 let composed: Vec<usize> = calls2238 let composed: Vec<usize> = calls
2193 .iter()2239 .iter()
2194 .map(|c| {2240 .map(|c| {
@@ -2662,12 +2708,13 @@ fn every_action_has_a_darkroom_widget_home_or_explicit_owner() {
2662 text.lines()2708 text.lines()
2663 .filter(|l| !l.contains("=> format!(\"{full} (global)\")"))2709 .filter(|l| !l.contains("=> format!(\"{full} (global)\")"))
2664 .any(|line| {2710 .any(|line| {
2665- line.match_indices(&format!("ActionId::{name}")).any(|(i, m)| {2711+ line.match_indices(&format!("ActionId::{name}"))
2666- !line[i + m.len()..]2712+ .any(|(i, m)| {
2667- .chars()2713+ !line[i + m.len()..]
2668- .next()2714+ .chars()
2669- .is_some_and(|c| c.is_alphanumeric() || c == '_')2715+ .next()
2670- })2716+ .is_some_and(|c| c.is_alphanumeric() || c == '_')
2717+ })
2671 })2718 })
2672 }2719 }
2673 let darkroom = [2720 let darkroom = [
@@ -2946,7 +2993,7 @@ fn the_bench_answers_a_wheel_notch_anywhere_over_it() {
2946 /// kept beside the first ([`Splits::clear`]).2993 /// kept beside the first ([`Splits::clear`]).
2947 #[test]2994 #[test]
2948 fn a_double_pressed_divider_forgets_the_size_it_was_dragged_to() {2995 fn a_double_pressed_divider_forgets_the_size_it_was_dragged_to() {
2949- use crate::layout::{Split, Splits, split_size};2996+ use crate::layout::{split_size, Split, Splits};
2950 use gpui::{px, size};2997 use gpui::{px, size};
2951 2998
2952 let window = size(px(1280.), px(720.));2999 let window = size(px(1280.), px(720.));
@@ -3007,7 +3054,8 @@ fn the_seam_paints_nothing_until_a_pointer_finds_it() {
3007 // gets after it no longer needs it (a `bench=207` -- a press with no3054 // gets after it no longer needs it (a `bench=207` -- a press with no
3008 // drag in it -- beside a dragged `dock=277`).3055 // drag in it -- beside a dragged `dock=277`).
3009 assert!(3056 assert!(
3010- body.find(".group(group.clone())").expect("the band's group")3057+ body.find(".group(group.clone())")
3058+ .expect("the band's group")
3011 < body.find("border_t_1()").expect("the hairline"),3059 < body.find("border_t_1()").expect("the hairline"),
3012 "the hairline is painted outside the band: {body}"3060 "the hairline is painted outside the band: {body}"
3013 );3061 );
@@ -3030,13 +3078,12 @@ fn the_bench_seam_reaches_no_further_than_every_other_seam() {
3030 );3078 );
3031 }3079 }
3032 3080
3033-
3034 /// The clamp table, driven: the seam refuses exactly two things, and neither3081 /// The clamp table, driven: the seam refuses exactly two things, and neither
3035 /// is anywhere near where a hand drags. Measured live at 2560x1440 --3082 /// is anywhere near where a hand drags. Measured live at 2560x1440 --
3036 /// `bench=105` at the floor, `bench=1164` at the ceiling.3083 /// `bench=105` at the floor, `bench=1164` at the ceiling.
3037 #[test]3084 #[test]
3038 fn the_bench_seam_stops_at_its_floor_and_its_ceiling() {3085 fn the_bench_seam_stops_at_its_floor_and_its_ceiling() {
3039- use crate::{BENCH_MIN_H, Split, split_bounds, split_size};3086+ use crate::{split_bounds, split_size, Split, BENCH_MIN_H};
3040 use gpui::{px, size};3087 use gpui::{px, size};
3041 3088
3042 let window = size(px(2560.), px(1440.));3089 let window = size(px(2560.), px(1440.));
@@ -3065,8 +3112,11 @@ fn the_bench_seam_stops_at_its_floor_and_its_ceiling() {
3065 fn the_lane_bed_clips_its_clips_at_the_pinned_heads() {3112 fn the_lane_bed_clips_its_clips_at_the_pinned_heads() {
3066 let src = src_text("ui/bench_stance.rs");3113 let src = src_text("ui/bench_stance.rs");
3067 let start = src.find(r#".id(("bench-bed""#).expect("the bed");3114 let start = src.find(r#".id(("bench-bed""#).expect("the bed");
3068- let bed =3115+ let bed = &src[start
3069- &src[start..start + src[start..].find(".bg(rgb(DARK_CANVAS()))").expect("its fill")];3116+ ..start
3117+ + src[start..]
3118+ .find(".bg(rgb(DARK_CANVAS()))")
3119+ .expect("its fill")];
3070 assert!(3120 assert!(
3071 bed.contains(".overflow_hidden()"),3121 bed.contains(".overflow_hidden()"),
3072 "the bed lets its clips paint outside itself, straight over the \3122 "the bed lets its clips paint outside itself, straight over the \
@@ -3130,7 +3180,10 @@ fn a_source_row_shows_its_name_before_anything_else() {
3130 "the metadata line no longer drops the decoder seat"3180 "the metadata line no longer drops the decoder seat"
3131 );3181 );
3132 let usage = &dock[dock.find("fn usage_line(").expect("the usage line")..start];3182 let usage = &dock[dock.find("fn usage_line(").expect("the usage line")..start];
3133- assert!(!usage.contains("use{}"), "the metadata line still counts uses");3183+ assert!(
3184+ !usage.contains("use{}"),
3185+ "the metadata line still counts uses"
3186+ );
3134 // DESIGN §8: the permanent footer telling the editor how to use a list3187 // DESIGN §8: the permanent footer telling the editor how to use a list
3135 // ("drag · ↵ add · double-click plays") is instructional copy and is gone.3188 // ("drag · ↵ add · double-click plays") is instructional copy and is gone.
3136 assert!(3189 assert!(
@@ -3183,7 +3236,10 @@ fn every_dock_body_mounts_the_ring_it_is_standing_in_for() {
3183 "the dock's key handler stops a stroke outside its tab/escape branches"3236 "the dock's key handler stops a stroke outside its tab/escape branches"
3184 );3237 );
3185 for branch in ["is_focus_cycle_key(key)", "is_focus_exit_key(key)"] {3238 for branch in ["is_focus_cycle_key(key)", "is_focus_exit_key(key)"] {
3186- assert!(body.contains(branch), "{branch} left the dock's key handler");3239+ assert!(
3240+ body.contains(branch),
3241+ "{branch} left the dock's key handler"
3242+ );
3187 }3243 }
3188 }3244 }
3189 3245
@@ -3299,7 +3355,10 @@ fn a_room_ghost_wears_no_chord_that_repeats_its_name() {
3299 fn the_ledger_carries_the_rooms_four_verbs_and_no_rail_remains() {3355 fn the_ledger_carries_the_rooms_four_verbs_and_no_rail_remains() {
3300 let src = src_text("ui/stance.rs");3356 let src = src_text("ui/stance.rs");
3301 for gone in ["stance-spine", "spine_stance", "SPINE_W", "fn spine("] {3357 for gone in ["stance-spine", "spine_stance", "SPINE_W", "fn spine("] {
3302- assert!(!src.contains(gone), "the rail is still in the stance: {gone}");3358+ assert!(
3359+ !src.contains(gone),
3360+ "the rail is still in the stance: {gone}"
3361+ );
3303 }3362 }
3304 let ledger = &src[src.find("fn ledger(").expect("the ledger strip")3363 let ledger = &src[src.find("fn ledger(").expect("the ledger strip")
3305 ..src.find("/// The dock:").expect("the dock frame")];3364 ..src.find("/// The dock:").expect("the dock frame")];
@@ -3341,8 +3400,8 @@ fn the_ledger_carries_the_rooms_four_verbs_and_no_rail_remains() {
3341 /// deletion.3400 /// deletion.
3342 #[test]3401 #[test]
3343 fn select_all_left_the_ruler_for_the_rulers_own_menu() {3402 fn select_all_left_the_ruler_for_the_rulers_own_menu() {
3344- use crate::ActionId;
3345 use crate::menus::BENCH_ITEMS;3403 use crate::menus::BENCH_ITEMS;
3404+ use crate::ActionId;
3346 let bench = src_text("ui/bench_stance.rs");3405 let bench = src_text("ui/bench_stance.rs");
3347 for gone in ["bench-select-all", "select_all_band", "SELECT_ALL_PAD"] {3406 for gone in ["bench-select-all", "select_all_band", "SELECT_ALL_PAD"] {
3348 assert!(!bench.contains(gone), "the ruler still carries {gone}");3407 assert!(!bench.contains(gone), "the ruler still carries {gone}");
@@ -3431,7 +3490,10 @@ fn one_name_per_source_one_stem_helper_and_one_save_door() {
3431 // a path with no name at all still reads as something.3490 // a path with no name at all still reads as something.
3432 use crate::files::{file_name, stem};3491 use crate::files::{file_name, stem};
3433 use std::path::Path;3492 use std::path::Path;
3434- assert_eq!(stem(Path::new("/x/he_is_not_the_only_one.mp4")), "he_is_not_the_only_one");3493+ assert_eq!(
3494+ stem(Path::new("/x/he_is_not_the_only_one.mp4")),
3495+ "he_is_not_the_only_one"
3496+ );
3435 assert_eq!(stem(Path::new("/x/untitled")), "untitled");3497 assert_eq!(stem(Path::new("/x/untitled")), "untitled");
3436 assert_eq!(stem(Path::new("/x/a.b.edith")), "a.b");3498 assert_eq!(stem(Path::new("/x/a.b.edith")), "a.b");
3437 assert_eq!(stem(Path::new("/")), file_name(Path::new("/")));3499 assert_eq!(stem(Path::new("/")), file_name(Path::new("/")));
@@ -3461,7 +3523,6 @@ fn the_ruler_plate_shows_the_timecode_only_while_a_scrub_is_live() {
3461 );3523 );
3462 }3524 }
3463 3525
3464-
3465 /// The band overflowed its own column at 1280x720 (`$EDITH_HITMAP`:3526 /// The band overflowed its own column at 1280x720 (`$EDITH_HITMAP`:
3466 /// `action.Export x=1113 w=80` with the column ending at x=995, the contact3527 /// `action.Export x=1113 w=80` with the column ending at x=995, the contact
3467 /// strip measured `w=0`), so the Export chip was invisible under the dock and3528 /// strip measured `w=0`), so the Export chip was invisible under the dock and
@@ -3471,8 +3532,14 @@ fn the_ruler_plate_shows_the_timecode_only_while_a_scrub_is_live() {
3471 #[test]3532 #[test]
3472 fn the_time_band_never_paints_outside_its_own_column() {3533 fn the_time_band_never_paints_outside_its_own_column() {
3473 let src = src_text("ui/timeband_stance.rs");3534 let src = src_text("ui/timeband_stance.rs");
3474- let start = src.find(r#".id("stance-time-band-row")"#).expect("the band row");3535+ let start = src
3475- let row = &src[start..start + src[start..].find(".child(hero_timecode(").expect("the timecode")];3536+ .find(r#".id("stance-time-band-row")"#)
3537+ .expect("the band row");
3538+ let row = &src[start
3539+ ..start
3540+ + src[start..]
3541+ .find(".child(hero_timecode(")
3542+ .expect("the timecode")];
3476 assert!(3543 assert!(
3477 row.contains(".overflow_hidden()"),3544 row.contains(".overflow_hidden()"),
3478 "the band row lets its children paint (and be clicked) under the dock: {row}"3545 "the band row lets its children paint (and be clicked) under the dock: {row}"
@@ -3518,9 +3585,16 @@ fn the_band_sheds_its_chords_and_nothing_else() {
3518 fn every_ghost_in_the_time_band_carries_a_full_hit_area() {3585 fn every_ghost_in_the_time_band_carries_a_full_hit_area() {
3519 let src = src_text("ui/timeband_stance.rs");3586 let src = src_text("ui/timeband_stance.rs");
3520 let start = src.find("fn ghost(").expect("the band's ghost");3587 let start = src.find("fn ghost(").expect("the band's ghost");
3521- let ghost = &src[start..start + src[start..].find(".child(glyph.into())").expect("its glyph")];3588+ let ghost = &src[start
3589+ ..start
3590+ + src[start..]
3591+ .find(".child(glyph.into())")
3592+ .expect("its glyph")];
3522 for needle in [".min_w(px(HIT_MIN))", ".min_h(px(HIT_MIN))"] {3593 for needle in [".min_w(px(HIT_MIN))", ".min_h(px(HIT_MIN))"] {
3523- assert!(ghost.contains(needle), "the band's ghost lost {needle}: {ghost}");3594+ assert!(
3595+ ghost.contains(needle),
3596+ "the band's ghost lost {needle}: {ghost}"
3597+ );
3524 }3598 }
3525 assert!(HIT_MIN >= 24.);3599 assert!(HIT_MIN >= 24.);
3526 }3600 }
@@ -3532,8 +3606,15 @@ fn every_ghost_in_the_time_band_carries_a_full_hit_area() {
3532 #[test]3606 #[test]
3533 fn the_band_writes_no_monitoring_level() {3607 fn the_band_writes_no_monitoring_level() {
3534 let src = src_text("ui/timeband_stance.rs");3608 let src = src_text("ui/timeband_stance.rs");
3535- for gone in ["player.volume.percent()", "fn volume_readout(", "fn volume_slider("] {3609+ for gone in [
3536- assert!(!src.contains(gone), "the monitoring cluster is back in the band: {gone}");3610+ "player.volume.percent()",
3611+ "fn volume_readout(",
3612+ "fn volume_slider(",
3613+ ] {
3614+ assert!(
3615+ !src.contains(gone),
3616+ "the monitoring cluster is back in the band: {gone}"
3617+ );
3537 }3618 }
3538 }3619 }
3539 3620
@@ -3552,7 +3633,11 @@ fn transport_verbs_differ_by_shape_not_only_by_chord() {
3552 let mut seen = shapes.to_vec();3633 let mut seen = shapes.to_vec();
3553 seen.sort();3634 seen.sort();
3554 seen.dedup();3635 seen.dedup();
3555- assert_eq!(seen.len(), shapes.len(), "two transport verbs share one glyph: {shapes:?}");3636+ assert_eq!(
3637+ seen.len(),
3638+ shapes.len(),
3639+ "two transport verbs share one glyph: {shapes:?}"
3640+ );
3556 }3641 }
3557 3642
3558 /// DESIGN §6: "the cut readout is the odometer". Keyed off the selection it3643 /// DESIGN §6: "the cut readout is the odometer". Keyed off the selection it
@@ -3745,7 +3830,9 @@ fn the_export_section_is_four_rows_and_no_fifth() {
3745 .find("fn export_section(")3830 .find("fn export_section(")
3746 .expect("the export section");3831 .expect("the export section");
3747 let body = &source[start..];3832 let body = &source[start..];
3748- let end = body.find("\n/// The page itself").expect("the page's render fn");3833+ let end = body
3834+ .find("\n/// The page itself")
3835+ .expect("the page's render fn");
3749 let body = &body[..end];3836 let body = &body[..end];
3750 let rows = [3837 let rows = [
3751 "settings-export-picture",3838 "settings-export-picture",
@@ -3760,10 +3847,16 @@ fn the_export_section_is_four_rows_and_no_fifth() {
3760 // unrated one's readout, never both at once -- so the count is by label,3847 // unrated one's readout, never both at once -- so the count is by label,
3761 // not by id.3848 // not by id.
3762 for label in ["\"Picture\"", "\"Sound\"", "\"Encoder\"", "\"Range\""] {3849 for label in ["\"Picture\"", "\"Sound\"", "\"Encoder\"", "\"Range\""] {
3763- assert!(body.contains(label), "the EXPORT section has no {label} row");3850+ assert!(
3851+ body.contains(label),
3852+ "the EXPORT section has no {label} row"
3853+ );
3764 }3854 }
3765 let ids = body.match_indices("\"settings-export-").count();3855 let ids = body.match_indices("\"settings-export-").count();
3766- assert_eq!(ids, 5, "the EXPORT section grew a row past the four (the two Sound rows are one row's two shapes)");3856+ assert_eq!(
3857+ ids, 5,
3858+ "the EXPORT section grew a row past the four (the two Sound rows are one row's two shapes)"
3859+ );
3767 assert!(3860 assert!(
3768 source.contains("what a delivery is written as"),3861 source.contains("what a delivery is written as"),
3769 "the section lost its head"3862 "the section lost its head"
@@ -3780,7 +3873,7 @@ fn the_export_section_is_four_rows_and_no_fifth() {
3780 /// cannot write, because [`Player::set_format`] would only refuse it back.3873 /// cannot write, because [`Player::set_format`] would only refuse it back.
3781 #[test]3874 #[test]
3782 fn the_picture_row_cycles_codec_and_container_together_and_skips_a_refusal() {3875 fn the_picture_row_cycles_codec_and_container_together_and_skips_a_refusal() {
3783- use crate::ui::settings_stance::{PICTURE_CYCLE, next_picture, picture_label};3876+ use crate::ui::settings_stance::{next_picture, picture_label, PICTURE_CYCLE};
3784 assert_eq!(3877 assert_eq!(
3785 PICTURE_CYCLE,3878 PICTURE_CYCLE,
3786 [3879 [
@@ -4017,7 +4110,6 @@ fn no_region_root_wears_a_focus_ring() {
4017 }4110 }
4018 }4111 }
4019 4112
4020-
4021 /// The user could not find the three columns (2026-09-10: "I couldn't realize4113 /// The user could not find the three columns (2026-09-10: "I couldn't realize
4022 /// them when I look at"), because their heads were 12px `ink3` -- the room's4114 /// them when I look at"), because their heads were 12px `ink3` -- the room's
4023 /// quietest type -- with a prose tail running on after each one. The page's4115 /// quietest type -- with a prose tail running on after each one. The page's
@@ -4187,9 +4279,13 @@ fn the_settings_page_is_a_centred_modal_with_one_column_of_measure() {
4187 #[test]4279 #[test]
4188 fn the_picture_row_tail_is_the_current_format_alone() {4280 fn the_picture_row_tail_is_the_current_format_alone() {
4189 let source = src_text("ui/settings_stance.rs");4281 let source = src_text("ui/settings_stance.rs");
4190- let start = source.find("fn export_section(").expect("the export section");4282+ let start = source
4283+ .find("fn export_section(")
4284+ .expect("the export section");
4191 let body = &source[start..];4285 let body = &source[start..];
4192- let body = &body[..body.find("\n/// The page itself").expect("the page's render fn")];4286+ let body = &body[..body
4287+ .find("\n/// The page itself")
4288+ .expect("the page's render fn")];
4193 assert!(4289 assert!(
4194 !body.contains("PICTURE_CYCLE"),4290 !body.contains("PICTURE_CYCLE"),
4195 "the Picture row walks the whole cycle to build its tail again"4291 "the Picture row walks the whole cycle to build its tail again"
crates/app/src/tests/mod.rsmodified+31 -32
@@ -10,56 +10,55 @@ mod media;
10 mod view;10 mod view;
11 11
12 use super::{12 use super::{
13- ACCENT_PRIMARY, AUDIO_KBPS, BG_RAISED, COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W,13+ active_lane, auto_bps, band_label, bitrate_detail, clipboard_after_remove, color_snap,
14- ColorEdit, CONTROL_H, Clip, Ctx, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX, EQ_CURVE_STEPS, EQ_FFT,14+ containers, destructive, enable, enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label,
15- EQ_FREQ_HIGH,15+ eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes, export_path, export_settings,
16- EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW,16+ format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at, frame_rate_ladder,
17- EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, Enable,17+ histogram, inserted_band, is_project, keymap, keys_rows, keys_rows_matching, lane_items,
18- BPS_COARSE, BPS_FINE, BPS_MAX, BPS_MIN, EXPORT_MOMENT_H, EncoderSeat, FORMATS, Format, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN,18+ lanes_h, marked, menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play,
19- KEYS_ROW_H, KEYS_W, KeyRow, LABEL_H, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W,19+ notice_tone, panel_h, parse_budget, project_path, proxies_to_start, push_notice, px_below,
20- BENCH_ITEMS, LIBRARY_MIN_W, Lane, MB_FLOOR, MENU_ITEMS, MENU_PAD,20+ range_word, rate_label, retarget, row_enable, row_items, scrub_due, secs_label, should_resync,
21- MENU_ROW_H, MENU_W, NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H, RESYNC_GAP,21+ silence_rate, size_label, snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at,
22- ROW_ITEMS, RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS,22+ sub_pick_after_removal, sub_pick_after_restore, subtitle_plan, timecode, timeline_fixed_h,
23+ tip_may_paint, transport, typed, unseen_paths, unseen_sources, viz_held_paint, whole_take,
24+ window_title, Clip, ColorEdit, Ctx, Enable, EncoderSeat, Format, KeyRow, Lane, NumberEdit,
25+ RowCtx, RowItem, Source, Speed, StreamInfo, SubPickKey, Transport, VizSlot, Volume, Wave,
26+ ACCENT_PRIMARY, AUDIO_KBPS, BENCH_ITEMS, BG_RAISED, BPS_COARSE, BPS_FINE, BPS_MAX, BPS_MIN,
27+ COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX,
28+ EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H,
29+ EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE,
30+ EXPORT_DONE, EXPORT_MOMENT_H, FORMATS, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN,
31+ KEYS_ROW_H, KEYS_W, LABEL_H, LANES_MAX, LANE_H, LATE_RESYNC, LIBRARY_MAX_W, LIBRARY_MIN_W,
32+ MB_FLOOR, MENU_ITEMS, MENU_PAD, MENU_ROW_H, MENU_W, NOTICES_MAX, NO_FILE, OVERLAID, PANEL_H,
33+ RESYNC_GAP, ROW_ITEMS, RULER_HIT_H, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS,
23 SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_PLAN_CHARS,34 SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_PLAN_CHARS,
24- Source, Speed, StreamInfo, TIMELINE_SHARE, Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL,35+ TIMELINE_SHARE, VOLUME_W, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, ZOOM_MIN_FRAMES,
25- WAVE_COLS_MAX, Wave, ZOOM_MIN_FRAMES, active_lane, auto_bps, band_label, bitrate_detail,
26- clipboard_after_remove, color_snap, containers, destructive, enable, enable_lane, envelope, eq_card_w,
27- eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes, export_path,
28- export_settings, format_refusal, fps_choices, fps_label, frac_along, frac_down,
29- frame_at, frame_rate_ladder, histogram, inserted_band, is_project, keymap, keys_rows, keys_rows_matching, lanes_h,
30- lane_items, marked, menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play,
31- notice_tone, panel_h, parse_budget, project_path, range_word, proxies_to_start, push_notice, px_below, retarget,
32- row_enable, row_items, scrub_due, secs_label, should_resync, silence_rate, size_label,
33- rate_label, snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at, sub_pick_after_removal,
34- subtitle_plan, timecode, timeline_fixed_h, tip_may_paint,
35- transport, typed, unseen_paths, unseen_sources, viz_held_paint, VizSlot, whole_take,
36- window_title,
37 };36 };
38 37
39 use super::{38 use super::{
40- ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, IMPORT_STALL, Import, ImportStage,39+ arrival, audio_rate_choices, av1_hw_warning, clip_width, clock, encoder_choices, encoder_label,
41- Landing, LaneKind, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, SAMPLE_RATES, SEEK_STALL,
42- Scale, ScanKey, ScanPlan, SilenceScan, SubClip, View, ZOOM_OUT_MARGIN, ZOOM_STEP, arrival,
43- audio_rate_choices, av1_hw_warning, clip_width, clock, encoder_choices, encoder_label,
44 eta_secs, file_name, file_uri, fit_choices, frames_of_us, full_scan_key, import_line, landing,40 eta_secs, file_name, file_uri, fit_choices, frames_of_us, full_scan_key, import_line, landing,
45 lane_refuses, launch_queue, library_rows, live_idx, next_fit, next_resolution, note_progress,41 lane_refuses, launch_queue, library_rows, live_idx, next_fit, next_resolution, note_progress,
46 pending_fps_choices, pending_resolution_choices, px_along, read_ahead, repeats,42 pending_fps_choices, pending_resolution_choices, px_along, read_ahead, repeats,
47 resolution_choices, resolution_ladder, sample_rate_choices, scan_plan, seek_line,43 resolution_choices, resolution_ladder, sample_rate_choices, scan_plan, seek_line,
48 silence_cached, silence_line, slice_whole_levels, source_secs, stash_or_write, tone_choices,44 silence_cached, silence_line, slice_whole_levels, source_secs, stash_or_write, tone_choices,
49- tone_label, trimmed_clip, trimmed_sub, trims, unscannable, unusable,45+ tone_label, trimmed_clip, trimmed_sub, trims, unscannable, unusable, ActionId, Choice, Edge,
46+ Import, ImportStage, Landing, LaneKind, Preset, Repeat, Scale, ScanKey, ScanPlan, SilenceScan,
47+ SubClip, View, EDGE_W, ETA_SPAN, FITS, FRAME_RATES, IMPORT_STALL, PPS_DEFAULT, PPS_MIN,
48+ RESOLUTIONS, SAMPLE_RATES, SEEK_STALL, ZOOM_OUT_MARGIN, ZOOM_STEP,
50 };49 };
51 50
52 use super::{51 use super::{
53- SUB_BOTTOM, SUB_CUE_MIN_W, SUB_LINE_H, SUB_TEXT, Subs, carries_subtitles, cue_box, cues_at,52+ carries_subtitles, cue_box, cues_at, file_tint, is_subtitle, lang_human, sub_bottom,
54- file_tint, is_subtitle, lang_human, sub_bottom, sub_pick_name, subtitle_detail,53+ sub_pick_name, subtitle_detail, subtitle_notice, subtitle_rows, subtitle_tail,
55- subtitle_notice, subtitle_rows, subtitle_tail, subtitle_toggle_notice, walk_subtitles,54+ subtitle_toggle_notice, walk_subtitles, Subs, SUB_BOTTOM, SUB_CUE_MIN_W, SUB_LINE_H, SUB_TEXT,
56 };55 };
57 56
58 use engine::PlaybackSession;57 use engine::PlaybackSession;
59 58
60 use engine::scale::FitPolicy;59 use engine::scale::FitPolicy;
61 60
62-use gpui::{Bounds, Pixels, point, px, size};61+use gpui::{point, px, size, Bounds, Pixels};
63 62
64 use std::collections::HashMap;63 use std::collections::HashMap;
65 64
crates/engine/src/playback.rsmodified+64 -7
@@ -1456,12 +1456,15 @@ impl PlaybackSession {
1456 /// unlike [`remove_source`](Self::remove_source) this does not reseek. Rows1456 /// unlike [`remove_source`](Self::remove_source) this does not reseek. Rows
1457 /// past `idx` move down by one: a caller holding a picked row (the export's1457 /// past `idx` move down by one: a caller holding a picked row (the export's
1458 /// subtitle pick) has to fix it up or drop it; the placements on the lanes1458 /// subtitle pick) has to fix it up or drop it; the placements on the lanes
1459- /// are walked down with it and need no fixing. Not an undo step, for the1459+ /// are walked down with it and need no fixing.
1460- /// reason [`Project::remove_subtitles`] gives -- the way back is1460+ ///
1461- /// [`import_subtitles`](Self::import_subtitles), which reads a file's1461+ /// One undo step, and the reindex with it ([`Project::remove_subtitles`]'s
1462- /// subtitles and touches nothing else on the timeline -- and it *empties*1462+ /// own entry): every step in the history names its tracks by index into the
1463- /// the undo history, because the steps in it name the tracks by the indexes1463+ /// palette, so an entry carries the palette it was taken beside its lanes --
1464- /// this call just changed.1464+ /// which is what lets a `z` put this row back, and every placement that
1465+ /// moved down with it. What that entry cannot bring back is the *pick*: it
1466+ /// is the caller's, and a caller holding one fixes it up or drops it
1467+ /// ([`crate::subs::sub_pick_after_restore`]).
1465 pub fn remove_subtitles(&mut self, idx: usize) -> crate::Result<()> {1468 pub fn remove_subtitles(&mut self, idx: usize) -> crate::Result<()> {
1466 self.project.remove_subtitles(idx)1469 self.project.remove_subtitles(idx)
1467 }1470 }
@@ -3723,10 +3726,17 @@ impl PlaybackSession {
3723 /// ([`Self::adopt_settings`]). Reseeks both halves, so a canvas that moved3726 /// ([`Self::adopt_settings`]). Reseeks both halves, so a canvas that moved
3724 /// is repainted and a proxy switch that flipped reopens the file.3727 /// is repainted and a proxy switch that flipped reopens the file.
3725 fn restored_step(&mut self, f: impl FnOnce(&mut Project) -> bool) -> bool {3728 fn restored_step(&mut self, f: impl FnOnce(&mut Project) -> bool) -> bool {
3726- if !self.edit(Dirty::Both, f) {3729+ if !f(&mut self.project) {
3727 return false;3730 return false;
3728 }3731 }
3732+ // Adopted *before* the reseek below, never after it: everything the
3733+ // reseek reads is one of the settings the entry just put back --
3734+ // `landing` the rate and the frame count, `picture_path` the switches,
3735+ // the sound the sample rate -- so a landing computed from the values
3736+ // the step *undid* lands on the wrong frame of the right project (and
3737+ // reopens the file through the switch that just went back).
3729 self.adopt_settings();3738 self.adopt_settings();
3739+ self.invalidate(Dirty::Both);
3730 true3740 true
3731 }3741 }
3732 3742
@@ -5091,6 +5101,53 @@ mod tests {
5091 assert_eq!(next.index, first.index, "paused: same timeline position before and after");5101 assert_eq!(next.index, first.index, "paused: same timeline position before and after");
5092 }5102 }
5093 5103
5104+ /// A rate undo lands the picture where the playhead is, in the rate that
5105+ /// came *back*: the entry a pick takes carries the old numbering beside the
5106+ /// old rate, so an undo restores both and the reseek has to be computed
5107+ /// after the restore. Computed before it, the landing is the pre-undo
5108+ /// rate's reading of the post-undo project -- `now` clamps to the pre-undo
5109+ /// rate's idea of the timeline's end and the worker is handed the last
5110+ /// frame of a five-second timeline for a playhead at three seconds.
5111+ #[test]
5112+ fn a_rate_undo_reseeks_at_the_rate_it_restored() {
5113+ let mut s = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
5114+ s.set_gain(0.0);
5115+ let poll = |s: &mut PlaybackSession| -> crate::decode::Frame {
5116+ let deadline = std::time::Instant::now() + std::time::Duration::from_secs(20);
5117+ loop {
5118+ if let Some(f) = s.try_frame() {
5119+ return f;
5120+ }
5121+ assert!(std::time::Instant::now() < deadline, "no frame within 20s");
5122+ std::thread::sleep(std::time::Duration::from_millis(10));
5123+ }
5124+ };
5125+ let native = s.native_frame_rate();
5126+ s.seek(3.0);
5127+ assert_eq!(s.now(), 3.0, "the fixture is five seconds long");
5128+ assert!(s.set_frame_rate(native * 2.0), "the rate pick");
5129+ assert!(s.undo(), "the pick is one step");
5130+ assert_eq!(s.meta().frame_rate, native, "the rate came back");
5131+ assert_eq!(
5132+ s.now(),
5133+ 3.0,
5134+ "the playhead is the seconds it was, read at the rate that came back"
5135+ );
5136+ // The worker's own landing, which is the half the clock alone cannot
5137+ // show: a frame 149 of 150 is exactly the pre-undo rate's clamp.
5138+ assert_eq!(
5139+ s.span.expect("a span for the picture").start,
5140+ secs_to_frame(3.0, native),
5141+ "the picture was asked for the playhead's own frame"
5142+ );
5143+ let frame = poll(&mut s);
5144+ assert_eq!(
5145+ frame.index,
5146+ secs_to_frame(3.0, native),
5147+ "and that is the frame that arrived"
5148+ );
5149+ }
5150+
5094 /// The session's live look samples leave its history exactly where the5151 /// The session's live look samples leave its history exactly where the
5095 /// press left it -- the colour-wheel drag's twin for the packed look, and5152 /// press left it -- the colour-wheel drag's twin for the packed look, and
5096 /// what lets the app drive one from a pointer: `z` after a drag lands5153 /// what lets the app drive one from a pointer: `z` after a drag lands
crates/engine/src/project.rsmodified+12 -0
@@ -116,6 +116,10 @@ pub(crate) struct SweepParts(
116 pub(crate) usize,116 pub(crate) usize,
117 pub(crate) Vec<(LaneKind, Vec<Clip>)>,117 pub(crate) Vec<(LaneKind, Vec<Clip>)>,
118 pub(crate) Vec<Vec<SubClip>>,118 pub(crate) Vec<Vec<SubClip>>,
119+ /// The palette, which the history holds beside the lanes and an undo
120+ /// therefore restores ([`Project::undo`]). Left out of this shape, a
121+ /// round-trip check passed with the palette restore deleted outright.
122+ pub(crate) Vec<SubtitleTrack>,
119 pub(crate) ProjectSettings,123 pub(crate) ProjectSettings,
120 );124 );
121 125
@@ -5083,6 +5087,7 @@ impl Project {
5083 self.sources.len(),5087 self.sources.len(),
5084 self.lanes.iter().map(|l| (l.kind, l.clips.clone())).collect(),5088 self.lanes.iter().map(|l| (l.kind, l.clips.clone())).collect(),
5085 self.lanes.iter().map(|l| l.subs.clone()).collect(),5089 self.lanes.iter().map(|l| l.subs.clone()).collect(),
5090+ self.subtitles.clone(),
5086 self.settings.clone(),5091 self.settings.clone(),
5087 )5092 )
5088 }5093 }
@@ -10569,14 +10574,21 @@ fn removing_a_subtitle_column_undoes_with_its_reindex() {
10569 .with_subtitles(vec![track("one"), track("two"), track("three")]);10574 .with_subtitles(vec![track("one"), track("two"), track("three")]);
10570 assert_eq!(p.subtitles().len(), 3);10575 assert_eq!(p.subtitles().len(), 3);
10571 let before = p.parts();10576 let before = p.parts();
10577+ let palette = p.subtitles().to_vec();
10572 // Column 0 goes, which renumbers the two behind it.10578 // Column 0 goes, which renumbers the two behind it.
10573 p.remove_subtitles(0).expect("a column with nothing on it");10579 p.remove_subtitles(0).expect("a column with nothing on it");
10574 assert_eq!(p.subtitles().len(), 2);10580 assert_eq!(p.subtitles().len(), 2);
10575 assert_eq!(p.subtitles()[0].label, "two");10581 assert_eq!(p.subtitles()[0].label, "two");
10576 assert!(p.undo(), "the removal is a step like any other cut");10582 assert!(p.undo(), "the removal is a step like any other cut");
10583+ // The palette itself, and not only what `parts` happens to compare: this
10584+ // is the assertion that cannot go vacuous if the restore below it ever
10585+ // leaves a field of it behind.
10586+ assert_eq!(p.subtitles(), palette.as_slice(), "the palette itself, back");
10577 assert_eq!(p.parts(), before, "the palette and the lanes, both back");10587 assert_eq!(p.parts(), before, "the palette and the lanes, both back");
10578 assert!(p.redo(), "and forward again");10588 assert!(p.redo(), "and forward again");
10589+ assert_eq!(p.subtitles().len(), 2, "the column goes again");
10579 assert_eq!(p.subtitles()[0].label, "two");10590 assert_eq!(p.subtitles()[0].label, "two");
10591+ assert_ne!(p.subtitles(), palette.as_slice(), "and it is not back");
10580 }10592 }
10581 10593
10582 }10594 }
crates/engine/src/subtitle.rsmodified+5 -1
@@ -140,7 +140,11 @@ fn segments(set: &[u8]) -> Option<Vec<(u8, &[u8])>> {
140 }140 }
141 141
142 /// A subtitle track: where it came from and what it says.142 /// A subtitle track: where it came from and what it says.
143-#[derive(Clone, Debug)]143+///
144+/// `PartialEq` because it is one of the things an edit can change and therefore
145+/// one of the things an undo has to bring back exactly
146+/// ([`crate::Project::parts`], the sweep's round-trip).
147+#[derive(Clone, Debug, PartialEq, Eq)]
144 pub struct SubtitleTrack {148 pub struct SubtitleTrack {
145 /// The file it was read out of: a standalone subtitle file, or the media149 /// The file it was read out of: a standalone subtitle file, or the media
146 /// file whose track number is below.150 /// file whose track number is below.