Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2550 inlay hints lambdas parameter type null reference exception #2604

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

madiele
Copy link
Contributor

@madiele madiele commented Feb 17, 2024

this fixes #2550

the issue happens with lambdas as parameters of a function call (Though it might happen in other cases too) es function(sp => sp.GetService<CloudAdapter>()

this should expand to function(|paramName:| |Type| sp => sp.GetService<CloudAdapter>()

each hint has a field called TextEdits of type LinePositionSpanTextChange[]? (either is an array or is null), which tell the editor that there is an option to promote the virtual text to real text in the document, but for lambdas paramenters type this is not an option so is set to null, when the TextEdits object gets passed to a foreach loop without checking for null the LSP would crash with a null reference

public static IEnumerable<TextEdit> ToTextEdits(LinePositionSpanTextChange[] textChanges)
{
    foreach (var change in textChanges) //<--- ops this is null!
    {
        yield return ToTextEdit(change);
    }
}

I've also added a test to replicate the exception, I hope it's all that's needed, if I need to change something in the PR let me know!

@madiele
Copy link
Contributor Author

madiele commented Feb 17, 2024

@microsoft-github-policy-service agree

Copy link
Member

@JoeRobich JoeRobich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @madiele!

@JoeRobich JoeRobich merged commit ac7b9b8 into OmniSharp:master Feb 22, 2024
22 checks passed
@madiele madiele deleted the lambda-param-nullref branch February 22, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InlayHints not working on neovim
2 participants