Skip to content

Commit 05c1fae

Browse files
committed
fix: don't add libraries in subdirectories to the main workspace
1 parent 0e11e22 commit 05c1fae

File tree

1 file changed

+9
-2
lines changed
  • crates/emmylua_code_analysis/src/db_index/module

1 file changed

+9
-2
lines changed

crates/emmylua_code_analysis/src/db_index/module/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,19 @@ impl LuaModuleIndex {
316316
if matched_module_path.is_none() {
317317
matched_module_path = Some((module_path, workspace.id));
318318
} else {
319-
let (matched, _) = match matched_module_path.as_ref() {
319+
let (matched, matched_workspace_id) = match matched_module_path.as_ref() {
320320
Some((matched, id)) => (matched, id),
321321
None => continue,
322322
};
323323
if module_path.len() < matched.len() {
324-
matched_module_path = Some((module_path, workspace.id));
324+
// Libraries could be in a subdirectory of the main workspace
325+
// In case of a conflict, we prioritise the non-main workspace ID
326+
let workspace_id = if workspace.id.is_main() {
327+
*matched_workspace_id
328+
} else {
329+
workspace.id
330+
};
331+
matched_module_path = Some((module_path, workspace_id));
325332
}
326333
}
327334
}

0 commit comments

Comments
 (0)