Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Merge remote-tracking branch 'origin/main' into perf-2
Nathan Sobofb3382bcc506
diff --cc crates/gpui2/src/elements/div.rsindex fa8ef50bbb7,bb8e76c627f..c24b5617d5d--- a/crates/gpui2/src/elements/div.rs+++ b/crates/gpui2/src/elements/div.rs@@@ -1152,81 -1273,84 +1305,87 @@@ impl Interactivitylet mut style = Style::default();style.refine(&self.base_style);- if let Some(focus_handle) = self.tracked_focus_handle.as_ref() {- if let Some(in_focus_style) = self.in_focus_style.as_ref() {- if focus_handle.within_focused(cx) {- style.refine(in_focus_style);+ cx.with_z_index(style.z_index.unwrap_or(0), |cx| {+ if let Some(focus_handle) = self.tracked_focus_handle.as_ref() {+ if let Some(in_focus_style) = self.in_focus_style.as_ref() {+ if focus_handle.within_focused(cx) {+ style.refine(in_focus_style);+ }}- }- if let Some(focus_style) = self.focus_style.as_ref() {- if focus_handle.is_focused(cx) {- style.refine(focus_style);+ if let Some(focus_style) = self.focus_style.as_ref() {+ if focus_handle.is_focused(cx) {+ style.refine(focus_style);+ }}}- }- if let Some(bounds) = bounds {- let mouse_position = cx.mouse_position();- if let Some(group_hover) = self.group_hover_style.as_ref() {- if let Some(group_bounds) = GroupBounds::get(&group_hover.group, cx) {- if group_bounds.contains(&mouse_position)+ if let Some(bounds) = bounds {+ let mouse_position = cx.mouse_position();+ if let Some(group_hover) = self.group_hover_style.as_ref() {+ if let Some(group_bounds) = GroupBounds::get(&group_hover.group, cx) {+ if group_bounds.contains(&mouse_position)+ && cx.was_top_layer(&mouse_position, cx.stacking_order())+ {+ style.refine(&group_hover.style);+ }+ }+ }+ if let Some(hover_style) = self.hover_style.as_ref() {+ if bounds+ .intersect(&cx.content_mask().bounds)+ .contains(&mouse_position)&& cx.was_top_layer(&mouse_position, cx.stacking_order()){- style.refine(&group_hover.style);+ style.refine(hover_style);}}- }- if let Some(hover_style) = self.hover_style.as_ref() {- if bounds- .intersect(&cx.content_mask().bounds)- .contains(&mouse_position)- && cx.was_top_layer(&mouse_position, cx.stacking_order())- {- style.refine(hover_style);- }- }- if let Some(drag) = cx.active_drag.take() {- for (state_type, group_drag_style) in &self.group_drag_over_styles {- if let Some(group_bounds) = GroupBounds::get(&group_drag_style.group, cx) {+ if let Some(drag) = cx.active_drag.take() {+ for (state_type, group_drag_style) in &self.group_drag_over_styles {+ if let Some(group_bounds) = GroupBounds::get(&group_drag_style.group, cx) {+ if *state_type == drag.view.entity_type()+ && group_bounds.contains(&mouse_position)+ {+ style.refine(&group_drag_style.style);+ }+ }+ }++ for (state_type, drag_over_style) in &self.drag_over_styles {if *state_type == drag.view.entity_type()- && group_bounds.contains(&mouse_position)+ && bounds+ .intersect(&cx.content_mask().bounds)+ .contains(&mouse_position)+ && cx.was_top_layer_under_active_drag(+ &mouse_position,+ cx.stacking_order(),+ ){- style.refine(&group_drag_style.style);+ style.refine(drag_over_style);}}- }- for (state_type, drag_over_style) in &self.drag_over_styles {- if *state_type == drag.view.entity_type()- && bounds- .intersect(&cx.content_mask().bounds)- .contains(&mouse_position)- {- style.refine(drag_over_style);- }+ cx.active_drag = Some(drag);}-- cx.active_drag = Some(drag);}- }- let clicked_state = element_state- .clicked_state- .get_or_insert_with(Default::default)- .borrow();- if clicked_state.group {- if let Some(group) = self.group_active_style.as_ref() {- style.refine(&group.style)- let clicked_state = element_state.clicked_state.borrow();++ let clicked_state = element_state++ .clicked_state++ .get_or_insert_with(Default::default)++ .borrow();+ if clicked_state.group {+ if let Some(group) = self.group_active_style.as_ref() {+ style.refine(&group.style)+ }}- }- if let Some(active_style) = self.active_style.as_ref() {- if clicked_state.element {- style.refine(active_style)+ if let Some(active_style) = self.active_style.as_ref() {+ if clicked_state.element {+ style.refine(active_style)+ }}- }+ });style}diff --cc crates/gpui2/src/style.rsindex d330e73585c,115db997843..f777e2d8cf2--- a/crates/gpui2/src/style.rs+++ b/crates/gpui2/src/style.rs@@@ -107,7 -110,12 +110,12 @@@ pub struct Style/// The mouse cursor style shown when the mouse pointer is over an element.pub mouse_cursor: Option<CursorStyle>,- pub z_index: Option<u32>,+ pub z_index: Option<u8>,++ #[cfg(debug_assertions)]+ pub debug: bool,+ #[cfg(debug_assertions)]+ pub debug_below: bool,}impl Styled for StyleRefinement {diff --cc crates/gpui2/src/window.rsindex fc8754afefb,585db90c6fe..2b00d193d60--- a/crates/gpui2/src/window.rs+++ b/crates/gpui2/src/window.rs@@@ -1,18 -1,18 +1,18 @@@use crate::{- key_dispatch::DispatchActionListener, px, size, Action, AnyDrag, AnyView, AppContext,- AsyncWindowContext, AvailableSpace, Bounds, BoxShadow, Context, Corners, CursorStyle,- DevicePixels, DispatchNodeId, DispatchTree, DisplayId, Edges, Effect, Entity, EntityId,- EventEmitter, FileDropEvent, Flatten, FocusEvent, FontId, GlobalElementId, GlyphId, Hsla,- ImageData, InputEvent, IsZero, KeyBinding, KeyContext, KeyDownEvent, KeystrokeEvent, LayoutId,- Model, ModelContext, Modifiers, MonochromeSprite, MouseButton, MouseMoveEvent, MouseUpEvent,- Path, Pixels, PlatformAtlas, PlatformDisplay, PlatformInputHandler, PlatformWindow, Point,- PolychromeSprite, PromptLevel, Quad, Render, RenderGlyphParams, RenderImageParams,- RenderSvgParams, ScaledPixels, Scene, SceneBuilder, Shadow, SharedString, Size, Style,- SubscriberSet, Subscription, Surface, TaffyLayoutEngine, Task, Underline, UnderlineStyle, View,- VisualContext, WeakView, WindowBounds, WindowOptions, SUBPIXEL_VARIANTS,+ key_dispatch::DispatchActionListener, px, size, transparent_black, Action, AnyDrag, AnyView,+ AppContext, AsyncWindowContext, AvailableSpace, Bounds, BoxShadow, Context, Corners,+ CursorStyle, DevicePixels, DispatchNodeId, DispatchTree, DisplayId, Edges, Effect, Entity,+ EntityId, EventEmitter, FileDropEvent, Flatten, FocusEvent, FontId, GlobalElementId, GlyphId,+ Hsla, ImageData, InputEvent, IsZero, KeyBinding, KeyContext, KeyDownEvent, KeystrokeEvent,+ LayoutId, Model, ModelContext, Modifiers, MonochromeSprite, MouseButton, MouseMoveEvent,+ MouseUpEvent, Path, Pixels, PlatformAtlas, PlatformDisplay, PlatformInputHandler,+ PlatformWindow, Point, PolychromeSprite, PromptLevel, Quad, Render, RenderGlyphParams,+ RenderImageParams, RenderSvgParams, ScaledPixels, Scene, SceneBuilder, Shadow, SharedString,+ Size, Style, SubscriberSet, Subscription, Surface, TaffyLayoutEngine, Task, Underline,+ UnderlineStyle, View, VisualContext, WeakView, WindowBounds, WindowOptions, SUBPIXEL_VARIANTS,};use anyhow::{anyhow, Context as _, Result};-use collections::HashMap;+use collections::FxHashMap;use derive_more::{Deref, DerefMut};use futures::{channel::{mpsc, oneshot},diff --cc crates/search2/src/project_search.rsindex f1b0c16d570,6e71253b1c9..bedbc25b229--- a/crates/search2/src/project_search.rs+++ b/crates/search2/src/project_search.rs@@@ -1440,122 -1479,78 +1479,62 @@@ impl Render for ProjectSearchBar}let search = search.read(cx);let semantic_is_available = SemanticIndex::enabled(cx);- let query_column = v_stack()- //.flex_1()- .child(- h_stack()- .min_w_80()- .on_action(cx.listener(|this, action, cx| this.confirm(action, cx)))- .on_action(- cx.listener(|this, action, cx| this.previous_history_query(action, cx)),- )- .on_action(cx.listener(|this, action, cx| this.next_history_query(action, cx)))- .child(IconElement::new(Icon::MagnifyingGlass))- .child(search.query_editor.clone())- .child(- h_stack()- .child(- IconButton::new("project-search-filter-button", Icon::Filter)- .tooltip(|cx| {- Tooltip::for_action("Toggle filters", &ToggleFilters, cx)- })- .on_click(cx.listener(|this, _, cx| {- this.toggle_filters(cx);- }))- .selected(- self.active_project_search- .as_ref()- .map(|search| search.read(cx).filters_enabled)- .unwrap_or_default(),- ),- )- .when(search.current_mode != SearchMode::Semantic, |this| {- this.child(- IconButton::new(- "project-search-case-sensitive",- Icon::CaseSensitive,- )- .tooltip(|cx| {- Tooltip::for_action(- "Toggle case sensitive",- &ToggleCaseSensitive,- cx,- )- })- .selected(- self.is_option_enabled(SearchOptions::CASE_SENSITIVE, cx),- )- .on_click(cx.listener(- |this, _, cx| {- this.toggle_search_option(- SearchOptions::CASE_SENSITIVE,- cx,- );- },- )),- )- .child(- IconButton::new("project-search-whole-word", Icon::WholeWord)- .tooltip(|cx| {- Tooltip::for_action(- "Toggle whole word",- &ToggleWholeWord,- cx,- )- })- .selected(- self.is_option_enabled(SearchOptions::WHOLE_WORD, cx),- )- .on_click(cx.listener(|this, _, cx| {- this.toggle_search_option(- SearchOptions::WHOLE_WORD,- cx,- );- })),- )- }),- )- .border_2()- .bg(white())- .rounded_lg(),- )- .when(search.filters_enabled, |this| {- this.child(+ let query_column = v_stack().child(+ h_stack()+ .min_w(rems(512. / 16.))+ .px_2()+ .py_1()+ .gap_2()+ .bg(cx.theme().colors().editor_background)+ .border_1()+ .border_color(cx.theme().colors().border)+ .rounded_lg()+ .on_action(cx.listener(|this, action, cx| this.confirm(action, cx)))+ .on_action(cx.listener(|this, action, cx| this.previous_history_query(action, cx)))+ .on_action(cx.listener(|this, action, cx| this.next_history_query(action, cx)))+ .child(IconElement::new(Icon::MagnifyingGlass))+ .child(self.render_text_input(&search.query_editor, cx))+ .child(h_stack()- .mt_2()- .flex_1()- .justify_between().child(- h_stack()- .flex_1()- .border_1()- .mr_2()- .child(search.included_files_editor.clone())- .when(search.current_mode != SearchMode::Semantic, |this| {- this.child(- SearchOptions::INCLUDE_IGNORED.as_button(- search- .search_options- .contains(SearchOptions::INCLUDE_IGNORED),- cx.listener(|this, _, cx| {- this.toggle_search_option(- SearchOptions::INCLUDE_IGNORED,- cx,- );- }),- ),- )- }),+ IconButton::new("project-search-filter-button", Icon::Filter)+ .tooltip(|cx| {+ Tooltip::for_action("Toggle filters", &ToggleFilters, cx)+ })+ .on_click(cx.listener(|this, _, cx| {+ this.toggle_filters(cx);+ }))+ .selected(+ self.active_project_search+ .as_ref()+ .map(|search| search.read(cx).filters_enabled)+ .unwrap_or_default(),+ ),)- .child(- h_stack()- .flex_1()- .border_1()- .ml_2()- .child(search.excluded_files_editor.clone()),- ),- )- });+ .when(search.current_mode != SearchMode::Semantic, |this| {+ this.child(+ IconButton::new(+ "project-search-case-sensitive",+ Icon::CaseSensitive,+ )+ .tooltip(|cx| {+ Tooltip::for_action(+ "Toggle case sensitive",+ &ToggleCaseSensitive,+ cx,+ )+ })- .selected(self.is_option_enabled(SearchOptions::CASE_SENSITIVE, cx))++ .selected(self.is_option_enabled(SearchOptions::WHOLE_WORD, cx))+ .on_click(cx.listener(+ |this, _, cx| {- this.toggle_search_option(- SearchOptions::CASE_SENSITIVE,- cx,- );++ this.toggle_search_option(SearchOptions::WHOLE_WORD, cx);+ },+ )),+ )- .child(- IconButton::new("project-search-whole-word", Icon::WholeWord)- .tooltip(|cx| {- Tooltip::for_action(- "Toggle whole word",- &ToggleWholeWord,- cx,- )- })- .selected(self.is_option_enabled(SearchOptions::WHOLE_WORD, cx))- .on_click(cx.listener(|this, _, cx| {- this.toggle_search_option(SearchOptions::WHOLE_WORD, cx);- })),- )+ }),+ ),+ );++let mode_column = v_stack().items_start().justify_start().child(h_stack().child(