mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-12-05 19:51:56 -05:00
fix(ui): name a warning found after an edit on a dismissed page (#4340)
page_changed drops the page's cached render warnings but kept the reader's dismissal for that page, so a different warning found after the edit stayed hidden behind the old dismissal. Forget the dismissal with the reports. The notice bar's icon call moves to the IconId type from main.
This commit is contained in:
@@ -323,7 +323,7 @@ fn warned_pages_bar(view: &mut DocView, ui: &mut egui::Ui) {
|
||||
&[("n", &n.to_string()), ("page", &page), ("what", &what)],
|
||||
)
|
||||
};
|
||||
if bar(Tone::Warn, "triangle-alert", text).dismiss().show(ui).dismissed {
|
||||
if bar(Tone::Warn, IconId::new("triangle-alert"), text).dismiss().show(ui).dismissed {
|
||||
view.warn_notice_dismissed.extend(warned.iter().map(|(page, _)| *page));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,9 @@ impl DocView {
|
||||
let _dropped = queue.reprioritize(|key, priority| (*key != page).then_some(priority));
|
||||
}
|
||||
self.reports.forget(page);
|
||||
// The page's old warnings are gone, so a reader's dismissal of them no longer covers the
|
||||
// page: a warning found after the edit must be named, not stay hidden (#4340 review).
|
||||
self.warn_notice_dismissed.remove(&page);
|
||||
if self.session.text.selection.as_ref().is_some_and(|s| s.pages().contains(&page)) {
|
||||
// With the marks a tool waits to make on it (#5017 review).
|
||||
self.session.text.selection = None;
|
||||
|
||||
@@ -317,6 +317,39 @@ fn a_page_with_a_render_warning_is_named_until_dismissed() {
|
||||
h.get_by_label_contains("spaced by their procedures");
|
||||
}
|
||||
|
||||
/// An edit drops that page's cached warnings together with the reader's dismissal of them: a
|
||||
/// different warning found after the edit is named, though the page's old one was dismissed
|
||||
/// (#4340 review).
|
||||
#[test]
|
||||
fn a_warning_after_an_edit_on_a_dismissed_page_is_named() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
use pdfcraft_render::RenderWarning;
|
||||
|
||||
let mut h = egui_kittest::Harness::builder().with_size(vec2(1400.0, 900.0)).build_eframe(|cc| {
|
||||
crate::PdfCraftApp::install_runtime(&cc.egui_ctx);
|
||||
{
|
||||
let mut app = PdfCraftApp::for_unit_tests();
|
||||
app.set_option(&cc.egui_ctx, "language", "en").unwrap();
|
||||
let bytes = app.session.create_blank(300.0, 400.0, 2).unwrap();
|
||||
app.open_bytes(&egui::Context::default(), "blank.pdf", None, bytes.as_ref().clone()).unwrap();
|
||||
app
|
||||
}
|
||||
});
|
||||
h.run_steps(3);
|
||||
h.state_mut().views[0].reports.warn(0, RenderWarning::ColourFallback);
|
||||
h.run_steps(2);
|
||||
h.get_by_label_contains("painted in a fallback colour");
|
||||
h.get_by_label("Dismiss").click();
|
||||
h.run_steps(2);
|
||||
assert!(h.query_by_label_contains("painted in a fallback colour").is_none(), "the warning bar can be dismissed");
|
||||
// The page is edited, so the renderer finds a different warning on it: the old dismissal
|
||||
// covered the warning that is gone, not this one.
|
||||
h.state_mut().views[0].page_changed(0);
|
||||
h.state_mut().views[0].reports.warn(0, RenderWarning::Type3WidthsMissing);
|
||||
h.run_steps(2);
|
||||
h.get_by_label_contains("spaced by their procedures");
|
||||
}
|
||||
|
||||
/// Dismissing another notice doesn't hide a page found cut later (#623), and dismissing the
|
||||
/// cut-page notice lasts until another page is found cut (review on #2113).
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user