-
Notifications
You must be signed in to change notification settings - Fork 28.8k
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
URIs in context keys #147732
Comments
Basically in #146686 I added a Actually, it just occurred to me that this won't work correctly for remote EHs. The extension needs to set the key to a real URI so it gets transformed, so really we need to make the expressions know how to check URI equality (or forcibly coerce both sides to a string), right? |
This issue has gotten a little chaotic but here's one proposal: #147734 |
#147926 makes it clear that we only want a string value in a context key value. To close this out, I still need a way for an extension to set a URI in a context key but have it stringified on the frontend so that it goes through uri-transformation and can be compared to something like my new So I guess I would propose stringifying it in the setContext command at this point
|
@roblourens I'm super sorry, but with things going in so many directions I'm having trouble understanding what the latest proposal is and the motivation behind it. If I understand correctly, we have done a big adoption with #147926 and we have now eliminated non-primitive values from the context keys defined by VS Code core. So there will be no context keys built in to VS Code that use URIs.
Would it be possible to identify the problematic extension that calls |
Yeah this set of issues has taken some turns. cc @jrieken. I am still trying to accomplish basically what I described in #146686 (comment). Let me update that for what has happened and summarize here. If it's hard to follow, call me any morning.
The problem is, that one
How does a context value get passed back to an extension command? |
I like that better than treating URIs as primitives - either way to need to traverse/massage the values given via 'setContext' because URIs would need "reviving".
Arguments are independent of context key values. When are arguments are provided than that's usually dependent on the menu. E.g the (code) editor context menu passes the URI of the current document, tree view context menus pass the tree item etc. For notebook cells menus it would make sense to pass the cell for which the menu has showing etc. |
Aha! Thanks for clarifying that. I agree that URIs need to cross over as URIs to benefit from transforming, so therefore we need to revive them and |
Looks perfect, thank you! |
Verification:
const cell = vscode.workspace.notebookDocuments[0].getCells()[0];
vscode.commands.executeCommand('setContext', 'extArrKey', [cell.document.uri]);
|
We have a 'resource' context key which has the full URI of the open editor. Even though it's a URI type, it's actually used as a string:
vscode/src/vs/workbench/contrib/preferences/browser/preferences.contribution.ts
Line 254 in 204d024
and it only works as a string. The equals expr coerces the real URI to a string:
vscode/src/vs/platform/contextkey/common/contextkey.ts
Line 457 in 4a130c4
and the "in" expr, which I want to use, doesn't work with URI objects because it's checking object equality.
So I suggest that we change the type to just be a string that only contains the toStringified URI. Does that make sense or am I missing something about how this is meant to be used?
The text was updated successfully, but these errors were encountered: