Add checks for 'location' and 'relativePath' in fix_relative_path function

This commit is contained in:
Hill committed 2025-04-23 09:56:09 +00:00
1 parent e51cb768db
commit af35f48ac1
1 file changed
+10 -8
+10 -8
View File
@@ -952,14 +952,16 @@ class LanguageServer:
# TODO: Not sure if this is actually still needed given recent changes to relative path handling
def fix_relative_path(nodes: List[multilspy_types.UnifiedSymbolInformation]):
for node in nodes:
path = Path(node["location"]["relativePath"])
if path.is_absolute():
try:
path = path.relative_to(self.repository_root_path)
node["location"]["relativePath"] = str(path)
except:
pass
fix_relative_path(node["children"])
if "location" in node and "relativePath" in node["location"]:
path = Path(node["location"]["relativePath"])
if path.is_absolute():
try:
path = path.relative_to(self.repository_root_path)
node["location"]["relativePath"] = str(path)
except Exception:
pass
if "children" in node:
fix_relative_path(node["children"])
fix_relative_path(root_nodes)