diff --git a/crates/doc/src/tests/lookups.rs b/crates/doc/src/tests/lookups.rs index 819ce373d0..1bc90a68b0 100644 --- a/crates/doc/src/tests/lookups.rs +++ b/crates/doc/src/tests/lookups.rs @@ -610,7 +610,8 @@ fn node_lookups_copy_no_index_path() { } /// Copies of one document that each add the same object, as the previews of a drag do from the document at the press, -/// find that object where a walk finds it. The first copy walks the tree once for it and the later copies do not walk. +/// find that object where a walk finds it. The first copy walks the tree once for it and the later copies do not walk, +/// and [`Document::node`] finds it without copying an index path. /// A copy that adds the object elsewhere, adds an object below it, groups it or deletes it, and the document they /// were copied from, still find what a walk finds. A copy that adds it twice finds one node with its id, and /// [`Document::nodes_in_order`] finds both. @@ -623,15 +624,19 @@ fn copies_that_add_an_object_find_it_without_walking_again() { base.drop_lookup_cache(); base.node(layer); let walks = tree_walks(); + let mut node_copies = 0; for copy in 0..20 { let mut d = base.clone(); d.insert(Some(layer), usize::MAX, new()).unwrap(); + let copies = path_copies(); assert!(d.node(added).is_some_and(|n| n.id == added), "copy {copy}"); + node_copies += path_copies() - copies; assert_eq!(d.index_path(added), Some(vec![0, ids.len()]), "copy {copy}"); assert_eq!(d.index_paths([added, ids[5]]).get(&added), Some(&vec![0, ids.len()]), "copy {copy}"); assert_eq!(d.ancestry(added), Some(vec![layer, added]), "copy {copy}"); } assert_eq!(tree_walks() - walks, 1, "walks of the tree for 20 copies"); + assert_eq!(node_copies, 0, "index paths copied by node for 20 copies"); // A copy that adds the object twice: lookups give one node with its id, and nodes_in_order, // which reads only the table's paths, gives both.