docs(shell-core): correct selected_node anchor doc

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.
This commit is contained in:
Kayshen-X 2026-05-12 02:58:57 +08:00
parent c62709584d
commit b2c3dd1671

View file

@ -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;