Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Rename `SharedUrl` to `SharedUri` (#7084)
Marshall Bowers6c7893db35d5
diff --git a/crates/client/src/user.rs b/crates/client/src/user.rsindex 23cd97994f6..d6a60f5b4c6 100644--- a/crates/client/src/user.rs+++ b/crates/client/src/user.rs@@ -4,7 +4,7 @@ use collections::{hash_map::Entry, HashMap, HashSet};use feature_flags::FeatureFlagAppExt;use futures::{channel::mpsc, Future, StreamExt};use gpui::{- AppContext, AsyncAppContext, EventEmitter, Model, ModelContext, SharedString, SharedUrl, Task,+ AppContext, AsyncAppContext, EventEmitter, Model, ModelContext, SharedString, SharedUri, Task,WeakModel,};use postage::{sink::Sink, watch};@@ -22,7 +22,7 @@ pub struct ParticipantIndex(pub u32);pub struct User {pub id: UserId,pub github_login: String,- pub avatar_uri: SharedUrl,+ pub avatar_uri: SharedUri,}#[derive(Clone, Debug, PartialEq, Eq)]@@ -707,7 +707,7 @@ impl User {Arc::new(User {id: message.id,github_login: message.github_login,- avatar_uri: SharedUrl::network(message.avatar_url),+ avatar_uri: SharedUri::network(message.avatar_url),})}}diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rsindex 6dd1751c8c6..0d9a64e511d 100644--- a/crates/collab/src/tests/integration_tests.rs+++ b/crates/collab/src/tests/integration_tests.rs@@ -9,7 +9,7 @@ use fs::{repository::GitFileStatus, FakeFs, Fs as _, RemoveOptions};use futures::StreamExt as _;use gpui::{px, size, AppContext, BackgroundExecutor, Model, Modifiers, MouseButton, MouseDownEvent,- SharedUrl, TestAppContext,+ SharedUri, TestAppContext,};use language::{language_settings::{AllLanguageSettings, Formatter},@@ -1828,7 +1828,7 @@ async fn test_active_call_events(owner: Arc::new(User {id: client_a.user_id().unwrap(),github_login: "user_a".to_string(),- avatar_uri: SharedUrl::network("avatar_a"),+ avatar_uri: SharedUri::network("avatar_a"),}),project_id: project_a_id,worktree_root_names: vec!["a".to_string()],@@ -1846,7 +1846,7 @@ async fn test_active_call_events(owner: Arc::new(User {id: client_b.user_id().unwrap(),github_login: "user_b".to_string(),- avatar_uri: SharedUrl::network("avatar_b"),+ avatar_uri: SharedUri::network("avatar_b"),}),project_id: project_b_id,worktree_root_names: vec!["b".to_string()]diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rsindex 14fab4301b4..879ff67d63b 100644--- a/crates/collab_ui/src/chat_panel.rs+++ b/crates/collab_ui/src/chat_panel.rs@@ -714,7 +714,7 @@ fn format_timestamp(#[cfg(test)]mod tests {use super::*;- use gpui::{HighlightStyle, SharedUrl};+ use gpui::{HighlightStyle, SharedUri};use pretty_assertions::assert_eq;use rich_text::Highlight;use time::{Date, OffsetDateTime, Time, UtcOffset};@@ -730,7 +730,7 @@ mod tests {timestamp: OffsetDateTime::now_utc(),sender: Arc::new(client::User {github_login: "fgh".into(),- avatar_uri: SharedUrl::network("avatar_fgh"),+ avatar_uri: SharedUri::network("avatar_fgh"),id: 103,}),nonce: 5,diff --git a/crates/collab_ui/src/chat_panel/message_editor.rs b/crates/collab_ui/src/chat_panel/message_editor.rsindex 48cf4ab4051..701ecd8e8e1 100644--- a/crates/collab_ui/src/chat_panel/message_editor.rs+++ b/crates/collab_ui/src/chat_panel/message_editor.rs@@ -365,7 +365,7 @@ impl Render for MessageEditor {mod tests {use super::*;use client::{Client, User, UserStore};- use gpui::{SharedUrl, TestAppContext};+ use gpui::{SharedUri, TestAppContext};use language::{Language, LanguageConfig};use rpc::proto;use settings::SettingsStore;@@ -392,7 +392,7 @@ mod tests {user: Arc::new(User {github_login: "a-b".into(),id: 101,- avatar_uri: SharedUrl::network("avatar_a-b"),+ avatar_uri: SharedUri::network("avatar_a-b"),}),kind: proto::channel_member::Kind::Member,role: proto::ChannelRole::Member,@@ -401,7 +401,7 @@ mod tests {user: Arc::new(User {github_login: "C_D".into(),id: 102,- avatar_uri: SharedUrl::network("avatar_C_D"),+ avatar_uri: SharedUri::network("avatar_C_D"),}),kind: proto::channel_member::Kind::Member,role: proto::ChannelRole::Member,diff --git a/crates/collab_ui/src/notifications/collab_notification.rs b/crates/collab_ui/src/notifications/collab_notification.rsindex 69d26e50fd3..97b7100106b 100644--- a/crates/collab_ui/src/notifications/collab_notification.rs+++ b/crates/collab_ui/src/notifications/collab_notification.rs@@ -1,10 +1,10 @@-use gpui::{img, prelude::*, AnyElement, SharedUrl};+use gpui::{img, prelude::*, AnyElement, SharedUri};use smallvec::SmallVec;use ui::prelude::*;#[derive(IntoElement)]pub struct CollabNotification {- avatar_uri: SharedUrl,+ avatar_uri: SharedUri,accept_button: Button,dismiss_button: Button,children: SmallVec<[AnyElement; 2]>,@@ -12,7 +12,7 @@ pub struct CollabNotification {impl CollabNotification {pub fn new(- avatar_uri: impl Into<SharedUrl>,+ avatar_uri: impl Into<SharedUri>,accept_button: Button,dismiss_button: Button,) -> Self {diff --git a/crates/collab_ui/src/notifications/stories/collab_notification.rs b/crates/collab_ui/src/notifications/stories/collab_notification.rsindex e04a7b39047..55700ca6f09 100644--- a/crates/collab_ui/src/notifications/stories/collab_notification.rs+++ b/crates/collab_ui/src/notifications/stories/collab_notification.rs@@ -1,4 +1,4 @@-use gpui::{prelude::*, SharedUrl};+use gpui::{prelude::*, SharedUri};use story::{StoryContainer, StoryItem, StorySection};use ui::prelude::*;@@ -19,7 +19,7 @@ impl Render for CollabNotificationStory {"Incoming Call Notification",window_container(400., 72.).child(CollabNotification::new(- SharedUrl::network("https://avatars.githubusercontent.com/u/1486634?v=4"),+ SharedUri::network("https://avatars.githubusercontent.com/u/1486634?v=4"),Button::new("accept", "Accept"),Button::new("decline", "Decline"),)@@ -36,7 +36,7 @@ impl Render for CollabNotificationStory {"Project Shared Notification",window_container(400., 72.).child(CollabNotification::new(- SharedUrl::network("https://avatars.githubusercontent.com/u/1714999?v=4"),+ SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4"),Button::new("open", "Open"),Button::new("dismiss", "Dismiss"),)diff --git a/crates/gpui/examples/image.rs b/crates/gpui/examples/image.rsindex 01a9cfb435b..f0bb371badd 100644--- a/crates/gpui/examples/image.rs+++ b/crates/gpui/examples/image.rs@@ -3,7 +3,7 @@ use gpui::*;#[derive(IntoElement)]struct ImageFromResource {text: SharedString,- resource: SharedUrl,+ resource: SharedUri,}impl RenderOnce for ImageFromResource {@@ -20,8 +20,8 @@ impl RenderOnce for ImageFromResource {}struct ImageShowcase {- local_resource: SharedUrl,- remote_resource: SharedUrl,+ local_resource: SharedUri,+ remote_resource: SharedUri,}impl Render for ImageShowcase {@@ -51,8 +51,8 @@ fn main() {App::new().run(|cx: &mut AppContext| {cx.open_window(WindowOptions::default(), |cx| {cx.new_view(|_cx| ImageShowcase {- local_resource: SharedUrl::file("../zed/resources/app-icon.png"),- remote_resource: SharedUrl::network("https://picsum.photos/512/512"),+ local_resource: SharedUri::file("../zed/resources/app-icon.png"),+ remote_resource: SharedUri::network("https://picsum.photos/512/512"),})});});diff --git a/crates/gpui/src/elements/img.rs b/crates/gpui/src/elements/img.rsindex d1455d33d63..00804fe565f 100644--- a/crates/gpui/src/elements/img.rs+++ b/crates/gpui/src/elements/img.rs@@ -2,7 +2,7 @@ use std::sync::Arc;use crate::{point, size, Bounds, DevicePixels, Element, ElementContext, ImageData, InteractiveElement,- InteractiveElementState, Interactivity, IntoElement, LayoutId, Pixels, SharedUrl, Size,+ InteractiveElementState, Interactivity, IntoElement, LayoutId, Pixels, SharedUri, Size,StyleRefinement, Styled,};use futures::FutureExt;@@ -13,7 +13,7 @@ use util::ResultExt;#[derive(Clone, Debug)]pub enum ImageSource {/// Image content will be loaded from provided URI at render time.- Uri(SharedUrl),+ Uri(SharedUri),/// Cached image dataData(Arc<ImageData>),// TODO: move surface definitions into mac platform module@@ -21,8 +21,8 @@ pub enum ImageSource {Surface(CVImageBuffer),}-impl From<SharedUrl> for ImageSource {- fn from(value: SharedUrl) -> Self {+impl From<SharedUri> for ImageSource {+ fn from(value: SharedUri) -> Self {Self::Uri(value)}}diff --git a/crates/gpui/src/gpui.rs b/crates/gpui/src/gpui.rsindex 638e94de396..36674b52bf6 100644--- a/crates/gpui/src/gpui.rs+++ b/crates/gpui/src/gpui.rs@@ -83,7 +83,7 @@ mod platform;pub mod prelude;mod scene;mod shared_string;-mod shared_url;+mod shared_uri;mod style;mod styled;mod subscription;@@ -133,7 +133,7 @@ pub use refineable::*;pub use scene::*;use seal::Sealed;pub use shared_string::*;-pub use shared_url::*;+pub use shared_uri::*;pub use smol::Timer;pub use style::*;pub use styled::*;diff --git a/crates/gpui/src/image_cache.rs b/crates/gpui/src/image_cache.rsindex 318aea8265b..3c9a1741edf 100644--- a/crates/gpui/src/image_cache.rs+++ b/crates/gpui/src/image_cache.rs@@ -1,4 +1,4 @@-use crate::{AppContext, ImageData, ImageId, SharedUrl, Task};+use crate::{AppContext, ImageData, ImageId, SharedUri, Task};use collections::HashMap;use futures::{future::Shared, AsyncReadExt, FutureExt, TryFutureExt};use image::ImageError;@@ -41,7 +41,7 @@ impl From<ImageError> for Error {pub(crate) struct ImageCache {client: Arc<dyn HttpClient>,- images: Arc<Mutex<HashMap<SharedUrl, FetchImageTask>>>,+ images: Arc<Mutex<HashMap<SharedUri, FetchImageTask>>>,}type FetchImageTask = Shared<Task<Result<Arc<ImageData>, Error>>>;@@ -54,7 +54,7 @@ impl ImageCache {}}- pub fn get(&self, uri: impl Into<SharedUrl>, cx: &AppContext) -> FetchImageTask {+ pub fn get(&self, uri: impl Into<SharedUri>, cx: &AppContext) -> FetchImageTask {let uri = uri.into();let mut images = self.images.lock();@@ -69,11 +69,11 @@ impl ImageCache {let uri = uri.clone();async move {match uri {- SharedUrl::File(uri) => {+ SharedUri::File(uri) => {let image = image::open(uri.as_ref())?.into_bgra8();Ok(Arc::new(ImageData::new(image)))}- SharedUrl::Network(uri) => {+ SharedUri::Network(uri) => {let mut response =client.get(uri.as_ref(), ().into(), true).await?;let mut body = Vec::new();diff --git a/crates/gpui/src/shared_url.rs b/crates/gpui/src/shared_uri.rssimilarity index 75%rename from crates/gpui/src/shared_url.rsrename to crates/gpui/src/shared_uri.rsindex d4194823917..0784ea87ff3 100644--- a/crates/gpui/src/shared_url.rs+++ b/crates/gpui/src/shared_uri.rs@@ -2,34 +2,34 @@ use std::ops::{Deref, DerefMut};use crate::SharedString;-/// A URL stored in a `SharedString` pointing to a file or a remote resource.+/// A URI stored in a [`SharedString`].#[derive(PartialEq, Eq, Hash, Clone)]-pub enum SharedUrl {+pub enum SharedUri {/// A path to a local file.File(SharedString),/// A URL to a remote resource.Network(SharedString),}-impl SharedUrl {- /// Create a URL pointing to a local file.+impl SharedUri {+ /// Creates a [`SharedUri`] pointing to a local file.pub fn file<S: Into<SharedString>>(s: S) -> Self {Self::File(s.into())}- /// Create a URL pointing to a remote resource.+ /// Creates a [`SharedUri`] pointing to a remote resource.pub fn network<S: Into<SharedString>>(s: S) -> Self {Self::Network(s.into())}}-impl Default for SharedUrl {+impl Default for SharedUri {fn default() -> Self {Self::Network(SharedString::default())}}-impl Deref for SharedUrl {+impl Deref for SharedUri {type Target = SharedString;fn deref(&self) -> &Self::Target {@@ -40,7 +40,7 @@ impl Deref for SharedUrl {}}-impl DerefMut for SharedUrl {+impl DerefMut for SharedUri {fn deref_mut(&mut self) -> &mut Self::Target {match self {Self::File(s) => s,@@ -49,7 +49,7 @@ impl DerefMut for SharedUrl {}}-impl std::fmt::Debug for SharedUrl {+impl std::fmt::Debug for SharedUri {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {match self {Self::File(s) => write!(f, "File({:?})", s),@@ -58,7 +58,7 @@ impl std::fmt::Debug for SharedUrl {}}-impl std::fmt::Display for SharedUrl {+impl std::fmt::Display for SharedUri {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {write!(f, "{}", self.as_ref())}diff --git a/crates/theme/src/styles/stories/players.rs b/crates/theme/src/styles/stories/players.rsindex 8963736e61b..e9462cbbbb1 100644--- a/crates/theme/src/styles/stories/players.rs+++ b/crates/theme/src/styles/stories/players.rs@@ -1,4 +1,4 @@-use gpui::{div, img, px, IntoElement, ParentElement, Render, SharedUrl, Styled, ViewContext};+use gpui::{div, img, px, IntoElement, ParentElement, Render, SharedUri, Styled, ViewContext};use story::Story;use crate::{ActiveTheme, PlayerColors};@@ -53,7 +53,7 @@ impl Render for PlayerStory {.border_2().border_color(player.cursor).child(- img(SharedUrl::network(+ img(SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4",)).rounded_full()@@ -84,7 +84,7 @@ impl Render for PlayerStory {.border_color(player.background).size(px(28.)).child(- img(SharedUrl::network(+ img(SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4",)).rounded_full()@@ -102,7 +102,7 @@ impl Render for PlayerStory {.border_color(player.background).size(px(28.)).child(- img(SharedUrl::network(+ img(SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4",)).rounded_full()@@ -120,7 +120,7 @@ impl Render for PlayerStory {.border_color(player.background).size(px(28.)).child(- img(SharedUrl::network(+ img(SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4",)).rounded_full()diff --git a/crates/ui/src/components/stories/avatar.rs b/crates/ui/src/components/stories/avatar.rsindex 5820d2b8c9c..6a8f70a3181 100644--- a/crates/ui/src/components/stories/avatar.rs+++ b/crates/ui/src/components/stories/avatar.rs@@ -1,4 +1,4 @@-use gpui::{Render, SharedUrl};+use gpui::{Render, SharedUri};use story::{StoryContainer, StoryItem, StorySection};use crate::{prelude::*, AudioStatus, Availability, AvatarAvailabilityIndicator};@@ -13,13 +13,13 @@ impl Render for AvatarStory {StorySection::new().child(StoryItem::new("Default",- Avatar::new(SharedUrl::network(+ Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4",)),)).child(StoryItem::new("Default",- Avatar::new(SharedUrl::network(+ Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/326587?v=4",)),)),@@ -28,14 +28,14 @@ impl Render for AvatarStory {StorySection::new().child(StoryItem::new("With free availability indicator",- Avatar::new(SharedUrl::network(+ Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/326587?v=4",)).indicator(AvatarAvailabilityIndicator::new(Availability::Free)),)).child(StoryItem::new("With busy availability indicator",- Avatar::new(SharedUrl::network(+ Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/326587?v=4",)).indicator(AvatarAvailabilityIndicator::new(Availability::Busy)),@@ -45,14 +45,14 @@ impl Render for AvatarStory {StorySection::new().child(StoryItem::new("With info border",- Avatar::new(SharedUrl::network(+ Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/326587?v=4",)).border_color(cx.theme().status().info_border),)).child(StoryItem::new("With error border",- Avatar::new(SharedUrl::network(+ Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/326587?v=4",)).border_color(cx.theme().status().error_border),@@ -62,14 +62,14 @@ impl Render for AvatarStory {StorySection::new().child(StoryItem::new("With muted audio indicator",- Avatar::new(SharedUrl::network(+ Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/326587?v=4",)).indicator(AvatarAudioStatusIndicator::new(AudioStatus::Muted)),)).child(StoryItem::new("With deafened audio indicator",- Avatar::new(SharedUrl::network(+ Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/326587?v=4",)).indicator(AvatarAudioStatusIndicator::new(AudioStatus::Deafened)),diff --git a/crates/ui/src/components/stories/list_item.rs b/crates/ui/src/components/stories/list_item.rsindex 014b56b422f..b0bf579fc59 100644--- a/crates/ui/src/components/stories/list_item.rs+++ b/crates/ui/src/components/stories/list_item.rs@@ -1,4 +1,4 @@-use gpui::{Render, SharedUrl};+use gpui::{Render, SharedUri};use story::Story;use crate::{prelude::*, Avatar};@@ -45,7 +45,7 @@ impl Render for ListItemStory {.child(ListItem::new("with_start slot avatar").child("Hello, world!")- .start_slot(Avatar::new(SharedUrl::network(+ .start_slot(Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4",))),)@@ -53,7 +53,7 @@ impl Render for ListItemStory {.child(ListItem::new("with_left_avatar").child("Hello, world!")- .end_slot(Avatar::new(SharedUrl::network(+ .end_slot(Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4",))),)@@ -64,23 +64,23 @@ impl Render for ListItemStory {.end_slot(h_flex().gap_2()- .child(Avatar::new(SharedUrl::network(+ .child(Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/1789?v=4",)))- .child(Avatar::new(SharedUrl::network(+ .child(Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/1789?v=4",)))- .child(Avatar::new(SharedUrl::network(+ .child(Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/1789?v=4",)))- .child(Avatar::new(SharedUrl::network(+ .child(Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/1789?v=4",)))- .child(Avatar::new(SharedUrl::network(+ .child(Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/1789?v=4",))),)- .end_hover_slot(Avatar::new(SharedUrl::network(+ .end_hover_slot(Avatar::new(SharedUri::network("https://avatars.githubusercontent.com/u/1714999?v=4",))),)