From 05c1fae13a5b8904d9760fc900a51d90c1854f80 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 5 Aug 2025 20:48:56 +0200 Subject: [PATCH] fix: don't add libraries in subdirectories to the main workspace --- .../emmylua_code_analysis/src/db_index/module/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/emmylua_code_analysis/src/db_index/module/mod.rs b/crates/emmylua_code_analysis/src/db_index/module/mod.rs index 2bae59833..147f2e7e6 100644 --- a/crates/emmylua_code_analysis/src/db_index/module/mod.rs +++ b/crates/emmylua_code_analysis/src/db_index/module/mod.rs @@ -316,12 +316,19 @@ impl LuaModuleIndex { if matched_module_path.is_none() { matched_module_path = Some((module_path, workspace.id)); } else { - let (matched, _) = match matched_module_path.as_ref() { + let (matched, matched_workspace_id) = match matched_module_path.as_ref() { Some((matched, id)) => (matched, id), None => continue, }; if module_path.len() < matched.len() { - matched_module_path = Some((module_path, workspace.id)); + // Libraries could be in a subdirectory of the main workspace + // In case of a conflict, we prioritise the non-main workspace ID + let workspace_id = if workspace.id.is_main() { + *matched_workspace_id + } else { + workspace.id + }; + matched_module_path = Some((module_path, workspace_id)); } } }