Highlight both cues in timing overlaps
This commit is contained in:
parent
68aa45bb72
commit
de72069577
|
|
@ -90,12 +90,27 @@ struct PreviewRow {
|
|||
source_only: bool,
|
||||
automatically_ignored: bool,
|
||||
issues: Vec<usize>,
|
||||
related_issues: Vec<usize>,
|
||||
decisions: String,
|
||||
kind: String,
|
||||
gap: bool,
|
||||
gap_key: Option<String>,
|
||||
}
|
||||
|
||||
fn row_diagnostic_message(row: &PreviewRow, index: usize, diagnostic: &Diagnostic) -> String {
|
||||
if row.related_issues.contains(&index) && diagnostic.code == "OVERLAP" {
|
||||
"This cue is the predecessor in the overlap. Its end conflicts with the following cue's start; either row may need a timing correction or a separate track."
|
||||
.into()
|
||||
} else {
|
||||
diagnostic
|
||||
.message
|
||||
.split("\nRow preview:")
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
/// Combine timed draft entries and omitted problem rows without changing the IR.
|
||||
fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
||||
let mut rows = Vec::new();
|
||||
|
|
@ -128,6 +143,7 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
.filter(|(_, d)| diagnostic_row(d) == e.source_rows.first().map(|s| s.row))
|
||||
.map(|(i, _)| i)
|
||||
.collect(),
|
||||
related_issues: vec![],
|
||||
decisions: e.decisions.join("\n"),
|
||||
kind: e.kind.clone(),
|
||||
gap: false,
|
||||
|
|
@ -189,6 +205,7 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
.filter(|(_, d)| diagnostic_row(d) == Some(row))
|
||||
.map(|(i, _)| i)
|
||||
.collect(),
|
||||
related_issues: vec![],
|
||||
decisions: String::new(),
|
||||
gap: false,
|
||||
gap_key: None,
|
||||
|
|
@ -265,6 +282,7 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
source_only: true,
|
||||
automatically_ignored: false,
|
||||
issues: a.diagnostics.iter().enumerate().filter(|(_, d)| d.location == format!("{} gap {:?}–{:?}", rundown.title, gap.after_row, gap.before_row)).map(|(i, _)| i).collect(),
|
||||
related_issues: vec![],
|
||||
decisions: "Keep the interval untimed, extend the previous event to its end, or start the next event at its beginning. Recheck to apply the choice.".into(),
|
||||
kind: if rundown.resolved_gaps.iter().any(|g| g.key() == gap.key()) {
|
||||
"Allocated gap · included in adjacent timer".into()
|
||||
|
|
@ -274,6 +292,29 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
});
|
||||
}
|
||||
}
|
||||
if let Some(rundown) = &a.rundown {
|
||||
for (index, diagnostic) in a.diagnostics.iter().enumerate() {
|
||||
if diagnostic.code != "OVERLAP" {
|
||||
continue;
|
||||
}
|
||||
let Some(current_row) = diagnostic_row(diagnostic) else {
|
||||
continue;
|
||||
};
|
||||
let Some(previous_row) = rundown.entries.windows(2).find_map(|pair| {
|
||||
(pair[1].source_rows.first().map(|source| source.row) == Some(current_row))
|
||||
.then(|| pair[0].source_rows.first().map(|source| source.row))
|
||||
.flatten()
|
||||
}) else {
|
||||
continue;
|
||||
};
|
||||
if let Some(row) = rows.iter_mut().find(|row| row.row == previous_row) {
|
||||
if !row.issues.contains(&index) {
|
||||
row.issues.push(index);
|
||||
}
|
||||
row.related_issues.push(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
for row in &mut rows {
|
||||
if a.automatically_ignored_rows.contains(&row.row) {
|
||||
row.automatically_ignored = true;
|
||||
|
|
@ -690,8 +731,10 @@ impl App {
|
|||
let d = &a.diagnostics[*index];
|
||||
let color = if needs_information(d) { PREVIEW_AMBER } else { PREVIEW_RED };
|
||||
egui::Frame::group(ui.style()).show(ui, |ui| {
|
||||
ui.colored_label(color, d.code.replace('_', " "));
|
||||
ui.add(egui::Label::new(d.message.split("\nRow preview:").next().unwrap_or_default()).wrap());
|
||||
ui.colored_label(color, if preview.related_issues.contains(index) {
|
||||
"RELATED OVERLAP".into()
|
||||
} else { d.code.replace('_', " ") });
|
||||
ui.add(egui::Label::new(row_diagnostic_message(preview, *index, d)).wrap());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1288,13 +1331,11 @@ impl App {
|
|||
for index in &row.issues {
|
||||
let diagnostic = &a.diagnostics[*index];
|
||||
explanation.push_str("\n\n");
|
||||
explanation.push_str(
|
||||
diagnostic
|
||||
.message
|
||||
.split("\nRow preview:")
|
||||
.next()
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
explanation.push_str(&row_diagnostic_message(
|
||||
row,
|
||||
*index,
|
||||
diagnostic,
|
||||
));
|
||||
}
|
||||
if row.row > 0 {
|
||||
explanation.push_str(
|
||||
|
|
@ -2335,6 +2376,65 @@ mod tests {
|
|||
assert!(labels.iter().any(|(s, _)| s == "Empty"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overlap_marks_both_the_current_and_preceding_cue() {
|
||||
let mut app = sample();
|
||||
app.tables[0].rows.last_mut().unwrap()[0].text = "09:04".into();
|
||||
let profile = Profile {
|
||||
ignore_warnings: true,
|
||||
..Default::default()
|
||||
};
|
||||
app.profile = serde_json::to_string(&profile).unwrap();
|
||||
let analysis =
|
||||
pipeline::analyze(&app.tables[0], &profile, &AtomicBool::new(false), |_, _| {});
|
||||
let overlap = analysis
|
||||
.diagnostics
|
||||
.iter()
|
||||
.position(|diagnostic| diagnostic.code == "OVERLAP")
|
||||
.unwrap();
|
||||
let rows = preview_rows(&analysis, Some(&app.tables[0]));
|
||||
let previous = rows.iter().find(|row| row.row == 2).unwrap();
|
||||
let current = rows.iter().find(|row| row.row == 15).unwrap();
|
||||
assert!(previous.issues.contains(&overlap));
|
||||
assert!(previous.related_issues.contains(&overlap));
|
||||
assert!(current.issues.contains(&overlap));
|
||||
assert!(!current.related_issues.contains(&overlap));
|
||||
assert!(
|
||||
row_diagnostic_message(previous, overlap, &analysis.diagnostics[overlap])
|
||||
.contains("either row may need")
|
||||
);
|
||||
|
||||
app.analysis = Some(analysis);
|
||||
app.row_filter = RowFilter::Included;
|
||||
let ctx = egui::Context::default();
|
||||
configure_style(&ctx);
|
||||
ctx.style_mut(|style| {
|
||||
style.interaction.tooltip_delay = 0.0;
|
||||
style.interaction.tooltip_grace_time = 0.0;
|
||||
});
|
||||
let size = [860.0, 620.0];
|
||||
render(&mut app, &ctx, size, vec![]);
|
||||
let labels = render(&mut app, &ctx, size, vec![]);
|
||||
let opening = labels
|
||||
.iter()
|
||||
.find(|(text, _)| text == "Opening")
|
||||
.unwrap()
|
||||
.1
|
||||
.center();
|
||||
render(
|
||||
&mut app,
|
||||
&ctx,
|
||||
size,
|
||||
vec![egui::Event::PointerMoved(opening)],
|
||||
);
|
||||
let labels = render(&mut app, &ctx, size, vec![]);
|
||||
assert!(
|
||||
labels
|
||||
.iter()
|
||||
.any(|(text, _)| text.contains("predecessor in the overlap"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preview_marks_invalid_timers_and_supports_failures_before_ir() {
|
||||
let mut app = sample();
|
||||
|
|
|
|||
|
|
@ -75,8 +75,10 @@ visually distinct from labels and ordinary actions; the active tab uses the stro
|
|||
diagnostics from the last analysis and gaps for context. Ignored rows can be restored using All rows.
|
||||
Notes attached to another event keep their own source row and identify their
|
||||
parent timer instead of duplicating it. Amber means unresolved, red means an
|
||||
error, gray means ignored, and teal marks gaps. Gaps appear in schedule order
|
||||
with their start, end and elapsed duration (no timer). Named breaks use their
|
||||
error, gray means ignored, and teal marks gaps. An overlap marks both the later
|
||||
cue and its predecessor in red because either timing may need correction; each
|
||||
row's hover and inspector explains its side of the conflict. Gaps appear in
|
||||
schedule order with their start, end and elapsed duration (no timer). Named breaks use their
|
||||
source row; inferred gaps update after recheck. Each gap offers **Keep gap**
|
||||
(default, no timer), **Extend previous timing** (extend the preceding event's end),
|
||||
or **Add to next timing** (start the following event earlier, keeping its end).
|
||||
|
|
|
|||
Loading…
Reference in New Issue