Skip to content

armgit / zed

Public Imported from GitHub
0

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 randomized-tests-operation-script

Antonio Scandurra016343e65d0a
diff --cc crates/client/src/client.rs
index f405c14a18c,b9bf449149f..ce808cd08d6
--- a/crates/client/src/client.rs
+++ b/crates/client/src/client.rs
@@@ -10,15 -10,13 +10,16 @@@ use async_tungstenite::tungstenite::
error::Error as WebsocketError,
http::{Request, StatusCode},
};
-use futures::{future::LocalBoxFuture, AsyncReadExt, FutureExt, SinkExt, StreamExt, TryStreamExt};
+use futures::{
+ future::LocalBoxFuture, AsyncReadExt, FutureExt, SinkExt, StreamExt, TryFutureExt as _,
+ TryStreamExt,
+};
use gpui::{
actions,
+ platform::AppVersion,
serde_json::{self, Value},
- AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AppContext, AppVersion,
- AsyncAppContext, Entity, ModelHandle, MutableAppContext, Task, View, ViewContext, ViewHandle,
+ AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AppContext,
+ AsyncAppContext, Entity, ModelHandle, Task, View, ViewContext, ViewHandle,
};
use lazy_static::lazy_static;
use parking_lot::RwLock;
diff --cc crates/gpui/src/app/test_app_context.rs
index 44db595ef7d,ac2f5408db5..ff94aa61405
--- a/crates/gpui/src/app/test_app_context.rs
+++ b/crates/gpui/src/app/test_app_context.rs
@@@ -29,9 -32,8 +32,9 @@@ use super::
ref_counts::LeakDetector, window_input_handler::WindowInputHandler, AsyncAppContext, RefCounts,
};
+#[derive(Clone)]
pub struct TestAppContext {
- cx: Rc<RefCell<MutableAppContext>>,
+ cx: Rc<RefCell<AppContext>>,
foreground_platform: Rc<platform::test::ForegroundPlatform>,
condition_duration: Option<Duration>,
pub function_name: String,
diff --cc crates/project/src/lsp_command.rs
index dcc462546f2,feec1ee0e4c..27c87125061
--- a/crates/project/src/lsp_command.rs
+++ b/crates/project/src/lsp_command.rs
@@@ -49,7 -49,7 +49,7 @@@ pub(crate) trait LspCommand: 'static +
project: &mut Project,
peer_id: PeerId,
buffer_version: &clock::Global,
- cx: &mut MutableAppContext,
- cx: &AppContext,
++ cx: &mut AppContext,
) -> <Self::ProtoRequest as proto::RequestMessage>::Response;
async fn response_from_proto(
self,
@@@ -175,7 -175,7 +175,7 @@@ impl LspCommand for PrepareRename
_: &mut Project,
_: PeerId,
buffer_version: &clock::Global,
- _: &mut MutableAppContext,
- _: &AppContext,
++ _: &mut AppContext,
) -> proto::PrepareRenameResponse {
proto::PrepareRenameResponse {
can_rename: range.is_some(),
@@@ -296,7 -296,7 +296,7 @@@ impl LspCommand for PerformRename
project: &mut Project,
peer_id: PeerId,
_: &clock::Global,
- cx: &mut MutableAppContext,
- cx: &AppContext,
++ cx: &mut AppContext,
) -> proto::PerformRenameResponse {
let transaction = project.serialize_project_transaction_for_peer(response, peer_id, cx);
proto::PerformRenameResponse {
@@@ -391,7 -391,7 +391,7 @@@ impl LspCommand for GetDefinition
project: &mut Project,
peer_id: PeerId,
_: &clock::Global,
- cx: &mut MutableAppContext,
- cx: &AppContext,
++ cx: &mut AppContext,
) -> proto::GetDefinitionResponse {
let links = location_links_to_proto(response, project, peer_id, cx);
proto::GetDefinitionResponse { links }
@@@ -477,7 -477,7 +477,7 @@@ impl LspCommand for GetTypeDefinition
project: &mut Project,
peer_id: PeerId,
_: &clock::Global,
- cx: &mut MutableAppContext,
- cx: &AppContext,
++ cx: &mut AppContext,
) -> proto::GetTypeDefinitionResponse {
let links = location_links_to_proto(response, project, peer_id, cx);
proto::GetTypeDefinitionResponse { links }
@@@ -658,7 -658,7 +658,7 @@@ fn location_links_to_proto
links: Vec<LocationLink>,
project: &mut Project,
peer_id: PeerId,
- cx: &mut MutableAppContext,
- cx: &AppContext,
++ cx: &mut AppContext,
) -> Vec<proto::LocationLink> {
links
.into_iter()
@@@ -787,7 -787,7 +787,7 @@@ impl LspCommand for GetReferences
project: &mut Project,
peer_id: PeerId,
_: &clock::Global,
- cx: &mut MutableAppContext,
- cx: &AppContext,
++ cx: &mut AppContext,
) -> proto::GetReferencesResponse {
let locations = response
.into_iter()
@@@ -928,7 -928,7 +928,7 @@@ impl LspCommand for GetDocumentHighligh
_: &mut Project,
_: PeerId,
_: &clock::Global,
- _: &mut MutableAppContext,
- _: &AppContext,
++ _: &mut AppContext,
) -> proto::GetDocumentHighlightsResponse {
let highlights = response
.into_iter()
@@@ -1130,7 -1130,7 +1130,7 @@@ impl LspCommand for GetHover
_: &mut Project,
_: PeerId,
_: &clock::Global,
- _: &mut MutableAppContext,
- _: &AppContext,
++ _: &mut AppContext,
) -> proto::GetHoverResponse {
if let Some(response) = response {
let (start, end) = if let Some(range) = response.range {
diff --cc crates/project/src/project.rs
index fd10e17bbf5,0fa7d0a63d1..6a8bbb98d29
--- a/crates/project/src/project.rs
+++ b/crates/project/src/project.rs
@@@ -427,47 -414,40 +427,47 @@@ impl Project
user_store: ModelHandle<UserStore>,
languages: Arc<LanguageRegistry>,
fs: Arc<dyn Fs>,
- cx: &mut MutableAppContext,
+ cx: &mut AppContext,
) -> ModelHandle<Self> {
- cx.add_model(|cx: &mut ModelContext<Self>| Self {
- worktrees: Default::default(),
- collaborators: Default::default(),
- opened_buffers: Default::default(),
- shared_buffers: Default::default(),
- incomplete_remote_buffers: Default::default(),
- loading_buffers_by_path: Default::default(),
- loading_local_worktrees: Default::default(),
- buffer_snapshots: Default::default(),
- client_state: None,
- opened_buffer: watch::channel(),
- client_subscriptions: Vec::new(),
- _subscriptions: vec![cx.observe_global::<Settings, _>(Self::on_settings_changed)],
- _maintain_buffer_languages: Self::maintain_buffer_languages(&languages, cx),
- _maintain_workspace_config: Self::maintain_workspace_config(languages.clone(), cx),
- active_entry: None,
- languages,
- client,
- user_store,
- fs,
- next_entry_id: Default::default(),
- next_diagnostic_group_id: Default::default(),
- language_servers: Default::default(),
- language_server_ids: Default::default(),
- language_server_statuses: Default::default(),
- last_workspace_edits_by_language_server: Default::default(),
- buffers_being_formatted: Default::default(),
- next_language_server_id: 0,
- nonce: StdRng::from_entropy().gen(),
- terminals: Terminals {
- local_handles: Vec::new(),
- },
+ cx.add_model(|cx: &mut ModelContext<Self>| {
+ let (tx, rx) = mpsc::unbounded();
+ cx.spawn_weak(|this, cx| Self::send_buffer_messages(this, rx, cx))
+ .detach();
+ Self {
+ worktrees: Default::default(),
+ buffer_changes_tx: tx,
+ collaborators: Default::default(),
+ opened_buffers: Default::default(),
+ shared_buffers: Default::default(),
+ incomplete_remote_buffers: Default::default(),
+ loading_buffers_by_path: Default::default(),
+ loading_local_worktrees: Default::default(),
+ buffer_snapshots: Default::default(),
+ join_project_response_message_id: 0,
+ client_state: None,
+ opened_buffer: watch::channel(),
+ client_subscriptions: Vec::new(),
+ _subscriptions: vec![cx.observe_global::<Settings, _>(Self::on_settings_changed)],
+ _maintain_buffer_languages: Self::maintain_buffer_languages(&languages, cx),
+ _maintain_workspace_config: Self::maintain_workspace_config(languages.clone(), cx),
+ active_entry: None,
+ languages,
+ client,
+ user_store,
+ fs,
+ next_entry_id: Default::default(),
+ next_diagnostic_group_id: Default::default(),
+ language_servers: Default::default(),
+ language_server_ids: Default::default(),
+ language_server_statuses: Default::default(),
+ last_workspace_edits_by_language_server: Default::default(),
+ buffers_being_formatted: Default::default(),
+ next_language_server_id: 0,
+ nonce: StdRng::from_entropy().gen(),
+ terminals: Terminals {
+ local_handles: Vec::new(),
+ },
+ }
})
}
@@@ -5902,7 -5858,7 +5902,7 @@@
&mut self,
project_transaction: ProjectTransaction,
peer_id: proto::PeerId,
- cx: &mut MutableAppContext,
- cx: &AppContext,
++ cx: &mut AppContext,
) -> proto::ProjectTransaction {
let mut serialized_transaction = proto::ProjectTransaction {
buffer_ids: Default::default(),
@@@ -5960,7 -5916,7 +5960,7 @@@
&mut self,
buffer: &ModelHandle<Buffer>,
peer_id: proto::PeerId,
- cx: &mut MutableAppContext,
- cx: &AppContext,
++ cx: &mut AppContext,
) -> u64 {
let buffer_id = buffer.read(cx).remote_id();
if let Some(project_id) = self.remote_id() {