ssh remoting: Fix cmd-o (#18308)
Release Notes: - ssh-remoting: Cmd-O now correctly opens files on the remote host --------- Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
fdb03d3058
commit
d33600525e
15 changed files with 80 additions and 87 deletions
|
@ -487,7 +487,7 @@ impl DirectoryLister {
|
|||
pub fn is_local(&self, cx: &AppContext) -> bool {
|
||||
match self {
|
||||
DirectoryLister::Local(_) => true,
|
||||
DirectoryLister::Project(project) => project.read(cx).is_local_or_ssh(),
|
||||
DirectoryLister::Project(project) => project.read(cx).is_local(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1199,7 +1199,13 @@ impl Project {
|
|||
self.dev_server_project_id
|
||||
}
|
||||
|
||||
pub fn supports_remote_terminal(&self, cx: &AppContext) -> bool {
|
||||
pub fn supports_terminal(&self, cx: &AppContext) -> bool {
|
||||
if self.is_local() {
|
||||
return true;
|
||||
}
|
||||
if self.is_via_ssh() {
|
||||
return true;
|
||||
}
|
||||
let Some(id) = self.dev_server_project_id else {
|
||||
return false;
|
||||
};
|
||||
|
@ -1213,10 +1219,6 @@ impl Project {
|
|||
}
|
||||
|
||||
pub fn ssh_connection_string(&self, cx: &ModelContext<Self>) -> Option<SharedString> {
|
||||
if self.is_local_or_ssh() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let dev_server_id = self.dev_server_project_id()?;
|
||||
dev_server_projects::Store::global(cx)
|
||||
.read(cx)
|
||||
|
@ -1643,13 +1645,6 @@ impl Project {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_local_or_ssh(&self) -> bool {
|
||||
match &self.client_state {
|
||||
ProjectClientState::Local | ProjectClientState::Shared { .. } => true,
|
||||
ProjectClientState::Remote { .. } => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_via_ssh(&self) -> bool {
|
||||
match &self.client_state {
|
||||
ProjectClientState::Local | ProjectClientState::Shared { .. } => {
|
||||
|
@ -1735,7 +1730,7 @@ impl Project {
|
|||
) -> Task<Result<Model<Buffer>>> {
|
||||
if let Some(buffer) = self.buffer_for_id(id, cx) {
|
||||
Task::ready(Ok(buffer))
|
||||
} else if self.is_local_or_ssh() {
|
||||
} else if self.is_local() || self.is_via_ssh() {
|
||||
Task::ready(Err(anyhow!("buffer {} does not exist", id)))
|
||||
} else if let Some(project_id) = self.remote_id() {
|
||||
let request = self.client.request(proto::OpenBufferById {
|
||||
|
@ -1857,7 +1852,7 @@ impl Project {
|
|||
let mut changes = rx.ready_chunks(MAX_BATCH_SIZE);
|
||||
|
||||
while let Some(changes) = changes.next().await {
|
||||
let is_local = this.update(&mut cx, |this, _| this.is_local_or_ssh())?;
|
||||
let is_local = this.update(&mut cx, |this, _| this.is_local())?;
|
||||
|
||||
for change in changes {
|
||||
match change {
|
||||
|
@ -2001,7 +1996,7 @@ impl Project {
|
|||
language_server_id,
|
||||
message,
|
||||
} => {
|
||||
if self.is_local_or_ssh() {
|
||||
if self.is_local() {
|
||||
self.enqueue_buffer_ordered_message(
|
||||
BufferOrderedMessage::LanguageServerUpdate {
|
||||
language_server_id: *language_server_id,
|
||||
|
@ -3039,8 +3034,19 @@ impl Project {
|
|||
query: String,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<Vec<PathBuf>>> {
|
||||
if self.is_local_or_ssh() {
|
||||
if self.is_local() {
|
||||
DirectoryLister::Local(self.fs.clone()).list_directory(query, cx)
|
||||
} else if let Some(session) = self.ssh_session.as_ref() {
|
||||
let request = proto::ListRemoteDirectory {
|
||||
dev_server_id: SSH_PROJECT_ID,
|
||||
path: query,
|
||||
};
|
||||
|
||||
let response = session.request(request);
|
||||
cx.background_executor().spawn(async move {
|
||||
let response = response.await?;
|
||||
Ok(response.entries.into_iter().map(PathBuf::from).collect())
|
||||
})
|
||||
} else if let Some(dev_server) = self.dev_server_project_id().and_then(|id| {
|
||||
dev_server_projects::Store::global(cx)
|
||||
.read(cx)
|
||||
|
@ -3317,7 +3323,7 @@ impl Project {
|
|||
mut cx: AsyncAppContext,
|
||||
) -> Result<()> {
|
||||
this.update(&mut cx, |this, cx| {
|
||||
if this.is_local_or_ssh() {
|
||||
if this.is_local() || this.is_via_ssh() {
|
||||
this.unshare(cx)?;
|
||||
} else {
|
||||
this.disconnected_from_host(cx);
|
||||
|
@ -3995,7 +4001,7 @@ impl Project {
|
|||
location: Location,
|
||||
cx: &mut ModelContext<'_, Project>,
|
||||
) -> Task<Option<TaskContext>> {
|
||||
if self.is_local_or_ssh() {
|
||||
if self.is_local() {
|
||||
let (worktree_id, worktree_abs_path) = if let Some(worktree) = self.task_worktree(cx) {
|
||||
(
|
||||
Some(worktree.read(cx).id()),
|
||||
|
@ -4081,7 +4087,7 @@ impl Project {
|
|||
location: Option<Location>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<Vec<(TaskSourceKind, TaskTemplate)>>> {
|
||||
if self.is_local_or_ssh() {
|
||||
if self.is_local() {
|
||||
let (file, language) = location
|
||||
.map(|location| {
|
||||
let buffer = location.buffer.read(cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue