Skip to content

Commit

Permalink
Fix canonicalization flag
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxxcode committed Jan 25, 2025
1 parent 9befbc8 commit f6c4d41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 8 additions & 0 deletions src/data/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,19 @@ impl Disks {

/// Queries the operating system for disks
pub fn new_native_disks(canonicalize_paths: bool) -> Self {
println!("LOADING_DISKS: {canonicalize_paths}");
Self {
disks: load_disks(canonicalize_paths),
}
}

/// Creates an empty list of Disks
pub fn new_empty() -> Self {
Self {
disks: Vec::new(),
}
}

/// Very simple wrapper method of the disks `.iter()` method.
/// No trait is implemented since this is currently only used internal.
pub(crate) fn iter(&self) -> std::slice::Iter<'_, Disk> {
Expand Down
12 changes: 3 additions & 9 deletions src/file_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ impl FileDialog {

window_id: egui::Id::new("file_dialog"),

user_directories: file_system.user_dirs(true),
system_disks: file_system.get_disks(true),
user_directories: None,
system_disks: Disks::new_empty(),

directory_stack: Vec::new(),
directory_offset: 0,
Expand Down Expand Up @@ -246,9 +246,6 @@ impl FileDialog {
pub fn with_config(config: FileDialogConfig) -> Self {
let mut obj = Self::new();
*obj.config_mut() = config;

obj.refresh();

obj
}

Expand Down Expand Up @@ -320,6 +317,7 @@ impl FileDialog {
operation_id: Option<&str>,
) -> io::Result<()> {
self.reset();
self.refresh();

if mode == DialogMode::PickFile {
show_files = true;
Expand Down Expand Up @@ -568,10 +566,6 @@ impl FileDialog {
/// already canonicalized path is then set as the initial directory.
pub fn canonicalize_paths(mut self, canonicalize: bool) -> Self {
self.config.canonicalize_paths = canonicalize;

// Reload data like system disks and user directories with the updated canonicalization.
self.refresh();

self
}

Expand Down

0 comments on commit f6c4d41

Please sign in to comment.