OmniSharp / omnisharp-vim

Vim omnicompletion (intellisense) and more for C#
http://www.omnisharp.net
MIT License
1.72k stars 168 forks source link

Guard nulls in complete function #616

Closed stevearc closed 4 years ago

stevearc commented 4 years ago

Hi Nick! It's been a while, but I'm back to doing some C# development. I see you've been busy! This project is a lot better than the last time I used it.

I was setting up deoplete to use the omnifunc as a completion source, but hit a crash in the fuzzy matcher because one of the complete options had None for the word. I checked the OmniSharp complete handler, and sure enough there was a null word sneaking in somehow. From the docs, word is mandatory so I think the correct fix is to filter the null value here before returning it.

nickspoons commented 4 years ago

Hey Steve, nice to see you again!

It looks like CompletionText and MethodHeader are both v:null in this case. Are there any other fields we can/should use instead? If there's nothing useful then filtering like this is the way to go.

Do you happen to have the response handy? I don't think I've hit this before so I'd be interested in seeing it, to help prevent regressions later on.

stevearc commented 4 years ago

Yeah, here's echoing out the value of cmp:

{'RequiredNamespaceImport': v:null, 'MethodHeader': v:null, 'CompletionText': 'null', 'Description': v:null, 'Snippet': 'null', 'Kind': v:null, 'DisplayText': 'null', 'ReturnType': v:null, 'Preselect': v:false, 'IsSuggestionMode': v:false}

Pretty useless. Likely OmniSharp shouldn't be giving us this result in the first place, but it's easier to filter it here than track that down.

Another thing I didn't fully understand is that it looks like CompletionText is the string "null", rather than v:null, but if I check the equality of it, it's definitely == v:null. ¯\(ツ)

nickspoons commented 4 years ago

Yeah that's all pretty useless to us, good to filter it here.

I haven't seen that 'RequiredNamespaceImport' before though! It'll be great if we can automatically insert that when using the completion!

I wonder what those 'Preselect' and 'IsSuggestionMode' are for?

nickspoons commented 4 years ago

Thanks!