Skip to content

Commit

Permalink
lsp: Ensure that symbols always have a name
Browse files Browse the repository at this point in the history
If a situation like #685 happens again, by giving the symbol a fallback
name we should prevent the language server from failing so dramatically.
  • Loading branch information
alcarney committed Nov 27, 2023
1 parent df90d1c commit 3bd22f4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/esbonio/esbonio/lsp/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def visit_title(self, node: nodes.Node) -> None:
symbol = self.push_symbol()

name = node.astext()
if len(name) == 0:
name = "title_node"

line = (node.line or 1) - 1

symbol.name = name
Expand All @@ -93,6 +96,9 @@ def visit_a_directive(self, node: nodes.Element):
symbol = self.push_symbol()

name = node["text"] # type: ignore
if len(name) == 0:
name = "a_directive"

line = (node.line or 1) - 1

symbol.name = name
Expand Down

0 comments on commit 3bd22f4

Please sign in to comment.