feat: Add file panel width persistence to config
- Add file_panel_width field to Config struct with default of 260.0 - Use stored width as default_width for the file list panel - Update config when panel is resized by dragging separator - This ensures panel maintains its width across sessions and only changes when user explicitly drags the separator Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
+12
-3
@@ -165,10 +165,12 @@ impl App {
|
|||||||
pub(super) fn left_pane(&mut self, ctx: &egui::Context) {
|
pub(super) fn left_pane(&mut self, ctx: &egui::Context) {
|
||||||
let show_files = self.config.show_file_panel;
|
let show_files = self.config.show_file_panel;
|
||||||
if show_files {
|
if show_files {
|
||||||
egui::SidePanel::left("files")
|
let panel = egui::SidePanel::left("files")
|
||||||
.resizable(true)
|
.resizable(true)
|
||||||
.width_range(260.0..=600.0)
|
.default_width(self.config.file_panel_width)
|
||||||
.show(ctx, |ui| {
|
.width_range(260.0..=600.0);
|
||||||
|
|
||||||
|
let response = panel.show(ctx, |ui| {
|
||||||
// The default theme renders unselected list rows fairly dim; bump
|
// The default theme renders unselected list rows fairly dim; bump
|
||||||
// the widget text colours so file names stay legible (especially in
|
// the widget text colours so file names stay legible (especially in
|
||||||
// dark mode) without affecting the rest of the app.
|
// 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ pub struct Config {
|
|||||||
/// leaves nothing on screen but the page.
|
/// leaves nothing on screen but the page.
|
||||||
#[serde(default = "default_show_toolbar")]
|
#[serde(default = "default_show_toolbar")]
|
||||||
pub show_file_panel: bool,
|
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.
|
/// Whether the editor hides the editorial header, showing the prose alone.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub collapse_header: bool,
|
pub collapse_header: bool,
|
||||||
@@ -184,6 +187,11 @@ pub fn default_show_toolbar() -> bool {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Default width for the file list panel.
|
||||||
|
pub fn default_file_panel_width() -> f32 {
|
||||||
|
260.0
|
||||||
|
}
|
||||||
|
|
||||||
/// Default cookiecutter template for **File ▸ New project…**.
|
/// Default cookiecutter template for **File ▸ New project…**.
|
||||||
/// Uses the bundled template from the project's templates/snowflake directory.
|
/// Uses the bundled template from the project's templates/snowflake directory.
|
||||||
pub fn default_project_template() -> PathBuf {
|
pub fn default_project_template() -> PathBuf {
|
||||||
@@ -326,6 +334,7 @@ impl Default for Config {
|
|||||||
show_preview: false,
|
show_preview: false,
|
||||||
show_toolbar: default_show_toolbar(),
|
show_toolbar: default_show_toolbar(),
|
||||||
show_file_panel: default_show_toolbar(),
|
show_file_panel: default_show_toolbar(),
|
||||||
|
file_panel_width: default_file_panel_width(),
|
||||||
collapse_header: false,
|
collapse_header: false,
|
||||||
show_reference_files: false,
|
show_reference_files: false,
|
||||||
draft_marker: default_marker(),
|
draft_marker: default_marker(),
|
||||||
|
|||||||
Reference in New Issue
Block a user