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 zed2-workspace
Conrad Irwin269a72464d56
diff --cc crates/workspace2/src/workspace2.rsindex 92d5c7c73f3,3731094b26f..24864633920--- a/crates/workspace2/src/workspace2.rs+++ b/crates/workspace2/src/workspace2.rs@@@ -10,70 -10,77 +10,70 @@@ mod status_barmod toolbar;mod workspace_settings;-use anyhow::{anyhow, Result};-// use call2::ActiveCall;-// use client2::{-// proto::{self, PeerId},-// Client, Status, TypedEnvelope, UserStore,-// };-// use collections::{hash_map, HashMap, HashSet};-// use futures::{-// channel::{mpsc, oneshot},-// future::try_join_all,-// FutureExt, StreamExt,-// };-// use gpui2::{-// actions,-// elements::*,-// geometry::{-// rect::RectF,-// vector::{vec2f, Vector2F},-// },-// impl_actions,-// platform::{-// CursorStyle, ModifiersChangedEvent, MouseButton, PathPromptOptions, Platform, PromptLevel,-// WindowBounds, WindowOptions,-// },-// AnyModelHandle, AnyViewHandle, AnyWeakViewHandle, AnyWindowHandle, AppContext, AsyncAppContext,-// Entity, ModelContext, ModelHandle, SizeConstraint, Subscription, Task, View, ViewContext,-// View, WeakViewHandle, WindowContext, WindowHandle,-// };-// use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem};-// use itertools::Itertools;-// use language2::{LanguageRegistry, Rope};-// use node_runtime::NodeRuntime;// //--use futures::channel::oneshot;-// use crate::{-// notifications::{simple_message_notification::MessageNotification, NotificationTracker},-// persistence::model::{-// DockData, DockStructure, SerializedPane, SerializedPaneGroup, SerializedWorkspace,-// },-// };-// use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle};-// use lazy_static::lazy_static;-// use notifications::{NotificationHandle, NotifyResultExt};+use crate::persistence::model::{+ DockData, DockStructure, SerializedItem, SerializedPane, SerializedPaneGroup,+ SerializedWorkspace,+};+use anyhow::{anyhow, Context as _, Result};+use call2::ActiveCall;+use client2::{+ proto::{self, PeerId},+ Client, TypedEnvelope, UserStore,+};+use collections::{HashMap, HashSet};+use dock::{Dock, DockPosition, PanelButtons};+use futures::{+ channel::{mpsc, oneshot},+ future::try_join_all,+ Future, FutureExt, StreamExt,+};+use gpui2::{+ div, point, size, AnyModel, AnyView, AnyWeakView, AppContext, AsyncAppContext,- AsyncWindowContext, Bounds, Component, Div, EntityId, EventEmitter, GlobalPixels,- Model, ModelContext, ParentElement, Point, Render, Size, StatefulInteractive, Styled,- Subscription, Task, View, ViewContext, VisualContext, WeakView, WindowBounds, WindowContext,- WindowHandle, WindowOptions,++ AsyncWindowContext, Bounds, Component, Div, EntityId, EventEmitter, GlobalPixels, Model,++ ModelContext, ParentElement, Point, Render, Size, StatefulInteractive, Styled, Subscription,++ Task, View, ViewContext, VisualContext, WeakView, WindowBounds, WindowContext, WindowHandle,++ WindowOptions,+};+use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem};+use language2::LanguageRegistry;+use lazy_static::lazy_static;+use node_runtime::NodeRuntime;+use notifications::{simple_message_notification::MessageNotification, NotificationHandle};pub use pane::*;pub use pane_group::*;-// use persistence::{model::SerializedItem, DB};-// pub use persistence::{-// model::{ItemId, WorkspaceLocation},-// WorkspaceDb, DB as WORKSPACE_DB,-// };-// use postage::prelude::Stream;-// use project::{Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId};-// use serde::Deserialize;-// use shared_screen::SharedScreen;-// use status_bar::StatusBar;-// pub use status_bar::StatusItemView;-// use theme::{Theme, ThemeSettings};+use persistence::{+ model::{ItemId, WorkspaceLocation},+ DB,+};+use postage::stream::Stream;+use project2::{Project, ProjectEntryId, ProjectPath, Worktree};+use serde::Deserialize;+use settings2::Settings;+use status_bar::StatusBar;+use std::{+ any::TypeId,+ borrow::Cow,+ env,+ path::{Path, PathBuf},+ sync::{atomic::AtomicUsize, Arc},+ time::Duration,+};+use theme2::ActiveTheme;pub use toolbar::{ToolbarItemLocation, ToolbarItemView};-// use util::ResultExt;-// pub use workspace_settings::{AutosaveSetting, GitGutterSetting, WorkspaceSettings};--// lazy_static! {-// static ref ZED_WINDOW_SIZE: Option<Vector2F> = env::var("ZED_WINDOW_SIZE")-// .ok()-// .as_deref()-// .and_then(parse_pixel_position_env_var);-// static ref ZED_WINDOW_POSITION: Option<Vector2F> = env::var("ZED_WINDOW_POSITION")-// .ok()-// .as_deref()-// .and_then(parse_pixel_position_env_var);-// }+use util::ResultExt;+use uuid::Uuid;+use workspace_settings::{AutosaveSetting, WorkspaceSettings};++lazy_static! {+ static ref ZED_WINDOW_SIZE: Option<Size<GlobalPixels>> = env::var("ZED_WINDOW_SIZE")+ .ok()+ .as_deref()+ .and_then(parse_pixel_size_env_var);+ static ref ZED_WINDOW_POSITION: Option<Point<GlobalPixels>> = env::var("ZED_WINDOW_POSITION")+ .ok()+ .as_deref()+ .and_then(parse_pixel_position_env_var);+}// pub trait Modal: View {// fn has_focus(&self) -> bool;@@@ -2689,86 -2688,100 +2689,85 @@@ impl Workspace// .any(|state| state.leader_id == peer_id)// }- // fn render_titlebar(&self, theme: &Theme, cx: &mut ViewContext<Self>) -> AnyElement<Self> {- // // TODO: There should be a better system in place for this- // // (https://github.com/zed-industries/zed/issues/1290)- // let is_fullscreen = cx.window_is_fullscreen();- // let container_theme = if is_fullscreen {- // let mut container_theme = theme.titlebar.container;- // container_theme.padding.left = container_theme.padding.right;- // container_theme- // } else {- // theme.titlebar.container- // };-- // enum TitleBar {}- // MouseEventHandler::new::<TitleBar, _>(0, cx, |_, cx| {- // Stack::new()- // .with_children(- // self.titlebar_item- // .as_ref()- // .map(|item| ChildView::new(item, cx)),- // )- // .contained()- // .with_style(container_theme)- // })- // .on_click(MouseButton::Left, |event, _, cx| {- // if event.click_count == 2 {- // cx.zoom_window();- // }- // })- // .constrained()- // .with_height(theme.titlebar.height)- // .into_any_named("titlebar")- // }+ fn render_titlebar(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {+ div()+ .bg(cx.theme().colors().title_bar)+ .when(+ !matches!(cx.window_bounds(), WindowBounds::Fullscreen),+ |s| s.pl_20(),+ )+ .id("titlebar")- .on_click(|workspace, event, cx| {++ .on_click(|_, event, cx| {+ if event.up.click_count == 2 {- // todo!()- // cx.zoom_window();++ cx.zoom_window();+ }+ })+ .child("Collab title bar Item") // self.titlebar_item+ }- // fn active_item_path_changed(&mut self, cx: &mut ViewContext<Self>) {- // let active_entry = self.active_project_path(cx);- // self.project- // .update(cx, |project, cx| project.set_active_path(active_entry, cx));- // self.update_window_title(cx);- // }+ // fn active_item_path_changed(&mut self, cx: &mut ViewContext<Self>) {+ // let active_entry = self.active_project_path(cx);+ // self.project+ // .update(cx, |project, cx| project.set_active_path(active_entry, cx));+ // self.update_window_title(cx);+ // }- // fn update_window_title(&mut self, cx: &mut ViewContext<Self>) {- // let project = self.project().read(cx);- // let mut title = String::new();-- // if let Some(path) = self.active_item(cx).and_then(|item| item.project_path(cx)) {- // let filename = path- // .path- // .file_name()- // .map(|s| s.to_string_lossy())- // .or_else(|| {- // Some(Cow::Borrowed(- // project- // .worktree_for_id(path.worktree_id, cx)?- // .read(cx)- // .root_name(),- // ))- // });+ fn update_window_title(&mut self, cx: &mut ViewContext<Self>) {+ let project = self.project().read(cx);+ let mut title = String::new();++ if let Some(path) = self.active_item(cx).and_then(|item| item.project_path(cx)) {+ let filename = path+ .path+ .file_name()+ .map(|s| s.to_string_lossy())+ .or_else(|| {+ Some(Cow::Borrowed(+ project+ .worktree_for_id(path.worktree_id, cx)?+ .read(cx)+ .root_name(),+ ))+ });- // if let Some(filename) = filename {- // title.push_str(filename.as_ref());- // title.push_str(" — ");- // }- // }+ if let Some(filename) = filename {+ title.push_str(filename.as_ref());+ title.push_str(" — ");+ }+ }- // for (i, name) in project.worktree_root_names(cx).enumerate() {- // if i > 0 {- // title.push_str(", ");- // }- // title.push_str(name);- // }+ for (i, name) in project.worktree_root_names(cx).enumerate() {+ if i > 0 {+ title.push_str(", ");+ }+ title.push_str(name);+ }- // if title.is_empty() {- // title = "empty project".to_string();- // }+ if title.is_empty() {+ title = "empty project".to_string();+ }- // if project.is_remote() {- // title.push_str(" ↙");- // } else if project.is_shared() {- // title.push_str(" ↗");- // }+ if project.is_remote() {+ title.push_str(" ↙");+ } else if project.is_shared() {+ title.push_str(" ↗");+ }- // cx.set_window_title(&title);- // }+ // todo!()+ // cx.set_window_title(&title);+ }- // fn update_window_edited(&mut self, cx: &mut ViewContext<Self>) {- // let is_edited = !self.project.read(cx).is_read_only()- // && self- // .items(cx)- // .any(|item| item.has_conflict(cx) || item.is_dirty(cx));- // if is_edited != self.window_edited {- // self.window_edited = is_edited;- // cx.set_window_edited(self.window_edited)- // }- // }+ fn update_window_edited(&mut self, cx: &mut ViewContext<Self>) {+ let is_edited = !self.project.read(cx).is_read_only()+ && self+ .items(cx)+ .any(|item| item.has_conflict(cx) || item.is_dirty(cx));+ if is_edited != self.window_edited {+ self.window_edited = is_edited;+ todo!()+ // cx.set_window_edited(self.window_edited)+ }+ }// fn render_disconnected_overlay(// &self,diff --cc crates/zed2/src/main.rsindex e91fb4bed41,78e94c591cb..05ca4690b8e--- a/crates/zed2/src/main.rs+++ b/crates/zed2/src/main.rs@@@ -8,13 -8,13 +8,13 @@@ use cli::ipc::{self, IpcSender},CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,};- use client2::UserStore;- use db2::kvp::KEY_VALUE_STORE;- use fs2::RealFs;+ use client::UserStore;+ use db::kvp::KEY_VALUE_STORE;+ use fs::RealFs;use futures::{channel::mpsc, SinkExt, StreamExt};- use gpui2::{Action, App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};-use gpui::{App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};++use gpui::{Action, App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};use isahc::{prelude::Configurable, Request};- use language2::LanguageRegistry;+ use language::LanguageRegistry;use log::LevelFilter;use node_runtime::RealNodeRuntime;@@@ -124,10 -122,10 +124,10 @@@ fn main()let languages = Arc::new(languages);let node_runtime = RealNodeRuntime::new(http.clone());- language2::init(cx);+ language::init(cx);languages::init(languages.clone(), node_runtime.clone(), cx);let user_store = cx.build_model(|cx| UserStore::new(client.clone(), http.clone(), cx));- // let workspace_store = cx.add_model(|cx| WorkspaceStore::new(client.clone(), cx));+ let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));cx.set_global(client.clone());diff --cc crates/zed2/src/zed2.rsindex b86a7d7d2b4,ea8bdd9f1c2..fe57d127527--- a/crates/zed2/src/zed2.rs+++ b/crates/zed2/src/zed2.rs@@@ -4,11 -4,8 +4,12 @@@ mod only_instancemod open_listener;pub use assets::*;+use collections::HashMap;- use gpui2::{+ use client::{Client, UserStore};-use gpui::{AsyncAppContext, Model};++use gpui::{+ point, px, AppContext, AsyncAppContext, AsyncWindowContext, Point, Task, TitlebarOptions,+ WeakView, WindowBounds, WindowKind, WindowOptions,+};pub use only_instance::*;pub use open_listener::*;