Use get() method for safer access to document root properties in LanguageServer

This commit is contained in:
Hill committed 2025-04-24 05:04:12 +00:00
1 parent da3ad9ad4d
commit 5cb291f096
1 file changed
+4 -4
+4 -4
View File
@@ -1046,10 +1046,10 @@ class LanguageServer:
_, document_roots = await self.request_document_symbols(relative_file_path)
return [
(
root["name"],
root["kind"],
root["selectionRange"]["start"]["line"], # type: ignore
root["selectionRange"]["start"]["character"] # type: ignore
root.get("name"),
root.get("kind"),
root.get("selectionRange", {}).get("start", {}).get("line"), # type: ignore
root.get("selectionRange", {}).get("start", {}).get("character"), # type: ignore
)
for root in document_roots
]