Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Merge branch 'main' into fix-panel-resize
Max Brunsfeldcf037ea4a8cd
diff --cc crates/gpui2/src/elements/div.rsindex 02b9d08b40e,631ffc43c67..0d477fc62d7--- a/crates/gpui2/src/elements/div.rs+++ b/crates/gpui2/src/elements/div.rs@@@ -984,175 -997,167 +984,175 @@@ impl Interactivitylocation.file(),location.line(),location.column()- ))- .spawn()- .ok();+ );++ std::process::Command::new("zed")+ .arg(format!(+ "{}/{}:{}:{}",+ dir.to_string_lossy(),+ location.file(),+ location.line(),+ location.column()+ ))+ .spawn()+ .ok();+ }}- }- });- cx.paint_quad(crate::outline(- crate::Bounds {- origin: bounds.origin- + crate::point(crate::px(0.), FONT_SIZE - px(2.)),- size: crate::Size {- width: text_bounds.size.width,- height: crate::px(1.),+ });+ cx.paint_quad(crate::outline(+ crate::Bounds {+ origin: bounds.origin+ + crate::point(crate::px(0.), FONT_SIZE - px(2.)),+ size: crate::Size {+ width: text_bounds.size.width,+ height: crate::px(1.),+ },},- },- crate::red(),- ))+ crate::red(),+ ))+ }}- }- };-- cx.with_z_index(1, |cx| {- cx.with_text_style(- Some(crate::TextStyleRefinement {- color: Some(crate::red()),- line_height: Some(FONT_SIZE.into()),- background_color: Some(crate::white()),- ..Default::default()- }),- render_debug_text,- )- });- }+ };++ cx.with_z_index(1, |cx| {+ cx.with_text_style(+ Some(crate::TextStyleRefinement {+ color: Some(crate::red()),+ line_height: Some(FONT_SIZE.into()),+ background_color: Some(crate::white()),+ ..Default::default()+ }),+ render_debug_text,+ )+ });+ }- if style- .background- .as_ref()- .is_some_and(|fill| fill.color().is_some_and(|color| !color.is_transparent()))- {- cx.with_z_index(style.z_index.unwrap_or(0), |cx| cx.add_opaque_layer(bounds))- }+ if style+ .background+ .as_ref()+ .is_some_and(|fill| fill.color().is_some_and(|color| !color.is_transparent()))+ {+ cx.add_opaque_layer(bounds)+ }- let interactive_bounds = InteractiveBounds {- bounds: bounds.intersect(&cx.content_mask().bounds),- stacking_order: cx.stacking_order().clone(),- };+ let interactive_bounds = InteractiveBounds {+ bounds: bounds.intersect(&cx.content_mask().bounds),+ stacking_order: cx.stacking_order().clone(),+ };- if let Some(mouse_cursor) = style.mouse_cursor {- let mouse_position = &cx.mouse_position();- let hovered = interactive_bounds.visibly_contains(mouse_position, cx);- if hovered {- cx.set_cursor_style(mouse_cursor);+ if let Some(mouse_cursor) = style.mouse_cursor {+ let mouse_position = &cx.mouse_position();+ let hovered = interactive_bounds.visibly_contains(mouse_position, cx);+ if hovered {+ cx.set_cursor_style(mouse_cursor);+ }}- }- // If this element can be focused, register a mouse down listener- // that will automatically transfer focus when hitting the element.- // This behavior can be suppressed by using `cx.prevent_default()`.- if let Some(focus_handle) = element_state.focus_handle.clone() {- cx.on_mouse_event({- let interactive_bounds = interactive_bounds.clone();- move |event: &MouseDownEvent, phase, cx| {- if phase == DispatchPhase::Bubble- && !cx.default_prevented()- && interactive_bounds.visibly_contains(&event.position, cx)- {- cx.focus(&focus_handle);- // If there is a parent that is also focusable, prevent it- // from transferring focus because we already did so.- cx.prevent_default();+ // If this element can be focused, register a mouse down listener+ // that will automatically transfer focus when hitting the element.+ // This behavior can be suppressed by using `cx.prevent_default()`.+ if let Some(focus_handle) = element_state.focus_handle.clone() {+ cx.on_mouse_event({+ let interactive_bounds = interactive_bounds.clone();+ move |event: &MouseDownEvent, phase, cx| {+ if phase == DispatchPhase::Bubble+ && !cx.default_prevented()+ && interactive_bounds.visibly_contains(&event.position, cx)+ {+ cx.focus(&focus_handle);+ // If there is a parent that is also focusable, prevent it- // from trasferring focus because we already did so.++ // from transferring focus because we already did so.+ cx.prevent_default();+ }}- }- });- }+ });+ }- for listener in self.mouse_down_listeners.drain(..) {- let interactive_bounds = interactive_bounds.clone();- cx.on_mouse_event(move |event: &MouseDownEvent, phase, cx| {- listener(event, &interactive_bounds, phase, cx);- })- }+ for listener in self.mouse_down_listeners.drain(..) {+ let interactive_bounds = interactive_bounds.clone();+ cx.on_mouse_event(move |event: &MouseDownEvent, phase, cx| {+ listener(event, &interactive_bounds, phase, cx);+ })+ }- for listener in self.mouse_up_listeners.drain(..) {- let interactive_bounds = interactive_bounds.clone();- cx.on_mouse_event(move |event: &MouseUpEvent, phase, cx| {- listener(event, &interactive_bounds, phase, cx);- })- }+ for listener in self.mouse_up_listeners.drain(..) {+ let interactive_bounds = interactive_bounds.clone();+ cx.on_mouse_event(move |event: &MouseUpEvent, phase, cx| {+ listener(event, &interactive_bounds, phase, cx);+ })+ }- for listener in self.mouse_move_listeners.drain(..) {- let interactive_bounds = interactive_bounds.clone();- cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {- listener(event, &interactive_bounds, phase, cx);- })- }+ for listener in self.mouse_move_listeners.drain(..) {+ let interactive_bounds = interactive_bounds.clone();+ cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {+ listener(event, &interactive_bounds, phase, cx);+ })+ }- for listener in self.scroll_wheel_listeners.drain(..) {- let interactive_bounds = interactive_bounds.clone();- cx.on_mouse_event(move |event: &ScrollWheelEvent, phase, cx| {- listener(event, &interactive_bounds, phase, cx);- })- }+ for listener in self.scroll_wheel_listeners.drain(..) {+ let interactive_bounds = interactive_bounds.clone();+ cx.on_mouse_event(move |event: &ScrollWheelEvent, phase, cx| {+ listener(event, &interactive_bounds, phase, cx);+ })+ }- let hover_group_bounds = self- .group_hover_style- .as_ref()- .and_then(|group_hover| GroupBounds::get(&group_hover.group, cx));+ let hover_group_bounds = self+ .group_hover_style+ .as_ref()+ .and_then(|group_hover| GroupBounds::get(&group_hover.group, cx));- if let Some(group_bounds) = hover_group_bounds {- let hovered = group_bounds.contains(&cx.mouse_position());- cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {- if phase == DispatchPhase::Capture {- if group_bounds.contains(&event.position) != hovered {- cx.notify();+ if let Some(group_bounds) = hover_group_bounds {+ let hovered = group_bounds.contains(&cx.mouse_position());+ cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {+ if phase == DispatchPhase::Capture {+ if group_bounds.contains(&event.position) != hovered {+ cx.notify();+ }}- }- });- }+ });+ }- if self.hover_style.is_some()- || self.base_style.mouse_cursor.is_some()- || cx.active_drag.is_some() && !self.drag_over_styles.is_empty()- {- let bounds = bounds.intersect(&cx.content_mask().bounds);- let hovered = bounds.contains(&cx.mouse_position());- cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {- if phase == DispatchPhase::Capture {- if bounds.contains(&event.position) != hovered {- cx.notify();+ if self.hover_style.is_some()+ || self.base_style.mouse_cursor.is_some()+ || cx.active_drag.is_some() && !self.drag_over_styles.is_empty()+ {+ let bounds = bounds.intersect(&cx.content_mask().bounds);+ let hovered = bounds.contains(&cx.mouse_position());+ cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {+ if phase == DispatchPhase::Capture {+ if bounds.contains(&event.position) != hovered {+ cx.notify();+ }}- }- });- }+ });+ }- if cx.active_drag.is_some() {+ let mut drag_listener = mem::take(&mut self.drag_listener);let drop_listeners = mem::take(&mut self.drop_listeners);- let interactive_bounds = interactive_bounds.clone();+ let click_listeners = mem::take(&mut self.click_listeners);+if !drop_listeners.is_empty() {- cx.on_mouse_event(move |event: &MouseUpEvent, phase, cx| {- if phase == DispatchPhase::Bubble- && interactive_bounds.drag_target_contains(&event.position, cx)- {- if let Some(drag_state_type) = cx- .active_drag- .as_ref()- .map(|drag| drag.value.as_ref().type_id())- {- for (drop_state_type, listener) in &drop_listeners {- if *drop_state_type == drag_state_type {- let drag = cx- .active_drag- .take()- .expect("checked for type drag state type above");-- listener(drag.value.as_ref(), cx);- cx.notify();- cx.stop_propagation();+ cx.on_mouse_event({+ let interactive_bounds = interactive_bounds.clone();+ move |event: &MouseUpEvent, phase, cx| {+ if let Some(drag) = &cx.active_drag {+ if phase == DispatchPhase::Bubble+ && interactive_bounds.drag_target_contains(&event.position, cx)+ {+ let drag_state_type = drag.value.as_ref().type_id();+ for (drop_state_type, listener) in &drop_listeners {+ if *drop_state_type == drag_state_type {+ let drag = cx+ .active_drag+ .take()+ .expect("checked for type drag state type above");++ listener(drag.value.as_ref(), cx);+ cx.notify();+ cx.stop_propagation();+ }}}- } else {- cx.active_drag = None;}}});