microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
159.32k stars 27.87k forks source link

Cleanup editor group context keys #212955

Closed benibenj closed 1 week ago

benibenj commented 2 weeks ago

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

benibenj commented 2 weeks ago

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.

bpasero commented 2 weeks ago

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 commented 2 weeks ago

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.