Skip to content

Commit 6040378

Browse files
authored
Re-configure locators on every refresh (#127)
1 parent 817b4cb commit 6040378

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/pet/src/jsonrpc.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,11 @@ pub fn handle_refresh(context: Arc<Context>, id: u32, params: Value) {
178178
let mut search_scope = None;
179179

180180
// If search kind is provided and no search_paths, then we will only search in the global locations.
181-
config.executables = None; // This can only be provided in the refresh request.
182181
if refresh_options.search_kind.is_some() || refresh_options.search_paths.is_some() {
182+
// Always clear this, as we will either serach in specified folder or a specific kind in global locations.
183183
config.workspace_directories = None;
184184
if let Some(search_paths) = refresh_options.search_paths {
185+
// These workspace folders are only for this refresh.
185186
config.workspace_directories = Some(
186187
search_paths
187188
.iter()
@@ -201,6 +202,15 @@ pub fn handle_refresh(context: Arc<Context>, id: u32, params: Value) {
201202
config.executables = None;
202203
search_scope = Some(SearchScope::Global(search_kind));
203204
}
205+
206+
// Configure the locators with the modified config.
207+
for locator in context.locators.iter() {
208+
locator.configure(&config);
209+
}
210+
} else {
211+
// Re-configure the locators with an un-modified config.
212+
// Possible we congirued the locators with a modified config in the in the previous request.
213+
// & the config was scoped to a particular search folder, executables or kind.
204214
for locator in context.locators.iter() {
205215
locator.configure(&config);
206216
}

0 commit comments

Comments
 (0)