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