fix: Use show_animated with width persistence for file panel
- Use show_animated instead of show() to maintain egui's animation - Add .default_width() from config - Update config when panel width changes - This should allow the panel to maintain its width after resizing Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
+7
-10
@@ -164,13 +164,11 @@ impl App {
|
||||
/// editor rather than leaving an empty column.
|
||||
pub(super) fn left_pane(&mut self, ctx: &egui::Context) {
|
||||
let show_files = self.config.show_file_panel;
|
||||
if show_files {
|
||||
let panel = egui::SidePanel::left("files")
|
||||
.resizable(true)
|
||||
.default_width(self.config.file_panel_width)
|
||||
.width_range(260.0..=600.0);
|
||||
|
||||
let response = panel.show(ctx, |ui| {
|
||||
if let Some(response) = egui::SidePanel::left("files")
|
||||
.resizable(true)
|
||||
.default_width(self.config.file_panel_width)
|
||||
.width_range(260.0..=600.0)
|
||||
.show_animated(ctx, show_files, |ui| {
|
||||
// The default theme renders unselected list rows fairly dim; bump
|
||||
// the widget text colours so file names stay legible (especially in
|
||||
// dark mode) without affecting the rest of the app.
|
||||
@@ -605,9 +603,8 @@ impl App {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Update the config with the current panel width if it changed
|
||||
}) {
|
||||
// Update the config with the current panel width
|
||||
let new_width = response.response.rect.width();
|
||||
if (new_width - self.config.file_panel_width).abs() > 0.1 {
|
||||
self.config.file_panel_width = new_width;
|
||||
|
||||
Reference in New Issue
Block a user