@@ -129,7 +129,7 @@ impl WorktreeList {
129129 return ;
130130 }
131131 picker. delegate . create_worktree (
132- entry. worktree . name ( ) ,
132+ entry. worktree . branch ( ) ,
133133 replace_current_window,
134134 Some ( default_branch. into ( ) ) ,
135135 window,
@@ -211,7 +211,7 @@ impl WorktreeListDelegate {
211211
212212 fn create_worktree (
213213 & self ,
214- worktree_name : & str ,
214+ worktree_branch : & str ,
215215 replace_current_window : bool ,
216216 commit : Option < String > ,
217217 window : & mut Window ,
@@ -243,19 +243,19 @@ impl WorktreeListDelegate {
243243 return ;
244244 } ;
245245
246- let name = worktree_name . to_string ( ) ;
246+ let branch = worktree_branch . to_string ( ) ;
247247 cx. spawn_in ( window, async move |_, cx| {
248248 let Some ( paths) = worktree_path. await ? else {
249249 return anyhow:: Ok ( ( ) ) ;
250250 } ;
251251 let path = paths. get ( 0 ) . cloned ( ) . context ( "No path selected" ) ?;
252252
253253 repo. update ( cx, |repo, _| {
254- repo. create_worktree ( name . clone ( ) , path. clone ( ) , commit)
254+ repo. create_worktree ( branch . clone ( ) , path. clone ( ) , commit)
255255 } ) ?
256256 . await ??;
257257
258- let final_path = path. join ( name ) ;
258+ let final_path = path. join ( branch ) ;
259259 workspace
260260 . update_in ( cx, |workspace, window, cx| {
261261 workspace. open_workspace_for_paths (
@@ -297,6 +297,12 @@ impl WorktreeListDelegate {
297297
298298 cx. emit ( DismissEvent ) ;
299299 }
300+
301+ fn base_branch < ' a > ( & ' a self , cx : & ' a mut Context < Picker < Self > > ) -> Option < & ' a str > {
302+ self . repo
303+ . as_ref ( )
304+ . and_then ( |repo| repo. read ( cx) . branch . as_ref ( ) . map ( |b| b. name ( ) ) )
305+ }
300306}
301307
302308impl PickerDelegate for WorktreeListDelegate {
@@ -351,7 +357,7 @@ impl PickerDelegate for WorktreeListDelegate {
351357 let candidates = all_worktrees
352358 . iter ( )
353359 . enumerate ( )
354- . map ( |( ix, worktree) | StringMatchCandidate :: new ( ix, worktree. name ( ) ) )
360+ . map ( |( ix, worktree) | StringMatchCandidate :: new ( ix, worktree. branch ( ) ) )
355361 . collect :: < Vec < StringMatchCandidate > > ( ) ;
356362 fuzzy:: match_strings (
357363 & candidates,
@@ -376,7 +382,7 @@ impl PickerDelegate for WorktreeListDelegate {
376382 if !query. is_empty ( )
377383 && !matches
378384 . first ( )
379- . is_some_and ( |entry| entry. worktree . name ( ) == query)
385+ . is_some_and ( |entry| entry. worktree . branch ( ) == query)
380386 {
381387 let query = query. replace ( ' ' , "-" ) ;
382388 matches. push ( WorktreeEntry {
@@ -408,7 +414,7 @@ impl PickerDelegate for WorktreeListDelegate {
408414 return ;
409415 } ;
410416 if entry. is_new {
411- self . create_worktree ( & entry. worktree . name ( ) , secondary, None , window, cx) ;
417+ self . create_worktree ( & entry. worktree . branch ( ) , secondary, None , window, cx) ;
412418 } else {
413419 self . open_worktree ( & entry. worktree . path , secondary, window, cx) ;
414420 }
@@ -449,12 +455,11 @@ impl PickerDelegate for WorktreeListDelegate {
449455 . on_right_click ( |_, window, cx| {
450456 window. dispatch_action ( WorktreeFromDefaultOnWindow . boxed_clone ( ) , cx)
451457 } )
452- . tooltip ( move |window , cx| {
458+ . tooltip ( move |_ , cx| {
453459 Tooltip :: for_action_in (
454460 format ! ( "From default branch {default_branch}" ) ,
455461 & WorktreeFromDefault ,
456462 & focus_handle,
457- window,
458463 cx,
459464 )
460465 } ) ,
@@ -463,7 +468,7 @@ impl PickerDelegate for WorktreeListDelegate {
463468 None
464469 } ;
465470
466- let worktree_name = if entry. is_new {
471+ let branch_name = if entry. is_new {
467472 h_flex ( )
468473 . gap_1 ( )
469474 . child (
@@ -472,26 +477,41 @@ impl PickerDelegate for WorktreeListDelegate {
472477 . color ( Color :: Muted ) ,
473478 )
474479 . child (
475- Label :: new ( format ! ( "Create worktree \" {}\" …" , entry. worktree. name ( ) ) )
480+ Label :: new ( format ! ( "Create worktree \" {}\" …" , entry. worktree. branch ( ) ) )
476481 . single_line ( )
477482 . truncate ( ) ,
478483 )
479484 . into_any_element ( )
480485 } else {
481- HighlightedLabel :: new ( entry. worktree . name ( ) . to_owned ( ) , entry. positions . clone ( ) )
486+ h_flex ( )
487+ . gap_1 ( )
488+ . child (
489+ Icon :: new ( IconName :: GitBranch )
490+ . size ( IconSize :: Small )
491+ . color ( Color :: Muted ) ,
492+ )
493+ . child ( HighlightedLabel :: new (
494+ entry. worktree . branch ( ) . to_owned ( ) ,
495+ entry. positions . clone ( ) ,
496+ ) )
482497 . truncate ( )
483498 . into_any_element ( )
484499 } ;
485500
501+ let sublabel = if entry. is_new {
502+ format ! (
503+ "based off {}" ,
504+ self . base_branch( cx) . unwrap_or( "the current branch" )
505+ )
506+ } else {
507+ format ! ( "at {}" , path)
508+ } ;
509+
486510 Some (
487511 ListItem :: new ( SharedString :: from ( format ! ( "worktree-menu-{ix}" ) ) )
488512 . inset ( true )
489513 . spacing ( ListItemSpacing :: Sparse )
490514 . toggle_state ( selected)
491- . tooltip ( {
492- let worktree_name = entry. worktree . name ( ) . to_string ( ) ;
493- Tooltip :: text ( worktree_name)
494- } )
495515 . child (
496516 v_flex ( )
497517 . w_full ( )
@@ -501,7 +521,7 @@ impl PickerDelegate for WorktreeListDelegate {
501521 . gap_6 ( )
502522 . justify_between ( )
503523 . overflow_x_hidden ( )
504- . child ( worktree_name )
524+ . child ( branch_name )
505525 . when ( !entry. is_new , |el| {
506526 el. child (
507527 Label :: new ( sha)
@@ -511,25 +531,15 @@ impl PickerDelegate for WorktreeListDelegate {
511531 )
512532 } ) ,
513533 )
514- . child ( {
515- let message = if entry. is_new {
516- if let Some ( current_branch) = self . repo . as_ref ( ) . and_then ( |repo| {
517- repo. read ( cx) . branch . as_ref ( ) . map ( |b| b. name ( ) )
518- } ) {
519- format ! ( "based off {}" , current_branch)
520- } else {
521- "based off the current branch" . to_string ( )
522- }
523- } else {
524- path
525- } ;
526- div ( ) . max_w_96 ( ) . child ( {
527- Label :: new ( message)
534+ . child (
535+ div ( ) . max_w_96 ( ) . child (
536+ Label :: new ( sublabel)
528537 . size ( LabelSize :: Small )
529- . truncate ( )
530538 . color ( Color :: Muted )
531- } )
532- } ) ,
539+ . truncate ( )
540+ . into_any_element ( ) ,
541+ ) ,
542+ ) ,
533543 )
534544 . end_slot :: < IconButton > ( icon) ,
535545 )
@@ -539,11 +549,7 @@ impl PickerDelegate for WorktreeListDelegate {
539549 Some ( "No worktrees found" . into ( ) )
540550 }
541551
542- fn render_footer (
543- & self ,
544- _window : & mut Window ,
545- cx : & mut Context < Picker < Self > > ,
546- ) -> Option < AnyElement > {
552+ fn render_footer ( & self , _: & mut Window , cx : & mut Context < Picker < Self > > ) -> Option < AnyElement > {
547553 let focus_handle = self . focus_handle . clone ( ) ;
548554
549555 Some (
@@ -555,32 +561,24 @@ impl PickerDelegate for WorktreeListDelegate {
555561 . border_t_1 ( )
556562 . border_color ( cx. theme ( ) . colors ( ) . border_variant )
557563 . child (
558- h_flex ( )
559- . gap_0p5 ( )
560- . child (
561- Button :: new ( "open-in-new-window" , "Open in new window" )
562- . key_binding (
563- KeyBinding :: for_action_in ( & menu:: Confirm , & focus_handle, cx)
564- . map ( |kb| kb. size ( rems_from_px ( 12. ) ) ) ,
565- )
566- . on_click ( |_, window, cx| {
567- window. dispatch_action ( menu:: Confirm . boxed_clone ( ) , cx)
568- } ) ,
564+ Button :: new ( "open-in-new-window" , "Open in new window" )
565+ . key_binding (
566+ KeyBinding :: for_action_in ( & menu:: Confirm , & focus_handle, cx)
567+ . map ( |kb| kb. size ( rems_from_px ( 12. ) ) ) ,
569568 )
570- . child (
571- Button :: new ( "open-in-window" , "Open" )
572- . key_binding (
573- KeyBinding :: for_action_in (
574- & menu:: SecondaryConfirm ,
575- & focus_handle,
576- cx,
577- )
578- . map ( |kb| kb. size ( rems_from_px ( 12. ) ) ) ,
579- )
580- . on_click ( |_, window, cx| {
581- window. dispatch_action ( menu:: SecondaryConfirm . boxed_clone ( ) , cx)
582- } ) ,
583- ) ,
569+ . on_click ( |_, window, cx| {
570+ window. dispatch_action ( menu:: Confirm . boxed_clone ( ) , cx)
571+ } ) ,
572+ )
573+ . child (
574+ Button :: new ( "open-in-window" , "Open" )
575+ . key_binding (
576+ KeyBinding :: for_action_in ( & menu:: SecondaryConfirm , & focus_handle, cx)
577+ . map ( |kb| kb. size ( rems_from_px ( 12. ) ) ) ,
578+ )
579+ . on_click ( |_, window, cx| {
580+ window. dispatch_action ( menu:: SecondaryConfirm . boxed_clone ( ) , cx)
581+ } ) ,
584582 )
585583 . into_any ( ) ,
586584 )
0 commit comments