Merge pull request #82 from HillLiu/main

Add checks for 'location' and 'relativePath' in fix_relative_path function
This commit is contained in:
Dominik Jain authored and GitHub committed 2025-04-23 12:47:51 +02:00
commit da3ad9ad4d
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)