@@ -9,7 +9,7 @@ use crate::{
99    SplitDirection ,  ToggleZoom ,  Workspace , 
1010} ; 
1111use  anyhow:: Result ; 
12- use  collections:: { HashMap ,  HashSet ,  VecDeque } ; 
12+ use  collections:: { BTreeSet ,   HashMap ,  HashSet ,  VecDeque } ; 
1313use  futures:: { stream:: FuturesUnordered ,  StreamExt } ; 
1414use  gpui:: { 
1515    actions,  anchored,  deferred,  impl_actions,  prelude:: * ,  Action ,  AnchorCorner ,  AnyElement , 
@@ -20,7 +20,7 @@ use gpui::{
2020} ; 
2121use  itertools:: Itertools ; 
2222use  parking_lot:: Mutex ; 
23- use  project:: { Project ,  ProjectEntryId ,  ProjectPath } ; 
23+ use  project:: { Project ,  ProjectEntryId ,  ProjectPath ,   WorktreeId } ; 
2424use  serde:: Deserialize ; 
2525use  settings:: { Settings ,  SettingsStore } ; 
2626use  std:: { 
@@ -43,6 +43,30 @@ use ui::{
4343use  ui:: { v_flex,  ContextMenu } ; 
4444use  util:: { debug_panic,  maybe,  truncate_and_remove_front,  ResultExt } ; 
4545
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+ 
4670#[ derive( PartialEq ,  Clone ,  Copy ,  Deserialize ,  Debug ) ]  
4771#[ serde( rename_all = "camelCase" ) ]  
4872pub  enum  SaveIntent  { 
@@ -1602,7 +1626,7 @@ impl Pane {
16021626            . drag_over :: < DraggedTab > ( |tab,  _,  cx| { 
16031627                tab. bg ( cx. theme ( ) . colors ( ) . drop_target_background ) 
16041628            } ) 
1605-             . drag_over :: < ProjectEntryId > ( |tab,  _,  cx| { 
1629+             . drag_over :: < DraggedSelection > ( |tab,  _,  cx| { 
16061630                tab. bg ( cx. theme ( ) . colors ( ) . drop_target_background ) 
16071631            } ) 
16081632            . when_some ( self . can_drop_predicate . clone ( ) ,  |this,  p| { 
@@ -1612,9 +1636,9 @@ impl Pane {
16121636                this. drag_split_direction  = None ; 
16131637                this. handle_tab_drop ( dragged_tab,  ix,  cx) 
16141638            } ) ) 
1615-             . on_drop ( cx. listener ( move  |this,  entry_id :  & ProjectEntryId ,  cx| { 
1639+             . on_drop ( cx. listener ( move  |this,  selection :  & DraggedSelection ,  cx| { 
16161640                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) 
16181642            } ) ) 
16191643            . on_drop ( cx. listener ( move  |this,  paths,  cx| { 
16201644                this. drag_split_direction  = None ; 
@@ -1820,16 +1844,16 @@ impl Pane {
18201844                    . drag_over :: < DraggedTab > ( |bar,  _,  cx| { 
18211845                        bar. bg ( cx. theme ( ) . colors ( ) . drop_target_background ) 
18221846                    } ) 
1823-                     . drag_over :: < ProjectEntryId > ( |bar,  _,  cx| { 
1847+                     . drag_over :: < DraggedSelection > ( |bar,  _,  cx| { 
18241848                        bar. bg ( cx. theme ( ) . colors ( ) . drop_target_background ) 
18251849                    } ) 
18261850                    . on_drop ( cx. listener ( move  |this,  dragged_tab :  & DraggedTab ,  cx| { 
18271851                        this. drag_split_direction  = None ; 
18281852                        this. handle_tab_drop ( dragged_tab,  this. items . len ( ) ,  cx) 
18291853                    } ) ) 
1830-                     . on_drop ( cx. listener ( move  |this,  entry_id :  & ProjectEntryId ,  cx| { 
1854+                     . on_drop ( cx. listener ( move  |this,  selection :  & DraggedSelection ,  cx| { 
18311855                        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) 
18331857                    } ) ) 
18341858                    . on_drop ( cx. listener ( move  |this,  paths,  cx| { 
18351859                        this. drag_split_direction  = None ; 
@@ -2179,7 +2203,7 @@ impl Render for Pane {
21792203                    . relative ( ) 
21802204                    . group ( "" ) 
21812205                    . 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) ) 
21832207                    . on_drag_move :: < ExternalPaths > ( cx. listener ( Self :: handle_drag_move) ) 
21842208                    . map ( |div| { 
21852209                        if  let  Some ( item)  = self . active_item ( )  { 
@@ -2205,16 +2229,19 @@ impl Render for Pane {
22052229                            . absolute ( ) 
22062230                            . bg ( cx. theme ( ) . colors ( ) . drop_target_background ) 
22072231                            . group_drag_over :: < DraggedTab > ( "" ,  |style| style. visible ( ) ) 
2208-                             . group_drag_over :: < ProjectEntryId > ( "" ,  |style| style. visible ( ) ) 
2232+                             . group_drag_over :: < DraggedSelection > ( "" ,  |style| style. visible ( ) ) 
22092233                            . group_drag_over :: < ExternalPaths > ( "" ,  |style| style. visible ( ) ) 
22102234                            . when_some ( self . can_drop_predicate . clone ( ) ,  |this,  p| { 
22112235                                this. can_drop ( move  |a,  cx| p ( a,  cx) ) 
22122236                            } ) 
22132237                            . on_drop ( cx. listener ( move  |this,  dragged_tab,  cx| { 
22142238                                this. handle_tab_drop ( dragged_tab,  this. active_item_index ( ) ,  cx) 
22152239                            } ) ) 
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+                                 ) 
22182245                            } ) ) 
22192246                            . on_drop ( cx. listener ( move  |this,  paths,  cx| { 
22202247                                this. handle_external_paths_drop ( paths,  cx) 
0 commit comments