ssh remoting: Fix opening settings file (#19614)

We have to do `workspace.with_local_workspace`, otherwise we'll try to
open the settings on the remote host.


Release Notes:

- N/A
This commit is contained in:
Thorsten Ball 2024-10-23 16:56:39 +02:00 committed by GitHub
parent b85af0e533
commit e633f62eaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1093,17 +1093,27 @@ fn open_settings_file(
cx: &mut ViewContext<Workspace>, cx: &mut ViewContext<Workspace>,
) { ) {
cx.spawn(|workspace, mut cx| async move { cx.spawn(|workspace, mut cx| async move {
let (worktree_creation_task, settings_open_task) = let (worktree_creation_task, settings_open_task) = workspace
workspace.update(&mut cx, |workspace, cx| { .update(&mut cx, |workspace, cx| {
let worktree_creation_task = workspace.project().update(cx, |project, cx| { workspace.with_local_workspace(cx, move |workspace, cx| {
// Set up a dedicated worktree for settings, since otherwise we're dropping and re-starting LSP servers for each file inside on every settings file close/open let worktree_creation_task = workspace.project().update(cx, |project, cx| {
// TODO: Do note that all other external files (e.g. drag and drop from OS) still have their worktrees released on file close, causing LSP servers' restarts. // Set up a dedicated worktree for settings, since
project.find_or_create_worktree(paths::config_dir().as_path(), false, cx) // otherwise we're dropping and re-starting LSP servers
}); // for each file inside on every settings file
let settings_open_task = create_and_open_local_file(abs_path, cx, default_content); // close/open
(worktree_creation_task, settings_open_task)
})?;
// TODO: Do note that all other external files (e.g.
// drag and drop from OS) still have their worktrees
// released on file close, causing LSP servers'
// restarts.
project.find_or_create_worktree(paths::config_dir().as_path(), false, cx)
});
let settings_open_task =
create_and_open_local_file(abs_path, cx, default_content);
(worktree_creation_task, settings_open_task)
})
})?
.await?;
let _ = worktree_creation_task.await?; let _ = worktree_creation_task.await?;
let _ = settings_open_task.await?; let _ = settings_open_task.await?;
anyhow::Ok(()) anyhow::Ok(())