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

Error in autocompletion with strings starting with an uppercase letter #4063

Closed
ssoher opened this issue Sep 13, 2020 · 2 comments · Fixed by OmniSharp/omnisharp-roslyn#1941

Comments

@ssoher
Copy link

ssoher commented Sep 13, 2020

Issue Type: Bug

When overriding a protected void method named OnEnable, if I autocomplete with tab or return, the resulting code is as such:

protected override voidnEnable() { basOnEnable(); }

If I autocomplete "onEnable" (first o is lower case), the result is correct. This happens with any string that starts with an uppercase letter. I've tried "Awake", "OnDisable" etc.

vsbug

Extension version: 1.23.2
VS Code version: Code 1.49.0 (e790b931385d72cf5669fcefc51cdf65990efa5d, 2020-09-10T13:22:08.892Z)
OS version: Windows_NT x64 10.0.18362

@ssoher ssoher changed the title Error in autocompletion with a specific string Error in autocompletion with strings starting with an uppercase letter Sep 13, 2020
@nohwnd
Copy link
Member

nohwnd commented Sep 14, 2020

Looking into this.

@nohwnd
Copy link
Member

nohwnd commented Sep 14, 2020

This is because the completion does not handle correctly the case when completion keeps a bit of the original text. It works with one, because the typed text is on the given position 34, 45 (line, col) the returned change would be OnEnabled()\n ... with position 34, 45. But with One the change is Enabled()\n ... on position 34,47.

This will skip this condition and instead use the one the is more complicated, that allows overwriting the existing code, but that path does not support this case correctly.

https://github.com/OmniSharp/omnisharp-roslyn/blob/0587b50d9baea974a76adbbe063a1572ae9382aa/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs#L239-L243

I was able to naively fix it by just taking the start of the typedText and prepending it to the proposed change. But this seems like oversimplifying the problem.

OmniSharp/omnisharp-roslyn#1941

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 a pull request may close this issue.

2 participants