From b2c3dd16713019cd79c2dbd81d2d1e996f8e4ee4 Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Tue, 12 May 2026 02:58:57 +0800 Subject: [PATCH] docs(shell-core): correct selected_node anchor doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stale comment claimed parity with TS `selectedIds[0]`, but the Rust port anchors on the LAST entry of `selected_set` (most- recently-added / most-recently-surviving id — see `toggle_selection`). Rewrote the doc to describe the actual Rust invariant and call out the TS divergence. --- crates/openpencil-shell-core/src/document/mutators.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/openpencil-shell-core/src/document/mutators.rs b/crates/openpencil-shell-core/src/document/mutators.rs index 42d43a1bb..f7f559525 100644 --- a/crates/openpencil-shell-core/src/document/mutators.rs +++ b/crates/openpencil-shell-core/src/document/mutators.rs @@ -133,9 +133,11 @@ impl Document { Some(new_index) } - /// Get the anchor-selected node (TS `selectedIds[0]`). ONLY - /// searches the active page (codex Step 2 R1 CONCERN-1). A - /// selection on a non-active page returns `None`. + /// Get the anchor-selected node. The anchor is the LAST entry + /// in `selected_set` (Rust convention — most-recently-added / + /// most-recently-surviving id; differs from TS's `selectedIds[0]`). + /// ONLY searches the active page; a selection on a non-active + /// page returns `None`. pub fn selected_node(&self) -> Option<&Node> { if !self.selected.is_real() { return None;