-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add dock state to workspace context #40454
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 dock state to workspace context #40454
Conversation
| impl Panel for OutlinePanel { | ||
| fn persistent_name() -> &'static str { | ||
| "Outline Panel" | ||
| "OutlinePanel" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: those 2 persistent_name changes spoil the DB restoration, at least the first time the new version is out.
Seems redundant to do?
|
This makes sense to me, but as Kirill points out we can't change the persistant_name. I'd suggest adding a second method (that can default to the first) for this identifier. |
|
@ConradIrwin There is a SQLite DB that handles the session restoration when the app is opened, and the table that refers to these panels uses What sort of session information is tied the Project Panel and the Outline Panel? Wouldn't it just be like the display width? Is there no way of running migrations on this DB? I'm just thinking out loud here. I contemplated creating a new method on the Panels, but changing these two to match all the other panels seemed like the smaller change. I can create a new method that will just return a key context identifier for the Panel. Give me a bit to work on it. |
7a5f9bc to
857450e
Compare
857450e to
8a16d31
Compare
|
alrighty, this PR now includes a new method this returns the *_PANEL_KEY const for each of the Panels. let me know what you think. |
|
Sounds good! It would also be possible to write a migration to do this, but I think there are two different things happening here. |
Head branch was pushed to by a user without write access
|
@ConradIrwin |
|
Release Notes:
|
|
thanks for fixing it! |
Release Notes: - Pane key context now includes 'buffer_search_deployed' identifier The goal of this PR is to add a new identifier in the key context that will let the user target when the BufferSearchBar is deployed even if they are not focused on it. requested in #36930 Same rational as #40454 this will allow users to make more flexible keybindings, by including some additional information higher up the key context tree. i thought adding this context to `Pane` seemed more appropriate than `Editor` since `Terminal` also has a `BufferSearchBar`; however, I ran into some import issues between BufferSearchBar, Search, Pane, and Workspace which made it difficult to implement adding this context directly inside `Pane`'s render function. instead i added a new method called `contributes_context` to `ToolbarItem` which will allow any toolbar item to add additional context to the `Pane` level, which feels like it might come in handy. here are some screen shots of the context being displayed in the Editor and the Terminal <img width="1653" height="1051" alt="Screenshot 2025-10-25 at 14 34 03" src="https://github.com/user-attachments/assets/21c5b07a-8d36-4e0b-ad09-378b12d2ea38" /> <img width="1444" height="1167" alt="Screenshot 2025-10-25 at 12 32 21" src="https://github.com/user-attachments/assets/86afe72f-b238-43cd-8230-9cb59fb93b2c" />
Release Notes: - Pane key context now includes 'buffer_search_deployed' identifier The goal of this PR is to add a new identifier in the key context that will let the user target when the BufferSearchBar is deployed even if they are not focused on it. requested in zed-industries#36930 Same rational as zed-industries#40454 this will allow users to make more flexible keybindings, by including some additional information higher up the key context tree. i thought adding this context to `Pane` seemed more appropriate than `Editor` since `Terminal` also has a `BufferSearchBar`; however, I ran into some import issues between BufferSearchBar, Search, Pane, and Workspace which made it difficult to implement adding this context directly inside `Pane`'s render function. instead i added a new method called `contributes_context` to `ToolbarItem` which will allow any toolbar item to add additional context to the `Pane` level, which feels like it might come in handy. here are some screen shots of the context being displayed in the Editor and the Terminal <img width="1653" height="1051" alt="Screenshot 2025-10-25 at 14 34 03" src="https://github.com/user-attachments/assets/21c5b07a-8d36-4e0b-ad09-378b12d2ea38" /> <img width="1444" height="1167" alt="Screenshot 2025-10-25 at 12 32 21" src="https://github.com/user-attachments/assets/86afe72f-b238-43cd-8230-9cb59fb93b2c" />
I love keybindings.
I spend way to much time thinking about them.
I also REALLY like working in Zed.
so far, however, I have found the key context system in Zed to be less flexible than in VSCode.
the HUGE context that is available in VSCode helps you create keybindings for very specific targeted scenarios.
the tree like structure of the Zed key context means you loose some information as focus moves throughout the application.
For example, it is not currently possible to create a keybinding in the editor that will only work when one of the Docks is open, or if a specific dock is open.
this would be useful in implementing solutions to ideas like #24222
we already have an action for moving focus to the dock, and we have an action for opening/closing the dock, but to my knowledge (very limited lol) we cannot determine if that dock is open unless we are focused on it.
I think it is possible to create a more flexible key binding system by adding more context information to the higher up context ancestors.
while:
may seem redundant, it actually communicates fundamentally different information than:
the first says "the GitPanel is in the right hand dock AND IT IS FOCUSED",
while the second means "Focus is on the Editor, and the GitPanel just happens to be open in the right hand dock"
This change adds a new set of identifiers to the
Workspacekey_context that will indicate which docks are open and what is the specific panel that is currently visible in that dock.examples:
left_dock=ProjectPanelbottom_dock=TerminalPanelright_dock=GitPanelin my testing the following types of keybindings seem to be supported with this change:
some screen shots of the context matching in different circumstances:





the persistent_name values for
ProjectPanelandOutlinePanelneeded to be updated to not have a space in them in order to pass theIdentifiercheck. all the other Panels already had names that did not include spaces, so it just makes these conform with the other ones.I think this is a great place to start with adding more context identifiers and i think this type of additional information will make it possible to create really dynamic keybindings!
Release Notes: