@@ -811,7 +811,7 @@ impl OutlinePanel {
811
811
if self . filter_editor . focus_handle ( cx) . is_focused ( cx) {
812
812
cx. propagate ( )
813
813
} 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) ;
815
815
}
816
816
}
817
817
@@ -834,7 +834,7 @@ impl OutlinePanel {
834
834
} else if let Some ( ( active_editor, selected_entry) ) =
835
835
self . active_editor ( ) . zip ( self . selected_entry ( ) . cloned ( ) )
836
836
{
837
- self . open_entry ( & selected_entry, true , cx) ;
837
+ self . open_entry ( & selected_entry, true , true , cx) ;
838
838
active_editor. update ( cx, |editor, cx| editor. open_excerpts ( action, cx) ) ;
839
839
}
840
840
}
@@ -849,7 +849,7 @@ impl OutlinePanel {
849
849
} else if let Some ( ( active_editor, selected_entry) ) =
850
850
self . active_editor ( ) . zip ( self . selected_entry ( ) . cloned ( ) )
851
851
{
852
- self . open_entry ( & selected_entry, true , cx) ;
852
+ self . open_entry ( & selected_entry, true , true , cx) ;
853
853
active_editor. update ( cx, |editor, cx| editor. open_excerpts_in_split ( action, cx) ) ;
854
854
}
855
855
}
@@ -858,6 +858,7 @@ impl OutlinePanel {
858
858
& mut self ,
859
859
entry : & PanelEntry ,
860
860
change_selection : bool ,
861
+ change_focus : bool ,
861
862
cx : & mut ViewContext < OutlinePanel > ,
862
863
) {
863
864
let Some ( active_editor) = self . active_editor ( ) else {
@@ -929,26 +930,30 @@ impl OutlinePanel {
929
930
. workspace
930
931
. update ( cx, |workspace, cx| match self . active_item ( ) {
931
932
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)
933
934
}
934
- None => workspace. activate_item ( & active_editor, true , change_selection , cx) ,
935
+ None => workspace. activate_item ( & active_editor, true , change_focus , cx) ,
935
936
} ) ;
936
937
937
938
if activate. is_ok ( ) {
938
939
self . select_entry ( entry. clone ( ) , true , cx) ;
939
940
if change_selection {
940
941
active_editor. update ( cx, |editor, cx| {
941
942
editor. change_selections (
942
- Some ( Autoscroll :: Strategy ( AutoscrollStrategy :: Top ) ) ,
943
+ Some ( Autoscroll :: Strategy ( AutoscrollStrategy :: Center ) ) ,
943
944
cx,
944
945
|s| s. select_ranges ( Some ( anchor..anchor) ) ,
945
946
) ;
946
947
} ) ;
947
- active_editor. focus_handle ( cx) . focus ( cx) ;
948
948
} else {
949
949
active_editor. update ( cx, |editor, cx| {
950
950
editor. set_scroll_anchor ( ScrollAnchor { offset, anchor } , cx) ;
951
951
} ) ;
952
+ }
953
+
954
+ if change_focus {
955
+ active_editor. focus_handle ( cx) . focus ( cx) ;
956
+ } else {
952
957
self . focus_handle . focus ( cx) ;
953
958
}
954
959
}
@@ -969,7 +974,7 @@ impl OutlinePanel {
969
974
self . select_first ( & SelectFirst { } , cx)
970
975
}
971
976
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) ;
973
978
}
974
979
}
975
980
@@ -988,7 +993,7 @@ impl OutlinePanel {
988
993
self . select_last ( & SelectLast , cx)
989
994
}
990
995
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) ;
992
997
}
993
998
}
994
999
@@ -2027,9 +2032,9 @@ impl OutlinePanel {
2027
2032
if event. down . button == MouseButton :: Right || event. down . first_mouse {
2028
2033
return ;
2029
2034
}
2030
- let change_selection = event. down . click_count > 1 ;
2035
+ let change_focus = event. down . click_count > 1 ;
2031
2036
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) ;
2033
2038
} )
2034
2039
} )
2035
2040
. cursor_pointer ( )
@@ -4863,9 +4868,13 @@ mod tests {
4863
4868
) ,
4864
4869
select_first_in_all_matches( navigated_outline_selection)
4865
4870
) ;
4871
+ } ) ;
4872
+ cx. executor ( )
4873
+ . advance_clock ( UPDATE_DEBOUNCE + Duration :: from_millis ( 100 ) ) ;
4874
+ outline_panel. update ( cx, |_, cx| {
4866
4875
assert_eq ! (
4867
4876
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
4869
4878
"Should still have the initial caret position after SelectNext calls"
4870
4879
) ;
4871
4880
} ) ;
@@ -4895,9 +4904,13 @@ mod tests {
4895
4904
) ,
4896
4905
select_first_in_all_matches( next_navigated_outline_selection)
4897
4906
) ;
4907
+ } ) ;
4908
+ cx. executor ( )
4909
+ . advance_clock ( UPDATE_DEBOUNCE + Duration :: from_millis ( 100 ) ) ;
4910
+ outline_panel. update ( cx, |_, cx| {
4898
4911
assert_eq ! (
4899
4912
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
4901
4914
"Should again preserve the selection after another SelectNext call"
4902
4915
) ;
4903
4916
} ) ;
0 commit comments