csharp-language-server-protocol
csharp-language-server-protocol copied to clipboard
CodeActions on visual studio
Hi,
Thank you for the great library. I had a question about CodeActions and how they work with Visual Studio (not VS Code). We are seeing a weird behavior and wondering if there's something we're missing.
The scenario is simple. Using the ITextDocumentSyncHandler, we are publishing diagnostics with the below properties: Range, Message, Severity, RelatedInfo, Source, Code, and CodeDescription.
And using the ICodeActionHandler, we are returning a codeAction with the below properties: Title, Edit, Diagnostics, IsPreferred
The weird behavior is that the codeAction will display with no issues, as long as there are no diagnostics that we published. It doesn't display for any range where there is a diagnostic (again, that we created). For other diagnostics, there are no issues.
I have tried multiple combinations of the properties above and seem to always get this behavior. Have you seen this issue before? Let me know.
Thanks again for building this awesome library!
@marknfawaz my best guess is that it doesn't like you haven't provided a Command.
I ran thins demo at dotnet conf and code actions were working, but I am setting the command. https://github.com/david-driscoll/dotnet-conf-2020/blob/1a73d216cc179aaf516900e5259ab3a106b3fd6d/server/CodeActionProvider.cs
@david-driscoll thanks for the response. When including the command, we are now seeing the code actions. I am still seeing an issue with code actions disappearing in some cases (in a c# file, while the user is still on the file). I am wondering if that's an issue you have seen in Visual studio 2019 or if there are any pointers you can help us with.
Thanks again for your help on this!
It looks like the issue is from Intellicode in visual studio. When its LS starts, code actions will stop showing up. If you disable it, there are no issues with CS files.