@@ -811,7 +811,7 @@ impl OutlinePanel {
811811 if self . filter_editor . focus_handle ( cx) . is_focused ( cx) {
812812 cx. propagate ( )
813813 } else if let Some ( selected_entry) = self . selected_entry ( ) . cloned ( ) {
814- self . open_entry ( & selected_entry, true , cx) ;
814+ self . open_entry ( & selected_entry, true , false , cx) ;
815815 }
816816 }
817817
@@ -834,7 +834,7 @@ impl OutlinePanel {
834834 } else if let Some ( ( active_editor, selected_entry) ) =
835835 self . active_editor ( ) . zip ( self . selected_entry ( ) . cloned ( ) )
836836 {
837- self . open_entry ( & selected_entry, true , cx) ;
837+ self . open_entry ( & selected_entry, true , true , cx) ;
838838 active_editor. update ( cx, |editor, cx| editor. open_excerpts ( action, cx) ) ;
839839 }
840840 }
@@ -849,7 +849,7 @@ impl OutlinePanel {
849849 } else if let Some ( ( active_editor, selected_entry) ) =
850850 self . active_editor ( ) . zip ( self . selected_entry ( ) . cloned ( ) )
851851 {
852- self . open_entry ( & selected_entry, true , cx) ;
852+ self . open_entry ( & selected_entry, true , true , cx) ;
853853 active_editor. update ( cx, |editor, cx| editor. open_excerpts_in_split ( action, cx) ) ;
854854 }
855855 }
@@ -858,6 +858,7 @@ impl OutlinePanel {
858858 & mut self ,
859859 entry : & PanelEntry ,
860860 change_selection : bool ,
861+ change_focus : bool ,
861862 cx : & mut ViewContext < OutlinePanel > ,
862863 ) {
863864 let Some ( active_editor) = self . active_editor ( ) else {
@@ -929,26 +930,30 @@ impl OutlinePanel {
929930 . workspace
930931 . update ( cx, |workspace, cx| match self . active_item ( ) {
931932 Some ( active_item) => {
932- workspace. activate_item ( active_item. as_ref ( ) , true , change_selection , cx)
933+ workspace. activate_item ( active_item. as_ref ( ) , true , change_focus , cx)
933934 }
934- None => workspace. activate_item ( & active_editor, true , change_selection , cx) ,
935+ None => workspace. activate_item ( & active_editor, true , change_focus , cx) ,
935936 } ) ;
936937
937938 if activate. is_ok ( ) {
938939 self . select_entry ( entry. clone ( ) , true , cx) ;
939940 if change_selection {
940941 active_editor. update ( cx, |editor, cx| {
941942 editor. change_selections (
942- Some ( Autoscroll :: Strategy ( AutoscrollStrategy :: Top ) ) ,
943+ Some ( Autoscroll :: Strategy ( AutoscrollStrategy :: Center ) ) ,
943944 cx,
944945 |s| s. select_ranges ( Some ( anchor..anchor) ) ,
945946 ) ;
946947 } ) ;
947- active_editor. focus_handle ( cx) . focus ( cx) ;
948948 } else {
949949 active_editor. update ( cx, |editor, cx| {
950950 editor. set_scroll_anchor ( ScrollAnchor { offset, anchor } , cx) ;
951951 } ) ;
952+ }
953+
954+ if change_focus {
955+ active_editor. focus_handle ( cx) . focus ( cx) ;
956+ } else {
952957 self . focus_handle . focus ( cx) ;
953958 }
954959 }
@@ -969,7 +974,7 @@ impl OutlinePanel {
969974 self . select_first ( & SelectFirst { } , cx)
970975 }
971976 if let Some ( selected_entry) = self . selected_entry ( ) . cloned ( ) {
972- self . open_entry ( & selected_entry, false , cx) ;
977+ self . open_entry ( & selected_entry, true , false , cx) ;
973978 }
974979 }
975980
@@ -988,7 +993,7 @@ impl OutlinePanel {
988993 self . select_last ( & SelectLast , cx)
989994 }
990995 if let Some ( selected_entry) = self . selected_entry ( ) . cloned ( ) {
991- self . open_entry ( & selected_entry, false , cx) ;
996+ self . open_entry ( & selected_entry, true , false , cx) ;
992997 }
993998 }
994999
@@ -2027,9 +2032,9 @@ impl OutlinePanel {
20272032 if event. down . button == MouseButton :: Right || event. down . first_mouse {
20282033 return ;
20292034 }
2030- let change_selection = event. down . click_count > 1 ;
2035+ let change_focus = event. down . click_count > 1 ;
20312036 outline_panel. toggle_expanded ( & clicked_entry, cx) ;
2032- outline_panel. open_entry ( & clicked_entry, change_selection , cx) ;
2037+ outline_panel. open_entry ( & clicked_entry, true , change_focus , cx) ;
20332038 } )
20342039 } )
20352040 . cursor_pointer ( )
@@ -4863,9 +4868,13 @@ mod tests {
48634868 ) ,
48644869 select_first_in_all_matches( navigated_outline_selection)
48654870 ) ;
4871+ } ) ;
4872+ cx. executor ( )
4873+ . advance_clock ( UPDATE_DEBOUNCE + Duration :: from_millis ( 100 ) ) ;
4874+ outline_panel. update ( cx, |_, cx| {
48664875 assert_eq ! (
48674876 selected_row_text( & active_editor, cx) ,
4868- initial_outline_selection . replace( "search: " , "" ) , // Clear outline metadata prefixes
4877+ navigated_outline_selection . replace( "search: " , "" ) , // Clear outline metadata prefixes
48694878 "Should still have the initial caret position after SelectNext calls"
48704879 ) ;
48714880 } ) ;
@@ -4895,9 +4904,13 @@ mod tests {
48954904 ) ,
48964905 select_first_in_all_matches( next_navigated_outline_selection)
48974906 ) ;
4907+ } ) ;
4908+ cx. executor ( )
4909+ . advance_clock ( UPDATE_DEBOUNCE + Duration :: from_millis ( 100 ) ) ;
4910+ outline_panel. update ( cx, |_, cx| {
48984911 assert_eq ! (
48994912 selected_row_text( & active_editor, cx) ,
4900- navigated_outline_selection . replace( "search: " , "" ) , // Clear outline metadata prefixes
4913+ next_navigated_outline_selection . replace( "search: " , "" ) , // Clear outline metadata prefixes
49014914 "Should again preserve the selection after another SelectNext call"
49024915 ) ;
49034916 } ) ;
0 commit comments