Skip to content

Improve completion logic #1738

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

Merged
merged 7 commits into from
Mar 10, 2022
Merged

Improve completion logic #1738

merged 7 commits into from
Mar 10, 2022

Conversation

andyleejordan
Copy link
Member

This makes the deduced CompletionItemKind enum more accurate, which
results in better icons for the user when viewing completions in an
editor. Also cleaned up the file as there were remnants of dead code.

Fixes PowerShell/vscode-powershell#3364

@andyleejordan
Copy link
Member Author

@MartinGC94 I think you'll like this!

From your demo (ignore ProviderItem, Code does some magic to get filetype specific icons later):
Screen Shot 2022-03-07 at 4 42 07 PM

Files:
Screen Shot 2022-03-07 at 4 44 43 PM

Operators:
Screen Shot 2022-03-07 at 4 46 06 PM

Namespace:
Screen Shot 2022-03-07 at 4 43 38 PM

And even classes:
Screen Shot 2022-03-07 at 4 43 09 PM

@andyleejordan andyleejordan added Area-IntelliSense Issue-Enhancement A feature request (enhancement). labels Mar 8, 2022
@MartinGC94
Copy link
Contributor

You are right, this looks great and great choice of icons as well. The only icon that looks a little out of place is the ParameterName. I know it shares its icon with the operators but parameters are used much more frequently so maybe the chosen icon should look more like a parameter?

Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

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

Looks great! Just a couple of nits

@andyleejordan andyleejordan force-pushed the andschwa/completions branch from 22b4b96 to 684b0ff Compare March 8, 2022 17:34
@andyleejordan
Copy link
Member Author

You are right, this looks great and great choice of icons as well. The only icon that looks a little out of place is the ParameterName. I know it shares its icon with the operators but parameters are used much more frequently so maybe the chosen icon should look more like a parameter?

@MartinGC94 That is an artifact of the way that test displays all of them at once and the logic that figures out if it's a parameter. They're actually currently mapped to CompletionItemKind.Variable (which was their previous mapping) and look like this:
Screen Shot 2022-03-08 at 9 47 05 AM

However, I'm trying to decide if instead they should map to Field or Property (which are maybe slightly more accurate? The parameters declared on a PowerShell function are kind of like fields/properties).

Field (which is so far unused):
Screen Shot 2022-03-08 at 9 50 11 AM

Property (which already has the PowerShell CompletionResultType.Property mapping to it):
Screen Shot 2022-03-08 at 9 51 57 AM

@MartinGC94
Copy link
Contributor

I see. All 3 of those are fine but if I had to pick I would go with Field because I like the icon and the fact that it's unique.

@andyleejordan andyleejordan force-pushed the andschwa/completions branch from 684b0ff to 28912a8 Compare March 8, 2022 19:08
@JustinGrote
Copy link
Collaborator

Using other languages as prior art, parameters are generally considered variables (Typescript as example):

image
image

C# as another:
image

So I think it should stay as variable for a consistent experience.

@andyleejordan
Copy link
Member Author

Thanks for pointing that out @JustinGrote, I agree. What tool are you using to inspect like that?

@andyleejordan andyleejordan force-pushed the andschwa/completions branch from 28912a8 to 59be311 Compare March 8, 2022 19:51
@andyleejordan andyleejordan self-assigned this Mar 8, 2022
@JustinGrote
Copy link
Collaborator

@andschwa it's built into vscode, very useful for troubleshooting syntax highlighting
image

@andyleejordan
Copy link
Member Author

@andschwa it's built into vscode, very useful for troubleshooting syntax highlighting
image

I'm so sad I've learned about this a year later...what else should I know?!

@JustinGrote
Copy link
Collaborator

@andschwa uuuh, you can access devtools for the running vscode instance maybe?
image

Basically check out everything prefixed with Developer:

@andyleejordan
Copy link
Member Author

@JustinGrote @SeeminglyScience @MartinGC94 Give this new commit a whirl would you? I removed the middle abstraction layer as it seemed superfluous.

@andyleejordan
Copy link
Member Author

Oops, probably tests expecting old code. Fixing up.

@andyleejordan andyleejordan force-pushed the andschwa/completions branch 4 times, most recently from fda3a76 to 1424359 Compare March 10, 2022 18:34
Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

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

LGTM, couple of little things

@andyleejordan andyleejordan force-pushed the andschwa/completions branch 2 times, most recently from bb14056 to 15c3b85 Compare March 10, 2022 20:20
This makes the deduced `CompletionItemKind` enum more accurate, which
results in better icons for the user when viewing completions in an
editor. Also cleaned up the file as there were remnants of dead code.
This removes an abstraction that sat between `SMA.CompletionResults` and
`OmniSharp.CompletionItems`. It most likely existed out of necessity
before a prior refactor that introduced OmniSharp. Now we can skip the
middle layer and instead convert directly, massively simplifying the
code (and fixing tooltips).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IntelliSense Issue-Enhancement A feature request (enhancement).
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

IntelliSense uses the wrong icons for some completion result types
4 participants