From 1f67d15196634d04cd71be9734fcdb000e6a3a29 Mon Sep 17 00:00:00 2001 From: cedricbuild Date: Wed, 28 Aug 2024 17:21:06 +0000 Subject: [PATCH] Add sort_by_file_name config for file_picker --- helix-term/src/ui/mod.rs | 5 ++++- helix-view/src/editor.rs | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 6a3e198c1..62c86a479 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -191,10 +191,13 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi .git_ignore(config.file_picker.git_ignore) .git_global(config.file_picker.git_global) .git_exclude(config.file_picker.git_exclude) - .sort_by_file_name(|name1, name2| name1.cmp(name2)) .max_depth(config.file_picker.max_depth) .filter_entry(move |entry| filter_picker_entry(entry, &absolute_root, dedup_symlinks)); + if config.file_picker.sort_by_file_name { + walk_builder.sort_by_file_name(|name1, name2| name1.cmp(name2)); + } + walk_builder.add_custom_ignore_filename(helix_loader::config_dir().join("ignore")); walk_builder.add_custom_ignore_filename(".helix/ignore"); diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 1708b3b4e..93542d1a4 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -197,6 +197,9 @@ pub struct FilePickerConfig { /// WalkBuilder options /// Maximum Depth to recurse directories in file picker and global search. Defaults to `None`. pub max_depth: Option, + /// Sort File names + /// File Picker will not when, it is set to true. + pub sort_by_file_name: bool, } impl Default for FilePickerConfig { @@ -211,6 +214,7 @@ impl Default for FilePickerConfig { git_global: true, git_exclude: true, max_depth: None, + sort_by_file_name: false, } } }