-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Provide the ability for an extension to conditionally provide snippets that render the same as package.json-provided snippets #41202
Comments
Hm, the different is because of this: Unsure what to do about it... |
Would you consider implementing #26943 instead? It would avoid having to leak any of this snippet-specific code out into extensions and also be consistent with a lot of the other things in |
Actually, I just read your comments about snippets wanting scopes, so maybe pushing people to completion providers is better - so maybe finding a way to expose this does make more sense.. |
Another way would be make it the default presentation for a snippet completion. So, when the type is snippet we always generate such a string and append to the doc. Tho it will collide with suggestions that already try to emulate this. |
Ah yeah, I forgot there was a kind specifically for snippets. Though whether users would expect the rendering to change like that based on the kind, I'm not sure. In the interest of shipping my changes so I can add project-specific snippets, I'm just going to hide the preview for now (not set the If you come up with a good way to handle this, I'll update it :-) |
A good idea might be to use the preview only when the documentation is missing ;-) |
That'd work for me; though I don't know if it'd make sense to support both. If I added documentation that was just a line of text, the preview would disappear? Thinking about the original problem again (my preview has |
That's just variables... Also placeholders come into play, so $1, $2 etc then also all other snippet features... |
@jrieken I think that stuff all already works using my completion provider at the top? The only difference I noticed (but it's possible I didn't test properly!) was the preview being different? |
On reflection I've decided to leave this as-is. It means the user may see things like I'll revisit if you add a better way to handle it. |
Ok. Closing until you'll change your mind. |
I'd like to be able to conditionally provide snippets based on some knowledge of the project type a user has opened with my extension. I previously opened #26943 requested
when
support for snippets but it was suggested that I just change to aCompletionItemProvider
instead.I've implemented a provider that reads the standard snippet JSON format in an attempt to provide the exact same behaviour as when the snippets were contributed via
package.json
:This appears to work fine and renders snippets that look just like the built-in ones, with one exception - the placeholders are hidden in the built-in snippets but visible in mine:
I've been searching through the code and believe this is because of
_rewriteBogousVariables
from here.I could copy that code into my completion provider, but it means I have to maintain it if there are any changes/bugfixes in the future. I think it would be better if Code exposed a way for us to be able to provide snippets that render the same as Code's but that we can be added conditionally. (Alternatively, is it possible #26943 could be re-considered? I think it would be a nicer solution!).
The text was updated successfully, but these errors were encountered: