diff --git a/src/app/file_list.rs b/src/app/file_list.rs index a788faa..92ff275 100644 --- a/src/app/file_list.rs +++ b/src/app/file_list.rs @@ -165,10 +165,12 @@ impl App { pub(super) fn left_pane(&mut self, ctx: &egui::Context) { let show_files = self.config.show_file_panel; if show_files { - egui::SidePanel::left("files") + let panel = egui::SidePanel::left("files") .resizable(true) - .width_range(260.0..=600.0) - .show(ctx, |ui| { + .default_width(self.config.file_panel_width) + .width_range(260.0..=600.0); + + let response = panel.show(ctx, |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. @@ -604,6 +606,13 @@ impl App { }); } }); + + // Update the config with the current panel width if it changed + 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; + self.config.save(); + } } } } diff --git a/src/config.rs b/src/config.rs index c3dd2ea..fa7def2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,6 +20,9 @@ pub struct Config { /// leaves nothing on screen but the page. #[serde(default = "default_show_toolbar")] pub show_file_panel: bool, + /// Width of the left-hand file list panel in pixels. + #[serde(default = "default_file_panel_width")] + pub file_panel_width: f32, /// Whether the editor hides the editorial header, showing the prose alone. #[serde(default)] pub collapse_header: bool, @@ -184,6 +187,11 @@ pub fn default_show_toolbar() -> bool { true } +/// Default width for the file list panel. +pub fn default_file_panel_width() -> f32 { + 260.0 +} + /// Default cookiecutter template for **File ▸ New project…**. /// Uses the bundled template from the project's templates/snowflake directory. pub fn default_project_template() -> PathBuf { @@ -326,6 +334,7 @@ impl Default for Config { show_preview: false, show_toolbar: default_show_toolbar(), show_file_panel: default_show_toolbar(), + file_panel_width: default_file_panel_width(), collapse_header: false, show_reference_files: false, draft_marker: default_marker(),