mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-29 08:02:12 +03:00
Fix hovering over hover popovers in the editor
Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
6bc17cc9a4
commit
3c88aa3d18
@ -5,7 +5,9 @@ use super::{
|
||||
};
|
||||
use crate::{
|
||||
display_map::{BlockStyle, DisplaySnapshot, TransformBlock},
|
||||
hover_popover::HoverAt,
|
||||
hover_popover::{
|
||||
HoverAt, HOVER_POPOVER_GAP, MIN_POPOVER_CHARACTER_WIDTH, MIN_POPOVER_LINE_HEIGHT,
|
||||
},
|
||||
link_go_to_definition::{
|
||||
CmdShiftChanged, GoToFetchedDefinition, GoToFetchedTypeDefinition, UpdateGoToDefinitionLink,
|
||||
},
|
||||
@ -44,10 +46,6 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
const MIN_POPOVER_CHARACTER_WIDTH: f32 = 20.;
|
||||
const MIN_POPOVER_LINE_HEIGHT: f32 = 4.;
|
||||
const HOVER_POPOVER_GAP: f32 = 10.;
|
||||
|
||||
struct SelectionLayout {
|
||||
head: DisplayPoint,
|
||||
range: Range<DisplayPoint>,
|
||||
@ -559,7 +557,6 @@ impl EditorElement {
|
||||
bounds: RectF,
|
||||
visible_bounds: RectF,
|
||||
layout: &mut LayoutState,
|
||||
paint: &mut PaintState,
|
||||
cx: &mut PaintContext,
|
||||
) {
|
||||
let view = self.view(cx.app);
|
||||
@ -729,8 +726,6 @@ impl EditorElement {
|
||||
cx,
|
||||
);
|
||||
|
||||
paint.context_menu_bounds = Some(RectF::new(list_origin, context_menu.size()));
|
||||
|
||||
cx.scene.pop_stacking_context();
|
||||
}
|
||||
|
||||
@ -753,8 +748,6 @@ impl EditorElement {
|
||||
let y = position.row() as f32 * layout.position_map.line_height - scroll_top;
|
||||
let hovered_point = content_origin + vec2f(x, y);
|
||||
|
||||
paint.hover_popover_bounds.clear();
|
||||
|
||||
if hovered_point.y() - height_to_reserve > 0.0 {
|
||||
// There is enough space above. Render popovers above the hovered point
|
||||
let mut current_y = hovered_point.y();
|
||||
@ -773,11 +766,6 @@ impl EditorElement {
|
||||
cx,
|
||||
);
|
||||
|
||||
paint.hover_popover_bounds.push(
|
||||
RectF::new(popover_origin, hover_popover.size())
|
||||
.dilate(Vector2F::new(0., 5.)),
|
||||
);
|
||||
|
||||
current_y = popover_origin.y() - HOVER_POPOVER_GAP;
|
||||
}
|
||||
} else {
|
||||
@ -798,11 +786,6 @@ impl EditorElement {
|
||||
cx,
|
||||
);
|
||||
|
||||
paint.hover_popover_bounds.push(
|
||||
RectF::new(popover_origin, hover_popover.size())
|
||||
.dilate(Vector2F::new(0., 5.)),
|
||||
);
|
||||
|
||||
current_y = popover_origin.y() + size.y() + HOVER_POPOVER_GAP;
|
||||
}
|
||||
}
|
||||
@ -1271,7 +1254,7 @@ impl EditorElement {
|
||||
|
||||
impl Element for EditorElement {
|
||||
type LayoutState = LayoutState;
|
||||
type PaintState = PaintState;
|
||||
type PaintState = ();
|
||||
|
||||
fn layout(
|
||||
&mut self,
|
||||
@ -1614,11 +1597,6 @@ impl Element for EditorElement {
|
||||
layout.text_size,
|
||||
);
|
||||
|
||||
let mut paint_state = PaintState {
|
||||
context_menu_bounds: None,
|
||||
hover_popover_bounds: Default::default(),
|
||||
};
|
||||
|
||||
Self::attach_mouse_handlers(
|
||||
&self.view,
|
||||
&layout.position_map,
|
||||
@ -1633,7 +1611,7 @@ impl Element for EditorElement {
|
||||
if layout.gutter_size.x() > 0. {
|
||||
self.paint_gutter(gutter_bounds, visible_bounds, layout, cx);
|
||||
}
|
||||
self.paint_text(text_bounds, visible_bounds, layout, &mut paint_state, cx);
|
||||
self.paint_text(text_bounds, visible_bounds, layout, cx);
|
||||
|
||||
if !layout.blocks.is_empty() {
|
||||
cx.scene.push_layer(Some(bounds));
|
||||
@ -1642,8 +1620,6 @@ impl Element for EditorElement {
|
||||
}
|
||||
|
||||
cx.scene.pop_layer();
|
||||
|
||||
paint_state
|
||||
}
|
||||
|
||||
fn dispatch_event(
|
||||
@ -1652,7 +1628,7 @@ impl Element for EditorElement {
|
||||
_: RectF,
|
||||
_: RectF,
|
||||
_: &mut LayoutState,
|
||||
_: &mut PaintState,
|
||||
_: &mut (),
|
||||
cx: &mut EventContext,
|
||||
) -> bool {
|
||||
if let Event::ModifiersChanged(event) = event {
|
||||
@ -1821,11 +1797,6 @@ fn layout_line(
|
||||
)
|
||||
}
|
||||
|
||||
pub struct PaintState {
|
||||
context_menu_bounds: Option<RectF>,
|
||||
hover_popover_bounds: Vec<RectF>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum CursorShape {
|
||||
Bar,
|
||||
|
@ -20,6 +20,10 @@ use crate::{
|
||||
pub const HOVER_DELAY_MILLIS: u64 = 350;
|
||||
pub const HOVER_REQUEST_DELAY_MILLIS: u64 = 200;
|
||||
|
||||
pub const MIN_POPOVER_CHARACTER_WIDTH: f32 = 20.;
|
||||
pub const MIN_POPOVER_LINE_HEIGHT: f32 = 4.;
|
||||
pub const HOVER_POPOVER_GAP: f32 = 10.;
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct HoverAt {
|
||||
pub point: Option<DisplayPoint>,
|
||||
@ -350,10 +354,11 @@ impl InfoPopover {
|
||||
.with_style(style.hover_popover.container)
|
||||
.boxed()
|
||||
})
|
||||
.on_move(|_, _| {})
|
||||
.with_cursor_style(CursorStyle::Arrow)
|
||||
.with_padding(Padding {
|
||||
bottom: 5.,
|
||||
top: 5.,
|
||||
bottom: HOVER_POPOVER_GAP,
|
||||
top: HOVER_POPOVER_GAP,
|
||||
..Default::default()
|
||||
})
|
||||
.boxed()
|
||||
@ -390,6 +395,12 @@ impl DiagnosticPopover {
|
||||
.with_style(container_style)
|
||||
.boxed()
|
||||
})
|
||||
.with_padding(Padding {
|
||||
top: HOVER_POPOVER_GAP,
|
||||
bottom: HOVER_POPOVER_GAP,
|
||||
..Default::default()
|
||||
})
|
||||
.on_move(|_, _| {})
|
||||
.on_click(MouseButton::Left, |_, cx| {
|
||||
cx.dispatch_action(GoToDiagnostic)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user