From 6411cc803fb02aae8c5486f49a161b091de0bc44 Mon Sep 17 00:00:00 2001 From: mtlcl410 <2368091+mtlcl410@users.noreply.github.com> Date: Thu, 22 Oct 2026 07:47:05 +0800 Subject: [PATCH] M5: a Replace text comment is named Replace text, not Strikethrough (#3947) The Replace text tool saves a StrikeOut with /IT /StrikeOutTextEdit and a caret reply. The Comments panel named it by subtype only, and tool_for mapped it to the Strikethrough tool, so Make Current Properties Default on it changed the Strikethrough tool's defaults. Both now read the intent. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01R3niW7kVeT8mi7TpWc8eAJ --- crates/ui-egui/src/comments.rs | 1 + crates/ui-egui/src/comments_panel.rs | 3 ++- crates/ui-egui/tests/comments.rs | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/comments.rs b/crates/ui-egui/src/comments.rs index 7fd9b7a62..d06eafdad 100644 --- a/crates/ui-egui/src/comments.rs +++ b/crates/ui-egui/src/comments.rs @@ -347,6 +347,7 @@ pub fn tool_for(a: &Annotation) -> Option { ("FreeText", _) => CommentTool::TextBox, ("Highlight", _) => CommentTool::Highlight, ("Underline", _) => CommentTool::Underline, + ("StrikeOut", Some("StrikeOutTextEdit")) => CommentTool::ReplaceText, ("StrikeOut", _) => CommentTool::StrikeOut, ("Squiggly", _) => CommentTool::Squiggly, ("Ink", _) => CommentTool::Ink, diff --git a/crates/ui-egui/src/comments_panel.rs b/crates/ui-egui/src/comments_panel.rs index 2ac1853f4..7dca40b85 100644 --- a/crates/ui-egui/src/comments_panel.rs +++ b/crates/ui-egui/src/comments_panel.rs @@ -33,9 +33,10 @@ pub fn subtype_label(s: &str) -> &str { } } -/// The comment type as the panel names it, telling callouts and clouds apart by `/IT`. +/// The comment type as the panel names it, telling callouts, clouds and replaced text apart by `/IT`. pub fn kind_label(a: &Annotation) -> &str { match a.intent.as_deref() { + Some("StrikeOutTextEdit") => "Replace text", Some("FreeTextCallout") => "Callout", Some("PolygonCloud") => "Cloud", Some("FreeTextTypeWriter") => "Typewriter", diff --git a/crates/ui-egui/tests/comments.rs b/crates/ui-egui/tests/comments.rs index 01166a41d..daab3ad64 100644 --- a/crates/ui-egui/tests/comments.rs +++ b/crates/ui-egui/tests/comments.rs @@ -1231,6 +1231,13 @@ fn replacing_text_strikes_it_and_adds_a_caret() { assert_eq!(caret.in_reply_to, strike.name, "grouped with the strikeout"); assert_eq!(h.state().session.get(h.state().views[0].id).unwrap().can_undo(), Some("Replace text")); assert_eq!(h.state().quick_tool, QuickTool::Select); + // The strikeout is the Replace text tool's, not Strikethrough's (#3947): the panel names it + // so, and Make Current Properties Default updates the Replace text tool. + assert_eq!(pdfcraft_ui_egui::comments::tool_for(strike), Some(pdfcraft_ui_egui::comments::CommentTool::ReplaceText)); + h.state_mut().set_option("panel", "comments").unwrap(); + h.run_steps(3); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Label, "Replace text").is_some(), "the panel names the comment Replace text"); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Label, "Strikethrough").is_none(), "not Strikethrough"); } #[test]