-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Lift setContext
from a command to proper API
#10471
Comments
Like so @farfromrefug What exactly do you want to achieve with that? |
Yes exactly like that. That's actually the only way to trigger a special build defined in an extension (see the linked issue). |
@farfromrefug Your extension could activate on
and then you can use @jrieken Now that there are more use-cases than vim, should we consider lifting |
I like. Maybe something similar to how we have it internally, like
I'll let it cook for a little |
@alexandrudima i love that. Does it already works (i don't see this in the cordova plugin)? |
@farfromrefug You can create an issue in the cordova extension repo and introduce them to the problem and provide them with the recommendation. |
@alexandrudima it s not an issue. I was just wondering if that API was already existing. And i was talking of cordova as an example. |
|
@alexandrudima i can confirm that it works! |
Usually we direct questions to Stack Overflow. You can also open issues if you feel you're running into something that looks like a bug, but each issue should be self-contained. We also have some issues that come in which are in fact questions. TL;DR Stack Overflow preferably, otherwise issues |
@alexandrudima i wont create issues though it might be bug related. I am not sure what's the cause yet. |
setContext
from a command to proper API
@alexandrudima from my experience in handling keybindings in Vim, the need for lifting it to API is because we only support limited context key type https://github.com/Microsoft/vscode/blob/c67ef57cda90b5f28499646f7cc94e8dcc5b0586/src/vs/platform/contextkey/common/contextkey.ts which makes For example, we have quite a few Vim commands implemented in our ext and ppl always come and say, hey we want to use these Vim commands and for others, we prefer Code's. In this case, a single context key to enable/disable all Vim keybinds is not enough. Is there any possibility that we support objects instead of just booleans for context keys then we can write below code to implement whatever we want
|
@rebornix You raise a good point, but IMHO this should not be tackled with options that then pollute the keybindings. All these users can today, without any code change in vscode or in the vim extension, customize their keybindings 100%. They just need to go to their For your case, the end user would need to write the following in their
Maybe not as easy as an option, but then that is a separate bug, that our keybindings UI is non existant. But I agree, there is a real problem here. I install an extension and all of a sudden I need to add all these rules with |
@alexandrudima I love your proposal here. A contribution point level enable/disable makes it possible to choose a specific command for a particular key combination. A concrete example is when you install Resharper on Visual Studio, you get a chance to decide which command you want to use for any keycap you press. We can make it happen in Code by enabling a contribution for one extension and disabling all others for a single key combination :) |
Is this documented anywhere yet? |
only in this issue |
Moving this issue to the next milestone. It's not clear to me now we bring this to the API given that there are actually different contexts active and that extensions might want to utilise that |
One more thing to think about with this API is how to allow string interpolation of context variable string values within package.json
|
|
I would like to see I could keep track of the state myself "perhaps", but that seems a shame if the key already exists for each editor. |
+1 for getContext API call. I am writing screenreader accessibility extension for VSCode and I need to figure out whether cursor is in the main text editor - as opposed to panes like debug or explorer pane. It appears current extension API doesn't have a way to figure that out. |
+1 , it would be great if I could use Memento directly from webview withouth passing messages. |
+1 for |
Please. How is this not a thing yet? |
+1 for EDIT: Out of desperation I tried receiving any arguments in my command. Turns out that you get the JSON set as |
…r. (#425) ### Description Because, secondary sidebar in vscode has a "close" button in top right corner, the user is faced with two "X" buttons that do different things; one closes the secondary sidebar and in effect hides our extension and the second closes our extension completely. ### Solution To mitigate the negative effects this PR overrides the command used to hide secondary sidebar and closes React native IDE completely before hiding it, that makes two buttons perform similar actions instead of doing two different things, which is an improvement. ### Hiding the second button The natural question to ask is why can't we disable, our "close RNIDE" button when IDE is in secondary sidebar. Unfortunately there is now reliable way to check in which sideBar the viewContainer contributed by an extension is located at any given time. There is a closed issue on that topic here. One workaround for that would be to check if context key "activeAuxiliary" has value matching our extension contributed viewContainer, because since it is an activeAuxiliary it has to be in Auxiliary SideBar, unfortunately the id of Extension contributed view Containers is randomly generated, you can read the code [here](https://github.com/microsoft/vscode/blob/main/src/vs/workbench/services/views/browser/viewDescriptorService.ts) the first relevant line is 502. There is hope of discovering the generated viewContainer id by checking the activeAxiliary and activeViewlet context fields while we know about its location, but it would require a getContext() API that is not currently implemented, an active issue on that can be found [here](microsoft/vscode#10471). --------- Co-authored-by: filip131311 <filip.kaminski@swmansiom.com>
+1 for |
1 similar comment
+1 for |
+1 for getContext API |
I would love to see such an API as well. My use case is that I do various presentations with VS Code and use the Demo Time extension to script and run my demos. My slides are shown in the lite browser like this: When I go to presentation mode, it would be helpful to hide the status and activity bars. However, when I run a demo, I want to show both of them again. As hiding them is a toggle action, it does not always work correctly. When I get the context, I can check what is shown/hidden and perform the actions accordingly. It might not be a common use-case, but being able to read those context values will give extension builders more control of the overall experience. |
Adding my own two cents for a +1 to |
…r. (#425) ### Description Because, secondary sidebar in vscode has a "close" button in top right corner, the user is faced with two "X" buttons that do different things; one closes the secondary sidebar and in effect hides our extension and the second closes our extension completely. ### Solution To mitigate the negative effects this PR overrides the command used to hide secondary sidebar and closes React native IDE completely before hiding it, that makes two buttons perform similar actions instead of doing two different things, which is an improvement. ### Hiding the second button The natural question to ask is why can't we disable, our "close RNIDE" button when IDE is in secondary sidebar. Unfortunately there is now reliable way to check in which sideBar the viewContainer contributed by an extension is located at any given time. There is a closed issue on that topic here. One workaround for that would be to check if context key "activeAuxiliary" has value matching our extension contributed viewContainer, because since it is an activeAuxiliary it has to be in Auxiliary SideBar, unfortunately the id of Extension contributed view Containers is randomly generated, you can read the code [here](https://github.com/microsoft/vscode/blob/main/src/vs/workbench/services/views/browser/viewDescriptorService.ts) the first relevant line is 502. There is hope of discovering the generated viewContainer id by checking the activeAxiliary and activeViewlet context fields while we know about its location, but it would require a getContext() API that is not currently implemented, an active issue on that can be found [here](microsoft/vscode#10471). --------- Co-authored-by: filip131311 <filip.kaminski@swmansiom.com>
+1 to |
+1 for getContext API |
This would be very useful to activate extension build feature per project type.
would help for this issue
The text was updated successfully, but these errors were encountered: