Add sort_by_file_name config for file_picker

pull/11594/head
cedricbuild 3 months ago
parent af7a1fd20c
commit 1f67d15196

@ -191,10 +191,13 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
.git_ignore(config.file_picker.git_ignore) .git_ignore(config.file_picker.git_ignore)
.git_global(config.file_picker.git_global) .git_global(config.file_picker.git_global)
.git_exclude(config.file_picker.git_exclude) .git_exclude(config.file_picker.git_exclude)
.sort_by_file_name(|name1, name2| name1.cmp(name2))
.max_depth(config.file_picker.max_depth) .max_depth(config.file_picker.max_depth)
.filter_entry(move |entry| filter_picker_entry(entry, &absolute_root, dedup_symlinks)); .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_loader::config_dir().join("ignore"));
walk_builder.add_custom_ignore_filename(".helix/ignore"); walk_builder.add_custom_ignore_filename(".helix/ignore");

@ -197,6 +197,9 @@ pub struct FilePickerConfig {
/// WalkBuilder options /// WalkBuilder options
/// Maximum Depth to recurse directories in file picker and global search. Defaults to `None`. /// Maximum Depth to recurse directories in file picker and global search. Defaults to `None`.
pub max_depth: Option<usize>, pub max_depth: Option<usize>,
/// Sort File names
/// File Picker will not when, it is set to true.
pub sort_by_file_name: bool,
} }
impl Default for FilePickerConfig { impl Default for FilePickerConfig {
@ -211,6 +214,7 @@ impl Default for FilePickerConfig {
git_global: true, git_global: true,
git_exclude: true, git_exclude: true,
max_depth: None, max_depth: None,
sort_by_file_name: false,
} }
} }
} }

Loading…
Cancel
Save