This came from vscode-docs issue customer comment https://github.com/Microsoft/vscode-docs/issues/1503#issuecomment-375170030
"The biggest missing documentation for extensions is the lack of setContext here https://code.visualstudio.com/docs/extensionAPI/vscode-api-commands"
Should we add the description and metadata so that it will be part of the _generateCommandsDocumentation output?
FYI https://github.com/Microsoft/vscode/issues/10471#issuecomment-239767247
I would love this. At the same time, could we think about adding the corollary getContext? The number of hoops that need to be jumped through to get the right context make things very difficult (and other impossible).
Here is a concrete example.
In GitLens, I have commands that navigate forward and backward through revisions. The current diff editor behavior make these difficult to implement well -- leaving aside the details there, to work around it one solution I've come up with is duplicating those 2 commands, 1 for normal editors and 1 for diff editors. And then I have to duplicate all the placements (inDiffEditor && ... and !inDiffEditor && ... and then have the command behave appropriately based on the context.
Alternatively, if there was a getContext type api, I could avoid all of that, and just look up inDiffEditor in my existing command and do the right thing. Way less complexity and explosion of commands and placements.
Please? 馃檹 馃槃
I am also very concerned about this issue. I found the setContext when I'm reading the source code of github pull request extension, but I didn't find it in Command Reference, but in the Update Docs. I hope the official team can fix this issue soon.
Best wishes. : )
Like @LeuisKen, I found use of setContext in the samples (tree-view-sample) and the 2016 update documentation. 2016 blog reference, but not in API docs and this issue has been open more than a year? 馃憥 Is it maybe considered "proposed API"?
@joaomoreno seems like the issue belongs to https://github.com/microsoft/vscode-docs, right?
Like @LeuisKen, I found use of
setContextin the samples (tree-view-sample) and the 2016 update documentation. 2016 blog reference, but not in API docs and this issue has been open more than a year? 馃憥 Is it maybe considered "proposed API"?
same here too... unfortunately documentation is falling behind!
setContext examples added to Command Extension Guide with https://github.com/microsoft/vscode-docs/commit/4ae8f109dec6d7ed58439abdcb44b31a6b9ea8e6
Most helpful comment
FYI https://github.com/Microsoft/vscode/issues/10471#issuecomment-239767247
I would love this. At the same time, could we think about adding the corollary
getContext? The number of hoops that need to be jumped through to get the right context make things very difficult (and other impossible).Here is a concrete example.
In GitLens, I have commands that navigate forward and backward through revisions. The current diff editor behavior make these difficult to implement well -- leaving aside the details there, to work around it one solution I've come up with is duplicating those 2 commands, 1 for normal editors and 1 for diff editors. And then I have to duplicate all the placements (
inDiffEditor && ...and!inDiffEditor && ...and then have the command behave appropriately based on the context.Alternatively, if there was a
getContexttype api, I could avoid all of that, and just look upinDiffEditorin my existing command and do the right thing. Way less complexity and explosion of commands and placements.Please? 馃檹 馃槃