@@ -9,7 +9,7 @@ use crate::{
9
9
SplitDirection , ToggleZoom , Workspace ,
10
10
} ;
11
11
use anyhow:: Result ;
12
- use collections:: { HashMap , HashSet , VecDeque } ;
12
+ use collections:: { BTreeSet , HashMap , HashSet , VecDeque } ;
13
13
use futures:: { stream:: FuturesUnordered , StreamExt } ;
14
14
use gpui:: {
15
15
actions, anchored, deferred, impl_actions, prelude:: * , Action , AnchorCorner , AnyElement ,
@@ -20,7 +20,7 @@ use gpui::{
20
20
} ;
21
21
use itertools:: Itertools ;
22
22
use parking_lot:: Mutex ;
23
- use project:: { Project , ProjectEntryId , ProjectPath } ;
23
+ use project:: { Project , ProjectEntryId , ProjectPath , WorktreeId } ;
24
24
use serde:: Deserialize ;
25
25
use settings:: { Settings , SettingsStore } ;
26
26
use std:: {
@@ -43,6 +43,30 @@ use ui::{
43
43
use ui:: { v_flex, ContextMenu } ;
44
44
use util:: { debug_panic, maybe, truncate_and_remove_front, ResultExt } ;
45
45
46
+ /// A selected entry in e.g. project panel.
47
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord ) ]
48
+ pub struct SelectedEntry {
49
+ pub worktree_id : WorktreeId ,
50
+ pub entry_id : ProjectEntryId ,
51
+ }
52
+
53
+ /// A group of selected entries from project panel.
54
+ #[ derive( Debug ) ]
55
+ pub struct DraggedSelection {
56
+ pub active_selection : SelectedEntry ,
57
+ pub marked_selections : Arc < BTreeSet < SelectedEntry > > ,
58
+ }
59
+
60
+ impl DraggedSelection {
61
+ pub fn items < ' a > ( & ' a self ) -> Box < dyn Iterator < Item = & ' a SelectedEntry > + ' a > {
62
+ if self . marked_selections . contains ( & self . active_selection ) {
63
+ Box :: new ( self . marked_selections . iter ( ) )
64
+ } else {
65
+ Box :: new ( std:: iter:: once ( & self . active_selection ) )
66
+ }
67
+ }
68
+ }
69
+
46
70
#[ derive( PartialEq , Clone , Copy , Deserialize , Debug ) ]
47
71
#[ serde( rename_all = "camelCase" ) ]
48
72
pub enum SaveIntent {
@@ -1602,7 +1626,7 @@ impl Pane {
1602
1626
. drag_over :: < DraggedTab > ( |tab, _, cx| {
1603
1627
tab. bg ( cx. theme ( ) . colors ( ) . drop_target_background )
1604
1628
} )
1605
- . drag_over :: < ProjectEntryId > ( |tab, _, cx| {
1629
+ . drag_over :: < DraggedSelection > ( |tab, _, cx| {
1606
1630
tab. bg ( cx. theme ( ) . colors ( ) . drop_target_background )
1607
1631
} )
1608
1632
. when_some ( self . can_drop_predicate . clone ( ) , |this, p| {
@@ -1612,9 +1636,9 @@ impl Pane {
1612
1636
this. drag_split_direction = None ;
1613
1637
this. handle_tab_drop ( dragged_tab, ix, cx)
1614
1638
} ) )
1615
- . on_drop ( cx. listener ( move |this, entry_id : & ProjectEntryId , cx| {
1639
+ . on_drop ( cx. listener ( move |this, selection : & DraggedSelection , cx| {
1616
1640
this. drag_split_direction = None ;
1617
- this. handle_project_entry_drop ( entry_id, cx)
1641
+ this. handle_project_entry_drop ( & selection . active_selection . entry_id , cx)
1618
1642
} ) )
1619
1643
. on_drop ( cx. listener ( move |this, paths, cx| {
1620
1644
this. drag_split_direction = None ;
@@ -1820,16 +1844,16 @@ impl Pane {
1820
1844
. drag_over :: < DraggedTab > ( |bar, _, cx| {
1821
1845
bar. bg ( cx. theme ( ) . colors ( ) . drop_target_background )
1822
1846
} )
1823
- . drag_over :: < ProjectEntryId > ( |bar, _, cx| {
1847
+ . drag_over :: < DraggedSelection > ( |bar, _, cx| {
1824
1848
bar. bg ( cx. theme ( ) . colors ( ) . drop_target_background )
1825
1849
} )
1826
1850
. on_drop ( cx. listener ( move |this, dragged_tab : & DraggedTab , cx| {
1827
1851
this. drag_split_direction = None ;
1828
1852
this. handle_tab_drop ( dragged_tab, this. items . len ( ) , cx)
1829
1853
} ) )
1830
- . on_drop ( cx. listener ( move |this, entry_id : & ProjectEntryId , cx| {
1854
+ . on_drop ( cx. listener ( move |this, selection : & DraggedSelection , cx| {
1831
1855
this. drag_split_direction = None ;
1832
- this. handle_project_entry_drop ( entry_id, cx)
1856
+ this. handle_project_entry_drop ( & selection . active_selection . entry_id , cx)
1833
1857
} ) )
1834
1858
. on_drop ( cx. listener ( move |this, paths, cx| {
1835
1859
this. drag_split_direction = None ;
@@ -2179,7 +2203,7 @@ impl Render for Pane {
2179
2203
. relative ( )
2180
2204
. group ( "" )
2181
2205
. on_drag_move :: < DraggedTab > ( cx. listener ( Self :: handle_drag_move) )
2182
- . on_drag_move :: < ProjectEntryId > ( cx. listener ( Self :: handle_drag_move) )
2206
+ . on_drag_move :: < DraggedSelection > ( cx. listener ( Self :: handle_drag_move) )
2183
2207
. on_drag_move :: < ExternalPaths > ( cx. listener ( Self :: handle_drag_move) )
2184
2208
. map ( |div| {
2185
2209
if let Some ( item) = self . active_item ( ) {
@@ -2205,16 +2229,19 @@ impl Render for Pane {
2205
2229
. absolute ( )
2206
2230
. bg ( cx. theme ( ) . colors ( ) . drop_target_background )
2207
2231
. group_drag_over :: < DraggedTab > ( "" , |style| style. visible ( ) )
2208
- . group_drag_over :: < ProjectEntryId > ( "" , |style| style. visible ( ) )
2232
+ . group_drag_over :: < DraggedSelection > ( "" , |style| style. visible ( ) )
2209
2233
. group_drag_over :: < ExternalPaths > ( "" , |style| style. visible ( ) )
2210
2234
. when_some ( self . can_drop_predicate . clone ( ) , |this, p| {
2211
2235
this. can_drop ( move |a, cx| p ( a, cx) )
2212
2236
} )
2213
2237
. on_drop ( cx. listener ( move |this, dragged_tab, cx| {
2214
2238
this. handle_tab_drop ( dragged_tab, this. active_item_index ( ) , cx)
2215
2239
} ) )
2216
- . on_drop ( cx. listener ( move |this, entry_id, cx| {
2217
- this. handle_project_entry_drop ( entry_id, cx)
2240
+ . on_drop ( cx. listener ( move |this, selection : & DraggedSelection , cx| {
2241
+ this. handle_project_entry_drop (
2242
+ & selection. active_selection . entry_id ,
2243
+ cx,
2244
+ )
2218
2245
} ) )
2219
2246
. on_drop ( cx. listener ( move |this, paths, cx| {
2220
2247
this. handle_external_paths_drop ( paths, cx)
0 commit comments