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

Cleanup editor group context keys #212955

Merged
merged 6 commits into from
May 20, 2024
Merged

Cleanup editor group context keys #212955

merged 6 commits into from
May 20, 2024

Conversation

benibenj
Copy link
Contributor

This pull request includes changes to clean up the editor group context keys.

@benibenj benibenj requested a review from bpasero May 17, 2024 08:15
@benibenj benibenj self-assigned this May 17, 2024
@benibenj benibenj enabled auto-merge (squash) May 17, 2024 08:15
@vscodenpa vscodenpa added this to the May 2024 milestone May 17, 2024
@benibenj benibenj disabled auto-merge May 17, 2024 08:25
@benibenj
Copy link
Contributor Author

benibenj commented May 17, 2024

Also, I need to make sure it's correctly handled when the active group changes which is not the case currently. I wonder if we can solve this from the EditorPart. It could listen on active group change and then set the global contextkeys to the scoped ones. Not sure its possible in a nice way... Otherwise, the editor group view just needs to rerun observeActiveEditor when it becomes active.

src/vs/workbench/browser/parts/editor/editorPart.ts Outdated Show resolved Hide resolved
src/vs/workbench/browser/parts/editor/editorPart.ts Outdated Show resolved Hide resolved
src/vs/workbench/browser/parts/editor/editorPart.ts Outdated Show resolved Hide resolved
@bpasero
Copy link
Member

bpasero commented May 17, 2024

Also, I need to make sure it's correctly handled when the active group changes which is not the case currently. I wonder if we can solve this from the EditorPart. It could listen on active group change and then set the global contextkeys to the scoped ones. Not sure its possible in a nice way... Otherwise, the editor group view just needs to rerun observeActiveEditor when it becomes active.

Yeah you need to keep track of active group changes and then go over all context keys that have been bound and ask for the scoped context key value to update the global one.

Btw EditorPart is per window and each window can have an active editor group. But only EditorParts has the true single active editor group, so maybe this actually needs to be managed by EditorParts so that we are not updating the global context key from multiple windows.

@benibenj benibenj requested a review from bpasero May 18, 2024 08:54
Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

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

I think bind works fine now for context keys that are bound within the group, but what if someone calls bind and passes in the active group, the key would only be bound for that active group and not the other groups.

So maybe bind needs to work differently: you are not passing in the editor group, but just the key. And then EditorParts makes sure to set the key properly when editor groups change, add or remove?

@benibenj
Copy link
Contributor Author

That is why bind is not on the service, so others don't use it, but it's hard to fully restrict it to the outside. The next step (other PR ideally) will be to have a method on the service which allows others to register a context key handler. This will then be managed correctly across all groups.

@benibenj benibenj enabled auto-merge (squash) May 20, 2024 09:55
@benibenj benibenj merged commit aa31bfc into main May 20, 2024
6 checks passed
@benibenj benibenj deleted the benibenj/organic-marsupial branch May 20, 2024 11:03
mustard-mh pushed a commit to gitpod-io/openvscode-server that referenced this pull request May 22, 2024
* cleanup editor group context keys

* Update src/vs/workbench/browser/parts/editor/editorPart.ts

Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>

* context key on parts

* Update global context keys

* remove scoped keys on group removal

* cleanup

---------

Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
@microsoft microsoft locked and limited conversation to collaborators Jul 4, 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.

5 participants