-
Notifications
You must be signed in to change notification settings - Fork 416
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
ArgumentOutOfRangeException from completion/resolve
on the 1st line of top level program
#2123
Comments
looks like it's happening here omnisharp-roslyn/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs Line 524 in 63834ec
-1 since we are on line 0 .
@333fred do you remember, is this subtraction intentional? I thought we are now on zero based indices |
Yes, it was intentional. This is because we don't want the current cursor location to intersect with the additional text edit. I'm not entirely sure whether we can make it just work without the |
Recently, Roslyn undeprecated the CompletionChange.TextChanges API. This API gives changes in a significantly simpler manner for us to deal with, as it splits up things like imports and the actual main change element, so we can remove a whole bunch of code dedicated to finding the changed elements and mapping original source locations to the new document. The new pattern is much simpler: except for import completion, we always resolve the change up front. For most providers, this is an extremely quick call, as most providers just return the label, and for the ones that don't we can't do much about it anyway. We can then loop through the individual changes, putting changes that are not touching the current cursor location into AdditionalTextChanges. This shrinks the completion payload pretty significantly for many scenarios, and gets rid of a bunch of special handling around it. The only remaining special handling is adjusting the filter texts and snippitizing completions that want to move the cursor. I've also aligned the behavior of the Preselect flag with Roslyn's completion handler, and removed additional filtering of completion items so that they can be filtered by the client instead. Fixes OmniSharp#2123 as well.
This reproduces for me with an empty
.cs
file + a regular project file, when trying to use the top level statements.As I start typing
Console
I see the following in the logs (using OmniSharp 1.37.6):The completion works but because resolve doesn't work, the details are empty:
This doesn't happen on line 2 anymore:
The text was updated successfully, but these errors were encountered: