From c6a3693436153dd7b017bb47fe50931b1eec9579 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 18 Jul 2024 18:10:09 +1000 Subject: [PATCH 1/3] Reconfigure locators on every refresh --- crates/pet/src/jsonrpc.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/pet/src/jsonrpc.rs b/crates/pet/src/jsonrpc.rs index d3072f0b..8e22a12f 100644 --- a/crates/pet/src/jsonrpc.rs +++ b/crates/pet/src/jsonrpc.rs @@ -108,7 +108,8 @@ pub fn handle_configure(context: Arc, id: u32, params: Value) { // Start in a new thread, we can have multiple requests. thread::spawn(move || { let mut cfg = context.configuration.write().unwrap(); - cfg.workspace_directories = configure_options.workspace_directories; + cfg.workspace_directories = configure_options.workspace_directories.clone(); + cfg.old_workspace_directories = configure_options.workspace_directories; cfg.conda_executable = configure_options.conda_executable; cfg.environment_directories = configure_options.environment_directories; cfg.poetry_executable = configure_options.poetry_executable; @@ -178,10 +179,11 @@ pub fn handle_refresh(context: Arc, id: u32, params: Value) { let mut search_scope = None; // If search kind is provided and no search_paths, then we will only search in the global locations. - config.executables = None; // This can only be provided in the refresh request. if refresh_options.search_kind.is_some() || refresh_options.search_paths.is_some() { + // Always clear this, as we will either serach in specified folder or a specific kind in global locations. config.workspace_directories = None; if let Some(search_paths) = refresh_options.search_paths { + // These workspace folders are only for this refresh. config.workspace_directories = Some( search_paths .iter() @@ -201,6 +203,15 @@ pub fn handle_refresh(context: Arc, id: u32, params: Value) { config.executables = None; search_scope = Some(SearchScope::Global(search_kind)); } + + // Configure the locators with the modified config. + for locator in context.locators.iter() { + locator.configure(&config); + } + } else { + // Re-configure the locators with an un-modified config. + // Possible we congirued the locators with a modified config in the in the previous request. + // & the config was scoped to a particular search folder, executables or kind. for locator in context.locators.iter() { locator.configure(&config); } From 496482685ce2c171a3696d9d6f2f6d0a0ce4daa1 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 18 Jul 2024 18:10:33 +1000 Subject: [PATCH 2/3] oops --- crates/pet/src/jsonrpc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/pet/src/jsonrpc.rs b/crates/pet/src/jsonrpc.rs index 8e22a12f..c22cca78 100644 --- a/crates/pet/src/jsonrpc.rs +++ b/crates/pet/src/jsonrpc.rs @@ -109,7 +109,7 @@ pub fn handle_configure(context: Arc, id: u32, params: Value) { thread::spawn(move || { let mut cfg = context.configuration.write().unwrap(); cfg.workspace_directories = configure_options.workspace_directories.clone(); - cfg.old_workspace_directories = configure_options.workspace_directories; + cfg.conda_executable = configure_options.conda_executable; cfg.environment_directories = configure_options.environment_directories; cfg.poetry_executable = configure_options.poetry_executable; From 4914c8da7ffe5cd67b73f08fc9a8ca210d4bdac4 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 18 Jul 2024 18:11:06 +1000 Subject: [PATCH 3/3] oops --- crates/pet/src/jsonrpc.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/pet/src/jsonrpc.rs b/crates/pet/src/jsonrpc.rs index c22cca78..43563912 100644 --- a/crates/pet/src/jsonrpc.rs +++ b/crates/pet/src/jsonrpc.rs @@ -108,8 +108,7 @@ pub fn handle_configure(context: Arc, id: u32, params: Value) { // Start in a new thread, we can have multiple requests. thread::spawn(move || { let mut cfg = context.configuration.write().unwrap(); - cfg.workspace_directories = configure_options.workspace_directories.clone(); - + cfg.workspace_directories = configure_options.workspace_directories; cfg.conda_executable = configure_options.conda_executable; cfg.environment_directories = configure_options.environment_directories; cfg.poetry_executable = configure_options.poetry_executable;