M7: replacing a line keeps both of two dropped quote copies' line move and spacing (edit.text-edit) (#2961)

This commit is contained in:
mtlcl410 authored and GitHub committed 2026-11-11 11:04:56 +07:00
1 parent d2916decb3
commit 41d959d94c
1 file changed
+9 -4
+9 -4
View File
@@ -10060,11 +10060,16 @@ fn rewriting_a_paragraph_drawn_with_quote_operators_keeps_their_line_move_and_sp
fn replacing_a_line_keeps_what_a_dropped_quote_copy_did() {
let cases = [
// The copy's `'` moves to the line the footer is placed from.
"BT /F1 12 Tf 14 TL 72 700 Td (Target line here) Tj ET BT 72.3 714 Td (Target line here) ' 0 -100 Td (Footer stays put) Tj ET",
(2, "BT /F1 12 Tf 14 TL 72 700 Td (Target line here) Tj ET BT 72.3 714 Td (Target line here) ' 0 -100 Td (Footer stays put) Tj ET"),
// The copy's `"` sets the spacing the footer inherits in the next text object.
"BT /F1 12 Tf 0 TL 72 700 Td (Target line here) Tj ET BT 72.3 700 Td 3 2 (Target line here) \" ET BT 72 600 Td (Footer stays put) Tj ET",
(2, "BT /F1 12 Tf 0 TL 72 700 Td (Target line here) Tj ET BT 72.3 700 Td 3 2 (Target line here) \" ET BT 72 600 Td (Footer stays put) Tj ET"),
// Two copies, a `'` one and a `"` one: the footer takes the second's line and spacing.
(
3,
"BT /F1 12 Tf 0 TL 72 700 Td (Target line here) Tj ET BT 72.3 700 Td (Target line here) ' ET BT 72.6 700 Td 3 2 (Target line here) \" 0 -100 Td (Footer stays put) Tj ET",
),
];
for content in cases {
for (drawn, content) in cases {
let footer = |doc: &Document| {
let lines = text::text_lines(doc, 0).unwrap();
let f = lines.iter().find(|l| l.text == "Footer stays put").unwrap_or_else(|| panic!("no footer in {content}"));
@@ -10074,7 +10079,7 @@ fn replacing_a_line_keeps_what_a_dropped_quote_copy_did() {
let before = footer(&original);
let targets: Vec<usize> =
text::text_lines(&original, 0).unwrap().iter().enumerate().filter(|(_, l)| l.text == "Target line here").map(|(i, _)| i).collect();
assert_eq!(targets.len(), 2, "{content}");
assert_eq!(targets.len(), drawn, "{content}");
for target in targets {
let mut doc = original.clone();
text::replace_line(&mut doc, 0, target, "NEW TEXT").unwrap();