diff --git a/crates/rundown-converter/src/gui.rs b/crates/rundown-converter/src/gui.rs index 7fc9349..fca0b5f 100644 --- a/crates/rundown-converter/src/gui.rs +++ b/crates/rundown-converter/src/gui.rs @@ -20,7 +20,7 @@ use std::{ enum Update { Progress(String), Sheets(Vec), - Analyzed(Box, Table), + Analyzed(Box, Table, Box), Exported(PathBuf), Failed(String), } @@ -70,6 +70,7 @@ struct App { sheet: String, profile: String, analysis: Option, + analyzed_profile: Option, tab: Tab, status: String, error: Option, @@ -129,6 +130,7 @@ impl Default for App { sheet: String::new(), profile: "{}".into(), analysis: None, + analyzed_profile: None, tab: Tab::Setup, status: "Choose a spreadsheet to begin".into(), error: None, @@ -162,6 +164,7 @@ impl Default for App { impl App { fn invalidate(&mut self) { self.analysis = None; + self.analyzed_profile = None; self.mapping_focus = None; self.mapping_focus_scroll = None; self.mapping_focus_until = None; @@ -233,6 +236,7 @@ impl App { let path = PathBuf::from(&self.input); let sheet = self.sheet.clone(); self.analysis = None; + self.analyzed_profile = None; let tx = self.begin(); let cancel = self.cancel.clone(); std::thread::spawn(move || { @@ -250,7 +254,7 @@ impl App { )) })(); let _ = tx.send(match result { - Ok((a, table)) => Update::Analyzed(Box::new(a), table), + Ok((a, table)) => Update::Analyzed(Box::new(a), table, Box::new(profile)), Err(e) => Update::Failed(format!("{e:#}")), }); }); @@ -319,7 +323,7 @@ impl App { "Ready to analyze".into() }; } - Update::Analyzed(a, table) => { + Update::Analyzed(a, table, profile) => { self.tables.retain(|t| t.name != table.name); self.tables.push(table); self.rx = None; @@ -343,6 +347,7 @@ impl App { } else { ReviewView::Rows }; + self.analyzed_profile = Some(*profile); self.analysis = Some(*a); } Update::Exported(p) => { diff --git a/crates/rundown-converter/src/gui/review.rs b/crates/rundown-converter/src/gui/review.rs index ca95e52..a96ece2 100644 --- a/crates/rundown-converter/src/gui/review.rs +++ b/crates/rundown-converter/src/gui/review.rs @@ -606,7 +606,10 @@ impl App { self.selected_gap = None; self.jump_row = row; if let Some(row) = row { - let profile: Profile = serde_json::from_str(&self.profile).unwrap_or_default(); + let profile = self + .analyzed_profile + .clone() + .unwrap_or_else(|| serde_json::from_str(&self.profile).unwrap_or_default()); let table = self.tables.iter().find(|t| t.name == self.sheet); if self.row_filter == RowFilter::Included && ignored_row( @@ -1519,6 +1522,10 @@ impl App { ui.label("Correct the profile JSON in Columns before editing rows."); return; }; + let analyzed_profile = self + .analyzed_profile + .clone() + .unwrap_or_else(|| profile.clone()); let before = serde_json::to_string(&profile).unwrap(); let Some(a) = &self.analysis else { ui.label("Analyze the sheet to see the schedule and edit its rows."); @@ -1537,7 +1544,15 @@ impl App { let all_rows = preview_rows(a, table); let rows: Vec<_> = all_rows .iter() - .filter(|r| show_row(r, self.row_filter, table, &profile, a.mapping.as_ref())) + .filter(|r| { + show_row( + r, + self.row_filter, + table, + &analyzed_profile, + a.mapping.as_ref(), + ) + }) .collect(); if rows.is_empty() { ui.label(match self.row_filter { @@ -1572,7 +1587,7 @@ impl App { let backgrounds: Vec<_> = std::iter::once(None) .chain(rows.iter().map(|row| { if row.automatically_ignored - || ignored_row(row.row, table, &profile, a.mapping.as_ref()) + || ignored_row(row.row, table, &analyzed_profile, a.mapping.as_ref()) { Some(Color32::from_rgb(34, 35, 39)) } else if row @@ -1624,7 +1639,12 @@ impl App { for row in &rows { let row_top = ui.cursor().min; let ignored = row.automatically_ignored - || ignored_row(row.row, table, &profile, a.mapping.as_ref()); + || ignored_row( + row.row, + table, + &analyzed_profile, + a.mapping.as_ref(), + ); let error = row .issues .iter() @@ -1895,6 +1915,7 @@ mod tests { sheet: table.name.clone(), tables: vec![table], analysis: Some(analysis), + analyzed_profile: Some(Profile::default()), tab: Tab::Review, selected_row: Some(3), ..Default::default() @@ -2606,6 +2627,12 @@ mod tests { assert_eq!(profile.row_kinds[&3], "ignore"); assert!(app.dirty); assert!(!app.row_details); + app.row_filter = RowFilter::Included; + let labels = render(&mut app, &ctx, [860.0, 900.0], vec![]); + assert!( + labels.iter().any(|(s, _)| s == "Stage direction 0"), + "a pending Ignore choice must not move the row before recheck" + ); let a = pipeline::analyze(&app.tables[0], &profile, &AtomicBool::new(false), |_, _| {}); assert!(!a.diagnostics.iter().any(|d| diagnostic_row(d) == Some(3))); let rows = preview_rows(&a, Some(&app.tables[0]));