Skip to content
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

Add isPositron context key #5673

Merged
merged 2 commits into from
Dec 12, 2024
Merged

Add isPositron context key #5673

merged 2 commits into from
Dec 12, 2024

Conversation

timtmok
Copy link
Contributor

@timtmok timtmok commented Dec 9, 2024

Address #5339

Adds a isPositron context key that is true. This can be used with extensions like this:

{
    "category": "Python",
    "command": "python.createEnvironment",
    "title": "%python.command.python.createEnvironment.title%",
    "enablement": "isPositron"
},

It can also be used internally with IsPositronContext or ContextKeyExpr.has('isPositron') if we had an existential crisis.

QA Notes

Nothing uses this and the unit test is enough to know that the key is available.

@timtmok timtmok requested a review from sharon-wang December 9, 2024 20:16
@@ -25,6 +25,9 @@ CONSTANT_VALUES.set('isEdge', isEdge);
CONSTANT_VALUES.set('isFirefox', isFirefox);
CONSTANT_VALUES.set('isChrome', isChrome);
CONSTANT_VALUES.set('isSafari', isSafari);
// --- START POSITRON ---
Copy link
Collaborator

@petetronic petetronic Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, instead of capitals, we've tried to be consistent with Start Positron and End Positron, mixed case, for these change region markers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why I thought we always used capitals. 🤯

Copy link
Member

@sharon-wang sharon-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Added one idea for testing in an extension, but I agree the test should be enough!

Comment on lines +380 to +384
// --- Start Positron ---
test('Positron Context Key', () => {
assert.ok(ContextKeyExpr.has('isPositron').equals(ContextKeyExpr.true()));
});
// --- End Positron ---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed this should be enough to verify the context key works for now 👍

If we'd like to test in an extension, one idea is to add a command to positron-zed which has enablement based on the Positron context? Then we can verify that the context key is working if the command is available in the Command Prompt.

extensions/positron-zed/package.json (I think something like this might work, but untested!)

            {
                "category": "Zed",
                "command": "zed.checkIsPositronContext",
                "title": "Check that the isPositron context key is set",
                "enablement": "isPositron"
            },

The PWB extension will be leveraging this context key soon, so we can also wait for that work to confirm the context key functionality: /~https://github.com/rstudio/rstudio-workbench-vscode-ext/issues/279

@timtmok timtmok merged commit fab84c8 into main Dec 12, 2024
5 checks passed
@timtmok timtmok deleted the feature/positron-context branch December 12, 2024 18:45
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants