Skip to content

Commit e13c612

Browse files
committed
Language Server: Fix hover crashes on invalid parameters
When `textDocument/hover` gets an out-of-range request
1 parent 4f23c18 commit e13c612

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

libsolidity/lsp/DocumentHoverHandler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ void DocumentHoverHandler::operator()(MessageID _id, Json const& _args)
5959
{
6060
auto const [sourceUnitName, lineColumn] = HandlerBase(*this).extractSourceUnitNameAndLineColumn(_args);
6161
auto const [sourceNode, sourceOffset] = m_server.astNodeAndOffsetAtSourceLocation(sourceUnitName, lineColumn);
62+
if (!sourceNode)
63+
{
64+
client().reply(_id, Json());
65+
return;
66+
}
6267

6368
MarkdownBuilder markdown;
6469
auto rangeToHighlight = toRange(sourceNode->location());

0 commit comments

Comments
 (0)