Fix renames over language server for SSH remoting (#17897)
Release Notes: - ssh remoting: Fix rename over language server --------- Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Max <max@zed.dev>
This commit is contained in:
parent
01bb10f518
commit
e66ea9e5d4
34 changed files with 505 additions and 329 deletions
|
@ -1,10 +1,13 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use fs::Fs;
|
||||
use gpui::{AppContext, AsyncAppContext, Context, Model, ModelContext};
|
||||
use language::LanguageRegistry;
|
||||
use language::{proto::serialize_operation, Buffer, BufferEvent, LanguageRegistry};
|
||||
use project::{
|
||||
buffer_store::BufferStore, project_settings::SettingsObserver, search::SearchQuery,
|
||||
worktree_store::WorktreeStore, LspStore, ProjectPath, WorktreeId,
|
||||
buffer_store::{BufferStore, BufferStoreEvent},
|
||||
project_settings::SettingsObserver,
|
||||
search::SearchQuery,
|
||||
worktree_store::WorktreeStore,
|
||||
LspStore, ProjectPath, WorktreeId,
|
||||
};
|
||||
use remote::SshSession;
|
||||
use rpc::{
|
||||
|
@ -26,6 +29,7 @@ pub struct HeadlessProject {
|
|||
pub lsp_store: Model<LspStore>,
|
||||
pub settings_observer: Model<SettingsObserver>,
|
||||
pub next_entry_id: Arc<AtomicUsize>,
|
||||
pub languages: Arc<LanguageRegistry>,
|
||||
}
|
||||
|
||||
impl HeadlessProject {
|
||||
|
@ -60,7 +64,7 @@ impl HeadlessProject {
|
|||
buffer_store.clone(),
|
||||
worktree_store.clone(),
|
||||
environment,
|
||||
languages,
|
||||
languages.clone(),
|
||||
None,
|
||||
fs.clone(),
|
||||
cx,
|
||||
|
@ -69,6 +73,17 @@ impl HeadlessProject {
|
|||
lsp_store
|
||||
});
|
||||
|
||||
cx.subscribe(
|
||||
&buffer_store,
|
||||
|_this, _buffer_store, event, cx| match event {
|
||||
BufferStoreEvent::BufferAdded(buffer) => {
|
||||
cx.subscribe(buffer, Self::on_buffer_event).detach();
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
)
|
||||
.detach();
|
||||
|
||||
let client: AnyProtoClient = session.clone().into();
|
||||
|
||||
session.subscribe_to_entity(SSH_PROJECT_ID, &worktree_store);
|
||||
|
@ -103,6 +118,26 @@ impl HeadlessProject {
|
|||
buffer_store,
|
||||
lsp_store,
|
||||
next_entry_id: Default::default(),
|
||||
languages,
|
||||
}
|
||||
}
|
||||
|
||||
fn on_buffer_event(
|
||||
&mut self,
|
||||
buffer: Model<Buffer>,
|
||||
event: &BufferEvent,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
match event {
|
||||
BufferEvent::Operation(op) => cx
|
||||
.background_executor()
|
||||
.spawn(self.session.request(proto::UpdateBuffer {
|
||||
project_id: SSH_PROJECT_ID,
|
||||
buffer_id: buffer.read(cx).remote_id().to_proto(),
|
||||
operations: vec![serialize_operation(op)],
|
||||
}))
|
||||
.detach(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue