From 778ca84f854a11120dfa837ec413ab3aa1b0396d Mon Sep 17 00:00:00 2001 From: George Waters Date: Mon, 29 Sep 2025 12:08:47 -0400 Subject: [PATCH] Fix selecting and deleting user toolchains (#39068) I was trying to use the new user toolchains but every time I clicked on one I had added, it would delete it from the picker. Ironically, it wouldn't delete it permanently when I tried to by clicking on the trash can icon. Every time I reopened the workspace all user toolchains were there. Release Notes: - Fixed selecting and deleting user toolchains. --- crates/toolchain_selector/src/toolchain_selector.rs | 7 ++++--- crates/workspace/src/persistence.rs | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/toolchain_selector/src/toolchain_selector.rs b/crates/toolchain_selector/src/toolchain_selector.rs index d074dd7dce8695d66cfa1bb052bea5840efccd37..3ebf7670d34851949a55a85ba04cabb4f115bfbd 100644 --- a/crates/toolchain_selector/src/toolchain_selector.rs +++ b/crates/toolchain_selector/src/toolchain_selector.rs @@ -1047,8 +1047,8 @@ impl PickerDelegate for ToolchainSelectorDelegate { let toolchain = toolchain.clone(); let scope = scope.clone(); - this.end_slot(IconButton::new(id, IconName::Trash)) - .on_click(cx.listener(move |this, _, _, cx| { + this.end_slot(IconButton::new(id, IconName::Trash).on_click(cx.listener( + move |this, _, _, cx| { this.delegate.project.update(cx, |this, cx| { this.remove_toolchain(toolchain.clone(), scope.clone(), cx) }); @@ -1076,7 +1076,8 @@ impl PickerDelegate for ToolchainSelectorDelegate { } cx.stop_propagation(); cx.notify(); - })) + }, + ))) }), ) } diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index 9e729b07e7d751495f30c1efa4ab04a768ced1eb..655fdf47ba2f6a0d3e18a9ef470daf08252fb48b 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -997,6 +997,13 @@ impl WorkspaceDb { } } } + + conn.exec_bound( + sql!( + DELETE FROM user_toolchains WHERE workspace_id = ?1; + ) + )?(workspace.id).context("Clearing old user toolchains")?; + for (scope, toolchains) in workspace.user_toolchains { for toolchain in toolchains { let query = sql!(INSERT OR REPLACE INTO user_toolchains(remote_connection_id, workspace_id, worktree_id, relative_worktree_path, language_name, name, path, raw_json) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8));