From af35f48ac19d0fa2610a110ea0d53c99c43f098d Mon Sep 17 00:00:00 2001 From: Hill Date: Wed, 23 Apr 2025 09:56:09 +0000 Subject: [PATCH] Add checks for 'location' and 'relativePath' in fix_relative_path function --- src/multilspy/language_server.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/multilspy/language_server.py b/src/multilspy/language_server.py index d7f60144..ca62a79f 100644 --- a/src/multilspy/language_server.py +++ b/src/multilspy/language_server.py @@ -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)