@@ -4135,21 +4135,27 @@ impl Workspace {
41354135 direction : SplitDirection ,
41364136 window : & mut Window ,
41374137 cx : & mut Context < Self > ,
4138- ) -> Option < Entity < Pane > > {
4139- let item = pane. read ( cx) . active_item ( ) ?;
4140- let maybe_pane_handle =
4141- if let Some ( clone) = item. clone_on_split ( self . database_id ( ) , window, cx) {
4142- let new_pane = self . add_pane ( window, cx) ;
4143- new_pane. update ( cx, |pane, cx| {
4144- pane. add_item ( clone, true , true , None , window, cx)
4145- } ) ;
4146- self . center . split ( & pane, & new_pane, direction) . unwrap ( ) ;
4147- cx. notify ( ) ;
4148- Some ( new_pane)
4138+ ) -> Task < Option < Entity < Pane > > > {
4139+ let Some ( item) = pane. read ( cx) . active_item ( ) else {
4140+ return Task :: ready ( None ) ;
4141+ } ;
4142+ let task = item. clone_on_split ( self . database_id ( ) , window, cx) ;
4143+ cx. spawn_in ( window, async move |this, cx| {
4144+ if let Some ( clone) = task. await {
4145+ this. update_in ( cx, |this, window, cx| {
4146+ let new_pane = this. add_pane ( window, cx) ;
4147+ new_pane. update ( cx, |pane, cx| {
4148+ pane. add_item ( clone, true , true , None , window, cx)
4149+ } ) ;
4150+ this. center . split ( & pane, & new_pane, direction) . unwrap ( ) ;
4151+ cx. notify ( ) ;
4152+ new_pane
4153+ } )
4154+ . ok ( )
41494155 } else {
41504156 None
4151- } ;
4152- maybe_pane_handle
4157+ }
4158+ } )
41534159 }
41544160
41554161 pub fn join_all_panes ( & mut self , window : & mut Window , cx : & mut Context < Self > ) {
@@ -8170,19 +8176,27 @@ pub fn clone_active_item(
81708176 let Some ( active_item) = source. read ( cx) . active_item ( ) else {
81718177 return ;
81728178 } ;
8173- destination. update ( cx, |target_pane, cx| {
8174- let Some ( clone) = active_item. clone_on_split ( workspace_id, window, cx) else {
8175- return ;
8176- } ;
8177- target_pane. add_item (
8178- clone,
8179- focus_destination,
8180- focus_destination,
8181- Some ( target_pane. items_len ( ) ) ,
8182- window,
8183- cx,
8184- ) ;
8185- } ) ;
8179+ let destination = destination. downgrade ( ) ;
8180+ let task = active_item. clone_on_split ( workspace_id, window, cx) ;
8181+ window
8182+ . spawn ( cx, async move |cx| {
8183+ let Some ( clone) = task. await else {
8184+ return ;
8185+ } ;
8186+ destination
8187+ . update_in ( cx, |target_pane, window, cx| {
8188+ target_pane. add_item (
8189+ clone,
8190+ focus_destination,
8191+ focus_destination,
8192+ Some ( target_pane. items_len ( ) ) ,
8193+ window,
8194+ cx,
8195+ ) ;
8196+ } )
8197+ . log_err ( ) ;
8198+ } )
8199+ . detach ( ) ;
81868200}
81878201
81888202#[ derive( Debug ) ]
@@ -8689,25 +8703,25 @@ mod tests {
86898703 cx,
86908704 ) ;
86918705
8692- let right_pane = workspace
8693- . split_and_clone ( left_pane. clone ( ) , SplitDirection :: Right , window, cx)
8694- . unwrap ( ) ;
8706+ let right_pane =
8707+ workspace. split_and_clone ( left_pane. clone ( ) , SplitDirection :: Right , window, cx) ;
86958708
8696- right_pane. update ( cx, |pane, cx| {
8697- pane. add_item (
8698- single_entry_items[ 1 ] . boxed_clone ( ) ,
8699- true ,
8700- true ,
8701- None ,
8702- window,
8703- cx,
8704- ) ;
8705- pane. add_item ( Box :: new ( item_3_4. clone ( ) ) , true , true , None , window, cx) ;
8709+ let boxed_clone = single_entry_items[ 1 ] . boxed_clone ( ) ;
8710+ let right_pane = window. spawn ( cx, async move |cx| {
8711+ right_pane. await . map ( |right_pane| {
8712+ right_pane
8713+ . update_in ( cx, |pane, window, cx| {
8714+ pane. add_item ( boxed_clone, true , true , None , window, cx) ;
8715+ pane. add_item ( Box :: new ( item_3_4. clone ( ) ) , true , true , None , window, cx) ;
8716+ } )
8717+ . unwrap ( ) ;
8718+ right_pane
8719+ } )
87068720 } ) ;
87078721
87088722 ( left_pane, right_pane)
87098723 } ) ;
8710-
8724+ let right_pane = right_pane . await . unwrap ( ) ;
87118725 cx. focus ( & right_pane) ;
87128726
87138727 let mut close = right_pane. update_in ( cx, |pane, window, cx| {
0 commit comments