workspace tree refactor#16
Merged
Merged
Conversation
hlcfan
commented
Jun 22, 2026
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.