Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Any API to replace tooltip for a completion item? #48

Open
wmjordan opened this issue Jun 28, 2023 · 8 comments
Open

Any API to replace tooltip for a completion item? #48

wmjordan opened this issue Jun 28, 2023 · 8 comments

Comments

@wmjordan
Copy link

Nowadays a tooltip will display at the right side of selected item in the AutoCompletion list.

In VS 2017, we can create a class implementing IUIElementProvider<Completion, ICompletionSession> to override The RoslynToolTipProvider, like the below code shows.

[Export(typeof(IUIElementProvider<Completion, ICompletionSession>))]
[Name(nameof(CSharpCompletionTooltip))]
//Roslyn is the default Tooltip Provider. We must override it if we wish to use custom tooltips
[Order(Before = "RoslynToolTipProvider")]
[ContentType("CSharp")]
internal sealed class CSharpCompletionTooltipProvider : IUIElementProvider<Completion, ICompletionSession>

In VS 2022, the logic is changed.
It seems that no extension point is provided to override the completion tooltip any more.
What can we do if we are to change the appearance and content of a completion tooltip?

@olegtk
Copy link
Member

olegtk commented Jul 4, 2023

It seems like it's still possible per documentation:

"The returned object will be rendered by IViewElementFactoryService. See its documentation for default supported types. You may export a IViewElementFactory to provide a renderer for a custom type."

But I think expectation is that you would be rendering your own custom type, not re-styling rendering of somebody's else types. Seems like Roslyn returns just Microsoft.VisualStudio.Text.Adornments.ContainerElement, so that's what you need to handle with your IViewElementFactory, @wmjordan. But given that it's so common type unfortunately you will be customizing more than completion tooltip, but likely more. Not sure if it's possible to detect specifically completion tooltip.

@AmadeuszW might know more.

What is your scenario, @wmjordan? What kind of customization would you like to apply to completion tooltips?

@wmjordan
Copy link
Author

wmjordan commented Jul 4, 2023

@olegtk, Thank you for your reply and information.

I am writing an extension to help C# programmers to better work with their source code.
Nowadays, it overrides C# completion tooltips on VS 2017--A demonstration can be seen below. The completion tooltip is listing possible method overloads for a completion entry.

image

I'd love to do the same thing on VS 2022 as well.

@wmjordan
Copy link
Author

wmjordan commented Jul 4, 2023

IViewElementFactory can not achieve the above result.

To override the C# completion tooltip, we need the ITextView, the trigger point and the completion text (Append<> in the above screenshot). The parameters passed into IViewElementFactory.CreateViewElement are only the view and an object, produced by the GetDescriptionAsync method. Those are insufficient.

@olegtk
Copy link
Member

olegtk commented Jul 6, 2023

Please file a bug via Help/Send Feedback/Report a Problem. It looks like a bug as it was possible before.

@wmjordan
Copy link
Author

wmjordan commented Jul 7, 2023

I guess it is by design.
They deliberately removed the extension point, for some reasons.
I am not sure whether there is another newly introduced extension point out there.

I cross posted the issue, but got no reply so far.

@olegtk
Copy link
Member

olegtk commented Jul 7, 2023

it's not exactly by design, either way it's a take back from previous completion extensibility API so please file a feedback ticket via Help/Send Feedback/Report a Problem or file create an issue on https://github.com/microsoft/VSExtensibility

@wmjordan
Copy link
Author

wmjordan commented Jul 7, 2023

https://github.com/microsoft/VSExtensibility appears to be the greenhouse for future extensions API. I guess it is not for this.

@wmjordan
Copy link
Author

wmjordan commented Jul 7, 2023

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants