remove_server: Add function to delete wsl project (#40105)

As title say, could delete wsl project in `open remote` delegate.

Release Notes:

- Added ability to delete wsl projects from remote picker
This commit is contained in:
CharlesChen0823
2025-10-13 17:19:39 +02:00
committed by GitHub
parent e7b19ab0b1
commit 46fff9979d
+53 -25
View File
@@ -1281,31 +1281,25 @@ impl RemoteServerProjects {
let secondary_confirm = e.modifiers().platform;
callback(this, secondary_confirm, window, cx)
}))
.when(
is_from_zed && matches!(server_ix, ServerIndex::Ssh(_)),
|server_list_item| {
let ServerIndex::Ssh(server_ix) = server_ix else {
unreachable!()
};
server_list_item.end_hover_slot::<AnyElement>(Some(
div()
.mr_2()
.child({
let project = project.clone();
// Right-margin to offset it from the Scrollbar
IconButton::new("remove-remote-project", IconName::Trash)
.icon_size(IconSize::Small)
.shape(IconButtonShape::Square)
.size(ButtonSize::Large)
.tooltip(Tooltip::text("Delete Remote Project"))
.on_click(cx.listener(move |this, _, _, cx| {
this.delete_ssh_project(server_ix, &project, cx)
}))
})
.into_any_element(),
))
},
),
.when(is_from_zed, |server_list_item| {
server_list_item.end_hover_slot::<AnyElement>(Some(
div()
.mr_2()
.child({
let project = project.clone();
// Right-margin to offset it from the Scrollbar
IconButton::new("remove-remote-project", IconName::Trash)
.icon_size(IconSize::Small)
.shape(IconButtonShape::Square)
.size(ButtonSize::Large)
.tooltip(Tooltip::text("Delete Remote Project"))
.on_click(cx.listener(move |this, _, _, cx| {
this.delete_remote_project(server_ix, &project, cx)
}))
})
.into_any_element(),
))
}),
)
}
@@ -1332,6 +1326,22 @@ impl RemoteServerProjects {
});
}
fn delete_remote_project(
&mut self,
server: ServerIndex,
project: &SshProject,
cx: &mut Context<Self>,
) {
match server {
ServerIndex::Ssh(server) => {
self.delete_ssh_project(server, project, cx);
}
ServerIndex::Wsl(server) => {
self.delete_wsl_project(server, project, cx);
}
}
}
fn delete_ssh_project(
&mut self,
server: SshServerIndex,
@@ -1350,6 +1360,24 @@ impl RemoteServerProjects {
});
}
fn delete_wsl_project(
&mut self,
server: WslServerIndex,
project: &SshProject,
cx: &mut Context<Self>,
) {
let project = project.clone();
self.update_settings_file(cx, move |setting, _| {
if let Some(server) = setting
.wsl_connections
.as_mut()
.and_then(|connections| connections.get_mut(server.0))
{
server.projects.remove(&project);
}
});
}
#[cfg(target_os = "windows")]
fn add_wsl_distro(
&mut self,