diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index deedd07d3eddfd563d4fbdaf51311908ebc40c01..a04e16683d92f8e79cbe75d6dc03764276ede226 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -8139,6 +8139,7 @@ pub(crate) fn render_buffer_header( .h(FILE_HEADER_HEIGHT as f32 * window.line_height()) .child( h_flex() + .group("buffer-header-group") .size_full() .flex_basis(Length::Definite(DefiniteLength::Fraction(0.667))) .pl_1() @@ -8332,31 +8333,36 @@ pub(crate) fn render_buffer_header( }) }, )) - .when( - can_open_excerpts && is_selected && relative_path.is_some(), - |el| { - el.child( - Button::new("open-file-button", "Open File") - .style(ButtonStyle::OutlinedGhost) - .key_binding(KeyBinding::for_action_in( - &OpenExcerpts, - &focus_handle, - cx, - )) - .on_click(window.listener_for(editor, { - let jump_data = jump_data.clone(); - move |editor, e: &ClickEvent, window, cx| { - editor.open_excerpts_common( - Some(jump_data.clone()), - e.modifiers().secondary(), - window, + .when(can_open_excerpts && relative_path.is_some(), |this| { + this.child( + div() + .when(!is_selected, |this| { + this.visible_on_hover("buffer-header-group") + }) + .child( + Button::new("open-file-button", "Open File") + .style(ButtonStyle::OutlinedGhost) + .when(is_selected, |this| { + this.key_binding(KeyBinding::for_action_in( + &OpenExcerpts, + &focus_handle, cx, - ); - } - })), - ) - }, - ) + )) + }) + .on_click(window.listener_for(editor, { + let jump_data = jump_data.clone(); + move |editor, e: &ClickEvent, window, cx| { + editor.open_excerpts_common( + Some(jump_data.clone()), + e.modifiers().secondary(), + window, + cx, + ); + } + })), + ), + ) + }) .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation()) .on_click(window.listener_for(editor, { let buffer_id = for_excerpt.buffer_id;