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 completion with backticks, underscores, numbers #10500

Merged
merged 3 commits into from
Nov 25, 2020

Conversation

zanaptak
Copy link
Contributor

This is to address the following issues:

Which are also listed in this issue:

Before PR:

completion underscore before dark

After PR:

completion underscore after dark

The problem (if I traced the right code) is that the default logic (erroneously?) only captures identifier-start characters to the left of the cursor, and further defines start characters as letters only.

https://github.com/dotnet/roslyn/blob/823039e98e56e527d40b4fbcb6bf9755ce02855c/src/Features/Core/Portable/Completion/CompletionService.cs#L102

C# overrides this to include identifier-part characters so I've used the same logic here, this handles underscores and numbers.

For backticks, my initial code shows it can work but is not ready for primetime. Simple character matching isn't enough to properly restrict the range especially in the case of partial entry. As in let x = (``typing here... , ``already-typed``), how to know it shouldn't include the comma? Is this an already-considered scenario somewhere in the existing tooling codebase? I'd appreciate any guidance or pointers to help with this.

@zanaptak
Copy link
Contributor Author

I've changed it to use the Tokenizer directly, so that it can easily handle multiple backticks, backticks in strings, etc.

Unfortunately it turns out the rest of the completion pipeline is not as robust. E.g. something like let x = ["``"; A.``#1``; B. works fine with the new completion span logic, but the later completion list logic fails to understand that B is the qualifying type in ProvideCompletionsAsyncAux.

I'll play around some more to see if feasible to update, otherwise maybe it's ok to leave some edge cases if the majority of typical cases work.

@cartermp
Copy link
Contributor

otherwise maybe it's ok to leave some edge cases if the majority of typical cases work.

I agree. I'm happy to review with aims to take this as is provided that tests pass. Just let me know if you want to proceed with that or hold off until you're finished experimenting a little more.

@zanaptak
Copy link
Contributor Author

Ok I'll skip digging into the rest of the pipeline for now so this can move forward.

@cartermp
Copy link
Contributor

Thanks! Mind marking this as no longer WIP? Then we can review.

@zanaptak zanaptak changed the title [WIP] Fix completion with backticks, underscores, numbers Fix completion with backticks, underscores, numbers Nov 25, 2020
@zanaptak
Copy link
Contributor Author

Ready to go, hopefully the test structure is ok, made it a separate utility function.

Copy link
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

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

This is great, thanks! Will merge subject to CI passing.

@abelbraaksma
Copy link
Contributor

Wonderful work! Since specifically for awkward names, completion is a must have, and removing redundant words or backticks was quite a pain. Very happy you solved this!!

nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
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.

3 participants