Skip to content

workspace tree refactor#16

Merged
hlcfan merged 10 commits into
mainfrom
workspace-tree-refactor
Jun 22, 2026
Merged

workspace tree refactor#16
hlcfan merged 10 commits into
mainfrom
workspace-tree-refactor

Conversation

@hlcfan

@hlcfan hlcfan commented Jun 22, 2026

Copy link
Copy Markdown
Owner
  • Render workspace tree with slots
  • Render slot with margin
  • Reduce the height of the slot bar
  • Make slot hit area sensitive with proximity detection
  • Render tree using v_virtual_list
  • Show ellipsis if row name is too long
  • Show tooltip for tree row

hlcfan added 10 commits June 21, 2026 22:15
The drop slot bar is 2px tall, which makes it hard to land a dragged
item precisely. Previous attempt grew the slot's layout box to 12px
during drag, but that shifted the tree down and made the visible bar
grow too.

This change keeps the slot layout box at 2px (no tree shift) and
instead expands the effective hit zone via proximity detection:

- Add SLOT_DRAG_PROXIMITY_PX (4px) constant in tree_dnd.rs. Each
  slot's on_drag_move handler checks if the cursor is within this
  threshold above or below the 2px bar, giving a 10px effective hit
  zone (4 + 2 + 4) with zero layout change.

- Add tree_drag_slot_hover: Option<TreeDropSlot> view state. Slots
  set it via set_tree_drag_slot_hover when the cursor is in
  proximity; only the previously-active slot clears itself so
  multiple slots don't clobber each other.

- Move can_drop/on_drop from individual slots and row bodies to the
  scroll container (and empty-tree container). On drop, resolve
  tree_drag_slot_hover first (slot insert), then tree_drag_hover
  (folder-body Into). This avoids gpui's per-element z-ordering
  where later-painted rows would win drops over earlier-painted
  slots.

- Split hover clearing: clear_tree_drag_slot_hover and
  clear_tree_drag_row_hover clear independently; clear_tree_drag_hover
  clears both on drop. Row body highlight is gated by
  drag_slot_hover.is_none() so the slot visually wins in overlap
  zones.

- Remove drag_over from slots and row bodies; the 2px visible bar is
  highlighted via state (is_active_slot) instead. Remove the now-unused
  can_accept_tree_row_body_drop helper.

Build, 108 tests, fmt, and clippy all clean.
The previous commit removed can_drop/drag_over from row bodies to
centralize drop handling on the scroll container. That also removed
the folder's drag-over highlight (selection bg), making folders feel
like non-drop-targets during a drag.

Add can_drop + drag_over back to the folder row body. The can_drop
predicate returns false when tree_drag_slot_hover.is_some(), so when
a slot is active (cursor near a slot bar) the folder's drag-over is
suppressed and the slot bar highlight takes priority. on_drop stays
on the scroll container; the row body only needs the visual feedback.
Drop slots compute insertion_index against the destination's sibling
list before the move, but the move helpers remove the dragged item
first then insert at insertion_index. When the dragged item sits below
the insertion point in the same container, removal shifts the target
down by one, so the raw slot index landed one position too far.

Add adjust_insertion_index_for_same_container_move and apply it in
request_move_action_for_destination and folder_move_action_for_destination.
@hlcfan hlcfan merged commit 190bded into main Jun 22, 2026
1 check passed
@hlcfan hlcfan deleted the workspace-tree-refactor branch June 22, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant