Skip to main content

move_stack_member

Function move_stack_member 

Source
pub fn move_stack_member(
    tree: &mut LayoutNode,
    block_id: &str,
    target_block_id: &str,
    position: StackMovePosition,
    activate: bool,
) -> bool
Expand description

Move block_id to position relative to target_block_id: a same-leaf reorder when both are already members of one leaf’s stack, otherwise a cross-leaf move (removed from its source leaf via remove_stack_member, placed into target_block_id’s leaf via a position-aware push). Returns false, leaving the tree untouched, when either block doesn’t exist in the tree.

When block_id is its source leaf’s ONLY member, the cross-leaf move empties that pane, so the source leaf is deleted from the tree (with the usual single-child-parent collapse, see delete_node). This is a move: the block itself lives on in the destination. source_leaf_emptied_by_move tells a caller in advance whether this will happen, so it can reconcile focus/magnify that pointed at that leaf. SPEC_PANE_TAB_DRAG_LANDING_FLASH_AND_LAST_TAB_CLOSE_2026_09_24.md §4.3.

Deliberately NOT a same-leaf-and-cross-leaf-both composition of remove_stack_member + a push: remove_stack_member’s neighbour reassignment assumes the member is actually leaving its leaf, and wrongly switches the visible tab if applied to a same-leaf reorder of the currently-visible member (see move_stack_member_reorder_does_not_change_which_tab_is_visible in tests.rs). The same-leaf branch below never touches block_id/active_block_id unless activate is explicitly set.

SPEC_PANE_TAB_DRAG_AND_DROP_2026_09_19.md §4.1.