fix(library): rebuild SymbolLibraryManager when cache is empty
When a project is opened for the first time (e.g. right after
create_project) the sym-lib-table may not exist on disk yet.
SymbolLibraryManager.__init__ succeeds but leaves self.libraries={}.
The original guard in use_project() was:
if self.library_manager.project_path == project_path:
return
Because the path already matched the newly-created manager, the
early-return fired and the manager was never rebuilt once the
sym-lib-table appeared. All subsequent list_symbols / search calls
returned nothing.
Fix: also require that at least one library was loaded before
treating the cache as valid.
Adds three unit tests that cover:
- rebuild triggered when project_path matches but libraries={}
- no spurious rebuild when libraries are already loaded
- rebuild on project_path change (existing behaviour)
This commit is contained in:
@@ -607,7 +607,11 @@ class SymbolLibraryCommands:
|
||||
"""
|
||||
if project_path is None:
|
||||
return
|
||||
if self.library_manager.project_path == project_path:
|
||||
# Patch (SER2RJ45): keep cache when project_path matches AND libraries were
|
||||
# actually loaded. Original early-return skipped rebuild even when the cache
|
||||
# was empty (e.g. first call after create_project, before sym-lib-table existed).
|
||||
if (self.library_manager.project_path == project_path
|
||||
and len(self.library_manager.libraries) > 0):
|
||||
return
|
||||
logger.info(f"Rebuilding SymbolLibraryManager for project: {project_path}")
|
||||
self.library_manager = SymbolLibraryManager(project_path=project_path)
|
||||
|
||||
Reference in New Issue
Block a user