From c812c83d95b7055a9e5b1325c7be1523914d3b9e Mon Sep 17 00:00:00 2001 From: Jeffrey Thayne <36243577+thaynej@users.noreply.github.com> Date: Fri, 9 Oct 2026 16:52:53 -0600 Subject: [PATCH] Word import: keep tracked moved text (w:moveTo) Text inside a tracked move destination was dropped on .docx import, so moved passages vanished from both places. Treat moveTo like ins (both kept as accepted); moveFrom stays skipped like del. Regression test covers ins, del, moveFrom and moveTo together. Fixes #256. Also adds my contributor credit entry. Co-Authored-By: Claude Opus 5.5 --- contributors/people.toml | 3 +++ crates/textimport/src/docx.rs | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/contributors/people.toml b/contributors/people.toml index 89c6db208..c480bd68a 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -21,3 +21,6 @@ real_name = "Brandon Thomas" display_name = "Brandon Thomas" sync_github_name = false + +[people.thaynej] +real_name = "Jeffrey Thayne" diff --git a/crates/textimport/src/docx.rs b/crates/textimport/src/docx.rs index 563eb7289..670f8a0fa 100644 --- a/crates/textimport/src/docx.rs +++ b/crates/textimport/src/docx.rs @@ -276,7 +276,9 @@ impl Ctx { for e in p.els() { match e.name.as_str() { "r" => self.run(e, st, allow_notes), - "hyperlink" | "smartTag" | "ins" | "fldSimple" | "customXml" => self.inline(e, st, allow_notes), + // Tracked changes import as accepted: insertions and move destinations are kept, + // deletions (`del`) and move sources (`moveFrom`) are dropped. + "hyperlink" | "smartTag" | "ins" | "moveTo" | "fldSimple" | "customXml" => self.inline(e, st, allow_notes), _ => {} } } @@ -469,4 +471,23 @@ mod tests { assert_eq!(i.para_styles[0].para.space_before, Some(12.0)); assert_eq!(i.char_styles[0].chars.font_style.as_deref(), Some("Italic")); } + + #[test] + fn tracked_changes_import_as_accepted_including_moves() { + // Regression (#256): text in a tracked move destination (`w:moveTo`) vanished on import. + let document = format!( + r#" + Kept text. + MOVED HERE. + MOVED THEN DELETED + Plain + INSERTED + DELETED + MOVED HERE.End. + "# + ); + let i = import(&docx(&document, "", "")).unwrap(); + i.story.check().unwrap(); + assert_eq!(i.story.text, "Kept text. MOVED HERE. Plain INSERTED\nEnd."); + } }