Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The archive row uses `cargo package --locked --allow-dirty --no-verify` with all

| Measurement | Value | Version | Platform | Build mode | Input | Command | Statistic | Measured on |
|---|---|---|---|---|---|---|---|---|
| Crates.io archive: rdocx | 4,501,789 compressed bytes, 56,396,845 member bytes, 37 members | 0.17.0 | macOS 26.6.2, Apple M5 Max, arm64 | `cargo package --locked --allow-dirty --no-verify` | Tracked `rdocx` package inventory | `python3 scripts/readme_doctests.py --record-measurements` | gzip archive bytes, tar member bytes, tar member count | 2026-11-09 |
| Crates.io archive: rdocx | 4,511,214 compressed bytes, 56,437,697 member bytes, 37 members | 0.17.0 | macOS 26.6.2, Apple M5 Max, arm64 | `cargo package --locked --allow-dirty --no-verify` | Tracked `rdocx` package inventory | `python3 scripts/readme_doctests.py --record-measurements` | gzip archive bytes, tar member bytes, tar member count | 2026-11-16 |
| Large-document layout throughput | minimum 250 pages/s, observed 31,019.1 pages/s | rdocx 0.14.0 | macOS 26.6.2, Apple M5 Max, arm64 | release, one test thread | 1,000 one-page paragraphs with deterministic fonts | `cargo test -p rdocx --test regression_test --release a_thousand_page_document_paginates_and_renders_within_the_declared_limits -- --ignored --exact --nocapture --test-threads=1` | pages per wall-clock second | 2026-09-19 |
| Large-document layout peak allocation | maximum 64 MiB, observed 29.03 MiB | rdocx 0.14.0 | macOS 26.6.2, Apple M5 Max, arm64 | release, one test thread | 1,000 one-page paragraphs with deterministic fonts | `cargo test -p rdocx --test regression_test --release a_thousand_page_document_paginates_and_renders_within_the_declared_limits -- --ignored --exact --nocapture --test-threads=1` | peak live allocation | 2026-09-19 |
| Large-document PDF throughput | minimum 1,000 pages/s, observed 60,058.0 pages/s | rdocx 0.14.0 | macOS 26.6.2, Apple M5 Max, arm64 | release, one test thread | 1,000 deterministic layout pages | `cargo test -p rdocx --test regression_test --release a_thousand_page_document_paginates_and_renders_within_the_declared_limits -- --ignored --exact --nocapture --test-threads=1` | pages per wall-clock second | 2026-09-19 |
Expand Down
2 changes: 1 addition & 1 deletion crates/rdocx-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The archive row uses `cargo package --locked --allow-dirty --no-verify` with all

| Measurement | Value | Version | Platform | Build mode | Input | Command | Statistic | Measured on |
|---|---|---|---|---|---|---|---|---|
| Crates.io archive: rdocx-cli | 126,182 compressed bytes, 593,817 member bytes, 8 members | 0.17.0 | macOS 26.6.2, Apple M5 Max, arm64 | `cargo package --locked --allow-dirty --no-verify` | Tracked `rdocx-cli` package inventory | `python3 scripts/readme_doctests.py --record-measurements` | gzip archive bytes, tar member bytes, tar member count | 2026-11-07 |
| Crates.io archive: rdocx-cli | 126,250 compressed bytes, 594,231 member bytes, 8 members | 0.17.0 | macOS 26.6.2, Apple M5 Max, arm64 | `cargo package --locked --allow-dirty --no-verify` | Tracked `rdocx-cli` package inventory | `python3 scripts/readme_doctests.py --record-measurements` | gzip archive bytes, tar member bytes, tar member count | 2026-11-16 |

## Use it when

Expand Down
2 changes: 1 addition & 1 deletion crates/rdocx-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ enum CommentCommand {
#[arg(long)]
json: bool,
},
/// Move an existing root comment onto literal main-story text
/// Move an existing root comment and its replies onto literal main-story text
Move {
/// Path to the DOCX file
file: PathBuf,
Expand Down
27 changes: 22 additions & 5 deletions crates/rdocx-cli/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5233,10 +5233,25 @@ fn comment_move_outputs_reopen_with_unchanged_thread() {
Some("2026-10-08T12:00:00Z"),
)
.unwrap();
document.reply_to(id, "Ben", "Reply").unwrap();
let reply = document.reply_to(id, "Ben", "Reply").unwrap();
document.resolve_comment(id, true).unwrap();
document.save(&input).unwrap();
let before = fs::read(&input).unwrap();
let refused = cli(&[
"comment",
"move",
path_text(&input),
&reply.to_string(),
"--text",
"TARGET",
"-o",
path_text(&output),
]);
assert!(
!refused.status.success(),
"a reply moves with its root only"
);
assert!(!output.exists());
let result = cli(&[
"comment",
"move",
Expand All @@ -5252,10 +5267,12 @@ fn comment_move_outputs_reopen_with_unchanged_thread() {
]);
assert_success(&result, "move root comment");
let reopened = Document::open(&output).unwrap();
assert_eq!(
reopened.comment_anchor_text(id).unwrap().as_deref(),
Some("TARGET")
);
for moved in [id, reply] {
assert_eq!(
reopened.comment_anchor_text(moved).unwrap().as_deref(),
Some("TARGET")
);
}
assert_eq!(reopened.comments().len(), 2);
assert_eq!(reopened.comments()[0].id(), id);
assert_eq!(reopened.comments()[0].resolved(), Some(true));
Expand Down
15 changes: 13 additions & 2 deletions crates/rdocx-py/python/rdocx/_rdocx.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1468,10 +1468,21 @@ class Document:
date: str | None = None,
) -> int: ...
def move_comment(self, id: int, range: StoryRunRange) -> None:
"""Move an existing root thread to a checked current story range."""
"""Move an existing root thread to a checked current story range.

Replies with their own range and reference move with the root and
cross its new range as ``reply_to`` writes them. Replies with no
marker at all follow through the thread. Any other reply anchor, such
as a reference without a range, refuses the move. A reply id is
refused: move its thread root. Moving a root onto its own range
brings back replies that a 0.17.0 move left behind.
"""
...
def move_comment_to_text(self, id: int, anchor: str, *, occurrence: int = 0) -> None:
"""Move an existing root thread onto a literal main-story occurrence."""
"""Move an existing root thread onto a literal main-story occurrence.

Replies move with the root, as in ``move_comment``.
"""
...
def reply_to(
self, parent_id: int, *, author: str, text: str, date: str | None = None, initials: str | None = None
Expand Down
6 changes: 4 additions & 2 deletions crates/rdocx-py/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16702,7 +16702,8 @@ impl PyDocument {
Ok(id)
}

/// Move a root comment to a checked current story range atomically.
/// Move a root comment and its replies to a checked current story range
/// atomically.
fn move_comment(
&mut self,
id: i32,
Expand Down Expand Up @@ -16731,7 +16732,8 @@ impl PyDocument {
Ok(())
}

/// Move a root comment onto the selected literal main-story occurrence.
/// Move a root comment and its replies onto the selected literal
/// main-story occurrence.
#[pyo3(signature = (id, anchor, *, occurrence = 0))]
fn move_comment_to_text(
&mut self,
Expand Down
25 changes: 25 additions & 0 deletions crates/rdocx-py/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5214,6 +5214,31 @@ def test_comment_moves_refuse_unknown_reply_and_invalid_ranges_atomically():
assert reopened.comments[0].anchor_text == "TARGET"


def test_issue446_moving_a_thread_carries_its_replies():
import rdocx

document = rdocx.Document()
document.add_paragraph("Keep the bearing positions here.")
document.add_paragraph("The bearing at pier 2 moved about 12 mm.")
root = document.add_comment_on_text("about 12 mm", author="R", text="Which reference?")
reply = document.reply_to(root, author="A", text="The 2019 survey marks.")
child = document.reply_to(reply, author="C", text="Which marks?")
document.move_comment_to_text(root, "bearing positions")
assert [(c.id, c.anchor_text) for c in document.comments] == [
(root, "bearing positions"),
(reply, "bearing positions"),
(child, "bearing positions"),
]
assert document.remove_content(document.find_content_index(document.paragraphs[1]))
assert [c.id for c in document.comments] == [root, reply, child]
before = document.to_bytes()
with pytest.raises(rdocx.RdocxError, match=f"thread root {root}"):
document.move_comment_to_text(reply, "bearing")
assert document.to_bytes() == before
reopened = rdocx.Document.from_bytes(before)
assert {c.anchor_text for c in reopened.comments} == {"bearing positions"}


def test_scoped_replacement_count_guards_are_atomic():
import pickle
import rdocx
Expand Down
29 changes: 29 additions & 0 deletions crates/rdocx-py/tests/test_formatting_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,35 @@ def test_cells_merge_through_the_checked_table_operations():
assert reopened.cell(1, -1).vertical_merge is None


def test_issue446_grid_span_and_merge_consume_the_same_cells():
from rdocx import WD_ALIGN_PARAGRAPH, Document, RdocxError

for operation in ("grid span", "merge"):
document = Document()
table = document.add_table(1, 3, style="Table Grid")
table.cell(0, 0).text = "Total"
table.cell(0, 1).paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT
if operation == "grid span":
document.tables[0].set_cell_grid_span(0, 0, 2)
else:
document.tables[0].cell(0, 0).merge(document.tables[0].cell(0, 1))
table = document.tables[0]
assert [cell.text for cell in table.rows[0].cells] == ["Total", ""], operation
assert [cell.grid_span for cell in table.rows[0].cells] == [2, 1], operation
assert len(table.cell(0, 0).paragraphs) == 1, operation

document = Document()
table = document.add_table(1, 2)
table.cell(0, 0).text = "Total"
table.cell(0, 1).text = "kept"
before = document.to_bytes()
with pytest.raises(RdocxError, match="nonempty cell"):
document.tables[0].set_cell_grid_span(0, 0, 2)
assert document.to_bytes() == before
document.tables[0].cell(0, 0).merge(document.tables[0].cell(0, 1))
assert [p.text for p in document.tables[0].cell(0, 0).paragraphs] == ["Total", "kept"]


def test_table_acceptance_workflow_writes_the_native_body():
# table_acceptance_workflow_writes_the_body_the_python_binding_pins in
# crates/rdocx/tests/integration_test.rs pins the same body for the native
Expand Down
Loading
Loading