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 go-to-line2
Mikayla409e17ad30ba
diff --cc crates/editor2/src/editor.rsindex 10831995ff3,ea76a7b57d9..4361ed53d09--- a/crates/editor2/src/editor.rs+++ b/crates/editor2/src/editor.rs@@@ -35,11 -37,13 +37,13 @@@ pub use element::};use futures::FutureExt;use fuzzy::{StringMatch, StringMatchCandidate};+ use git::diff_hunk_to_display;use gpui::{- actions, div, hsla, px, relative, rems, AnyElement, AppContext, BackgroundExecutor, Context,- DispatchContext, Div, Element, Entity, EventEmitter, FocusHandle, FontFeatures, FontStyle,- FontWeight, Hsla, Model, Pixels, Render, Styled, Subscription, Task, TextStyle, View,- ViewContext, VisualContext, WeakView, WindowContext,- action, actions, div, px, relative, AnyElement, AppContext, BackgroundExecutor, ClipboardItem,- Context, DispatchContext, Div, Element, Entity, EventEmitter, FocusHandle, FontStyle,- FontWeight, HighlightStyle, Hsla, InputHandler, Model, Pixels, PlatformInputHandler, Render,- Styled, Subscription, Task, TextStyle, View, ViewContext, VisualContext, WeakView,- WindowContext,++ action, actions, div, px, relative, rems, AnyElement, AppContext, BackgroundExecutor,++ ClipboardItem, Context, DispatchContext, Div, Element, Entity, EventEmitter, FocusHandle,++ FontFeatures, FontStyle, FontWeight, HighlightStyle, Hsla, InputHandler, Model, Pixels,++ PlatformInputHandler, Render, Styled, Subscription, Task, TextStyle, View, ViewContext,++ VisualContext, WeakView, WindowContext,};use highlight_matching_bracket::refresh_matching_bracket_highlights;use hover_popover::{hide_hover, HoverState};diff --cc crates/go_to_line2/src/go_to_line.rsindex fc0b7432c7b,3c9cd5e31eb..bb705427b1c--- a/crates/go_to_line2/src/go_to_line.rs+++ b/crates/go_to_line2/src/go_to_line.rs@@@ -1,25 -1,19 +1,24 @@@-use gpui::{actions, div, px, red, AppContext, Div, Render, Styled, ViewContext, VisualContext};+use editor::Editor;+use gpui::{+ actions, div, AppContext, Div, EventEmitter, ParentElement, Render, SharedString, Styled, View,+ ViewContext, VisualContext,+};+use text::Point;+use theme::ActiveTheme;+use ui::{h_stack, modal, v_stack, Label, LabelColor};+use util::paths::FILE_ROW_COLUMN_DELIMITER;use workspace::ModalRegistry;-actions!(Toggle);+actions!(Toggle, Cancel, Confirm);pub fn init(cx: &mut AppContext) {- cx.register_action_type::<Toggle>();cx.global_mut::<ModalRegistry>()- .register_modal(Toggle, |_, cx| {- // if let Some(editor) = workspace- // .active_item(cx)- // .and_then(|active_item| active_item.downcast::<Editor>())- // {- // cx.build_view(|cx| GoToLine::new(editor, cx))- // }- let view = cx.build_view(|_| GoToLine);- view+ .register_modal(Toggle, |workspace, cx| {+ let editor = workspace+ .active_item(cx)+ .and_then(|active_item| active_item.downcast::<Editor>())?;++ Some(cx.build_view(|cx| GoToLine::new(editor, cx)))});// cx.add_action(GoToLine::toggle);diff --cc crates/gpui2/src/styled.rsindex 2bf3006d419,c27347f2b1b..3f1fa843f99--- a/crates/gpui2/src/styled.rs+++ b/crates/gpui2/src/styled.rs@@@ -1,10 -1,11 +1,11 @@@use crate::{self as gpui, hsla, point, px, relative, rems, AbsoluteLength, AlignItems, CursorStyle,DefiniteLength, Display, Fill, FlexDirection, Hsla, JustifyContent, Length, Position,- SharedString, StyleRefinement, Visibility,+ SharedString, Style, StyleRefinement, Visibility,};use crate::{BoxShadow, TextStyleRefinement};+ use refineable::Refineable;-use smallvec::smallvec;+use smallvec::{smallvec, SmallVec};pub trait Styled {fn style(&mut self) -> &mut StyleRefinement;diff --cc crates/workspace2/src/modal_layer.rsindex c69354f87b5,4121574b6a4..694b4e7ffe1--- a/crates/workspace2/src/modal_layer.rs+++ b/crates/workspace2/src/modal_layer.rs@@@ -1,13 -1,9 +1,11 @@@- use std::{any::TypeId, sync::Arc};-+ use crate::Workspace;use gpui::{- div, px, AnyView, AppContext, Component, DispatchPhase, Div, ParentElement, Render,- StatelessInteractive, Styled, View, ViewContext,- div, AnyView, AppContext, Div, ParentElement, Render, StatelessInteractive, View, ViewContext,++ div, px, AnyView, AppContext, Component, Div, ParentElement, Render, StatelessInteractive,++ Styled, View, ViewContext,};+ use std::{any::TypeId, sync::Arc};+use ui::v_stack;- use crate::Workspace;-pub struct ModalRegistry {registered_modals: Vec<(TypeId, Box<dyn Fn(Div<Workspace>) -> Div<Workspace>>)>,}@@@ -43,18 -39,8 +41,11 @@@ impl ModalRegistrylet build_view = build_view.clone();div.on_action(- move |workspace: &mut Workspace,- event: &A,- phase: DispatchPhase,- cx: &mut ViewContext<Workspace>| {- if phase == DispatchPhase::Capture {- return;- }-+ move |workspace: &mut Workspace, event: &A, cx: &mut ViewContext<Workspace>| {- let new_modal = (build_view)(workspace, cx);+ let Some(new_modal) = (build_view)(workspace, cx) else {+ return;+ };+workspace.modal_layer.update(cx, |modal_layer, _| {modal_layer.open_modal = Some(new_modal.into());});