@@ -533,6 +533,11 @@ func (c *Client) FindReferences(ctx context.Context, filepath string, line, char
533 if err := c.OpenFileOnDemand(ctx, filepath); err != nil {
533 if err := c.OpenFileOnDemand(ctx, filepath); err != nil {
534 return nil, err
534 return nil, err
537+ // Add timeout to prevent hanging on slow LSP servers.
538+ ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
536 // NOTE: line and character should be 0-based.
541 // NOTE: line and character should be 0-based.
537 // See: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position
542 // See: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position
538 return c.client.FindReferences(ctx, filepath, line-1, character-1, includeDeclaration)
543 return c.client.FindReferences(ctx, filepath, line-1, character-1, includeDeclaration)