Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add more debugging
Mikayla735f2029e9bb
diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rsindex aa6a5e32ec5..168be4d094b 100644--- a/crates/gpui2/src/elements/div.rs+++ b/crates/gpui2/src/elements/div.rs@@ -1,10 +1,10 @@use crate::{- green, point, px, red, Action, AnyDrag, AnyDragState, AnyElement, AnyTooltip, AnyView,- AppContext, BorrowAppContext, BorrowWindow, Bounds, ClickEvent, DispatchPhase, Element,- ElementId, FocusEvent, FocusHandle, IntoElement, KeyContext, KeyDownEvent, KeyUpEvent,- LayoutId, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels,- Point, Render, ScrollWheelEvent, SharedString, Size, StackingOrder, Style, StyleRefinement,- Styled, Task, View, Visibility, WindowContext,+ point, px, Action, AnyDrag, AnyDragState, AnyElement, AnyTooltip, AnyView, AppContext,+ BorrowAppContext, BorrowWindow, Bounds, ClickEvent, DispatchPhase, Element, ElementId,+ FocusEvent, FocusHandle, IntoElement, KeyContext, KeyDownEvent, KeyUpEvent, LayoutId,+ MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point,+ Render, ScrollWheelEvent, SharedString, Size, StackingOrder, Style, StyleRefinement, Styled,+ Task, View, Visibility, WindowContext,};use collections::HashMap;use refineable::Refineable;@@ -95,6 +95,32 @@ pub trait InteractiveElement: Sized + Element {self}+ fn on_mouse_down_weird(+ mut self,+ button: MouseButton,+ listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,+ ) -> Self {+ self.interactivity().mouse_down_listeners.push(Box::new(+ move |event, bounds, phase, cx| {+ dbg!("HEREEEE");++ let contains = dbg!(dbg!(&bounds.bounds).contains_point(dbg!(&event.position)))+ && dbg!(cx.was_top_layer(&event.position, &bounds.stacking_order));+ dbg!(contains);++ if phase == DispatchPhase::Bubble+ && event.button == button+ && bounds.visibly_contains(&event.position, cx)+ {+ dbg!("HEREEEE2");++ (listener)(event, cx)+ }+ },+ ));+ self+ }+fn on_any_mouse_down(mut self,listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,@@ -767,7 +793,7 @@ pub struct Interactivity {pub tooltip_builder: Option<TooltipBuilder>,}-#[derive(Clone)]+#[derive(Clone, Debug)]pub struct InteractiveBounds {pub bounds: Bounds<Pixels>,pub stacking_order: StackingOrder,diff --git a/crates/terminal_view2/src/terminal_element.rs b/crates/terminal_view2/src/terminal_element.rsindex 03e98e831d8..211d74ea3a8 100644--- a/crates/terminal_view2/src/terminal_element.rs+++ b/crates/terminal_view2/src/terminal_element.rs@@ -638,7 +638,7 @@ impl TerminalElement {let connection = self.terminal.clone();let mut this = self- .on_mouse_down(MouseButton::Left, {+ .on_mouse_down_weird(MouseButton::Left, {let connection = connection.clone();let focus = focus.clone();move |e, cx| {@@ -814,6 +814,7 @@ impl Element for TerminalElement {state: &mut Self::State,cx: &mut WindowContext<'_>,) {+ dbg!(bounds);let mut layout = self.compute_layout(bounds, cx);let theme = cx.theme();@@ -832,54 +833,51 @@ impl Element for TerminalElement {let mut this = self.register_mouse_listeners(origin, layout.mode, bounds, cx);let interactivity = mem::take(&mut this.interactivity);- cx.with_z_index(0, |cx| {- interactivity.paint(bounds, bounds.size, state, cx, |_, _, cx| {- this.register_key_listeners(cx);+ interactivity.paint(bounds, bounds.size, state, cx, |_, _, cx| {+ this.register_key_listeners(cx);- for rect in &layout.rects {- rect.paint(origin, &layout, cx);- }+ for rect in &layout.rects {+ rect.paint(origin, &layout, cx);+ }- cx.with_z_index(1, |cx| {- for (relative_highlighted_range, color) in- layout.relative_highlighted_ranges.iter()+ cx.with_z_index(1, |cx| {+ for (relative_highlighted_range, color) in layout.relative_highlighted_ranges.iter()+ {+ if let Some((start_y, highlighted_range_lines)) =+ to_highlighted_range_lines(relative_highlighted_range, &layout, origin){- if let Some((start_y, highlighted_range_lines)) =- to_highlighted_range_lines(relative_highlighted_range, &layout, origin)- {- let hr = HighlightedRange {- start_y, //Need to change this- line_height: layout.size.line_height,- lines: highlighted_range_lines,- color: color.clone(),- //Copied from editor. TODO: move to theme or something- corner_radius: 0.15 * layout.size.line_height,- };- hr.paint(bounds, cx);- }- }- });-- cx.with_z_index(2, |cx| {- for cell in &layout.cells {- cell.paint(origin, &layout, bounds, cx);+ let hr = HighlightedRange {+ start_y, //Need to change this+ line_height: layout.size.line_height,+ lines: highlighted_range_lines,+ color: color.clone(),+ //Copied from editor. TODO: move to theme or something+ corner_radius: 0.15 * layout.size.line_height,+ };+ hr.paint(bounds, cx);}- });-- if this.cursor_visible {- cx.with_z_index(3, |cx| {- if let Some(cursor) = &layout.cursor {- cursor.paint(origin, cx);- }- });}+ });- if let Some(element) = layout.hyperlink_tooltip.take() {- let width: AvailableSpace = bounds.size.width.into();- let height: AvailableSpace = bounds.size.height.into();- element.draw(origin, Size { width, height }, cx)+ cx.with_z_index(2, |cx| {+ for cell in &layout.cells {+ cell.paint(origin, &layout, bounds, cx);}});++ if this.cursor_visible {+ cx.with_z_index(3, |cx| {+ if let Some(cursor) = &layout.cursor {+ cursor.paint(origin, cx);+ }+ });+ }++ if let Some(element) = layout.hyperlink_tooltip.take() {+ let width: AvailableSpace = bounds.size.width.into();+ let height: AvailableSpace = bounds.size.height.into();+ element.draw(origin, Size { width, height }, cx)+ }});}}diff --git a/crates/terminal_view2/src/terminal_view.rs b/crates/terminal_view2/src/terminal_view.rsindex e9e4cd51676..17d4829e7cf 100644--- a/crates/terminal_view2/src/terminal_view.rs+++ b/crates/terminal_view2/src/terminal_view.rs@@ -266,18 +266,18 @@ impl TerminalView {.detach();let focus = cx.focus_handle();- let focus_in = cx.on_focus_in(&focus, |this, cx| {- this.has_new_content = false;- this.terminal.read(cx).focus_in();- this.blink_cursors(this.blink_epoch, cx);- cx.notify();- });- let focus_out = cx.on_focus_out(&focus, |this, cx| {- this.terminal.update(cx, |terminal, _| {- terminal.focus_out();- });- cx.notify();- });+ // let focus_in = cx.on_focus_in(&focus, |this, cx| {+ // this.has_new_content = false;+ // this.terminal.read(cx).focus_in();+ // this.blink_cursors(this.blink_epoch, cx);+ // cx.notify();+ // });+ // let focus_out = cx.on_focus_out(&focus, |this, cx| {+ // this.terminal.update(cx, |terminal, _| {+ // terminal.focus_out();+ // });+ // cx.notify();+ // });Self {terminal,@@ -291,7 +291,7 @@ impl TerminalView {blink_epoch: 0,can_navigate_to_selected_word: false,workspace_id,- _subscriptions: vec![focus_in, focus_out],+ _subscriptions: vec![/*focus_in, focus_out*/],}}