workspace: Reset all configured dock panels - #62552
Conversation
dinocosta
left a comment
There was a problem hiding this comment.
Hey @austincummings ! 👋
Thank you for taking a stab at this. The overall approach seems good to me but I left some comments because I think some of the method names can be confusing for future readers.
Overall, I think the approach should be to have some "generic" names on the Dock's public methods, something like Dock::resize_panel_sizes Dock::reset_panel_sizes and then have some private helpers that either resize/reset only the active panel or all panels in the Dock.
Thanks!
| fn resizes_all_panels(&self, cx: &App) -> bool { | ||
| WorkspaceSettings::get_global(cx) | ||
| .resize_all_panels_in_dock | ||
| .contains(&self.position) | ||
| } |
There was a problem hiding this comment.
We should probably rename this, as I got confused reviewing the code due to the fact that we now have both Dock::resizes_all_panels and Dock::resize_all_panels.
I'd suggest renaming to Dock::should_resize_all_panels 🙂
There was a problem hiding this comment.
Renamed this to Dock::should_resize_all_panels to make the predicate distinct from Dock::resize_all_panels.
| dock.update(cx, |dock, cx| { | ||
| dock.reset_active_panel_size(window, cx); | ||
| }); |
There was a problem hiding this comment.
I found the Dock::reset_active_panel_size to be a bit confusing here, as it can also end up resetting the size for all panels in the dock. I believe that introducing a Dock::reset_panel_sizes method that simply checks whether all panels should be resized and the dispatched to either Dock::reset_all_panels_size or Dock::reset_active_panel_size might be easier to follow.
There was a problem hiding this comment.
Renamed resize_panels to resize_panel_sizes in 62a453d. I left the reset API unchanged for now so that naming change can be considered separately.
There was a problem hiding this comment.
Updated in 6eb5570. Dock now exposes reset_panel_sizes, which dispatches to private reset_active_panel_size and reset_all_panel_sizes helpers. resize_active_panel is private as well, leaving resize_panel_sizes and reset_panel_sizes as the public operations.
| @@ -7695,32 +7695,20 @@ impl Workspace { | |||
| |workspace: &mut Workspace, _: &ResetActiveDockSize, window, cx| { | |||
| for dock in workspace.all_docks() { | |||
There was a problem hiding this comment.
Unrelated to these changes, but we can also update this to leverage Workspace::active_dock 👍
There was a problem hiding this comment.
Updated in 6eb5570. ResetActiveDockSize now uses Workspace::active_dock instead of searching all docks directly.
Closes #57388.
When a dock is listed in
resize_all_panels_in_dock, reset its compatible panels to the active panel's default size. This applies to the reset actions and resize-handle double-clicks. Docks not listed in the setting continue to reset only the active panel.Adds regression coverage for fixed panels with different defaults, flexible panels, and active-panel-only resets.
Release Notes:
resize_all_panels_in_dockis enabled.