Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to define dotfiles to be exposed in file picker #5924

Closed
Prev Previous commit
Next Next commit
Cargo fmt
Mordeaux committed Apr 21, 2023
commit 1dc6afaf76cba2c60f708edc29e25ebf272b2632
23 changes: 11 additions & 12 deletions helix-term/src/ui/mod.rs
Original file line number Diff line number Diff line change
@@ -179,37 +179,36 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
.max_depth(config.file_picker.max_depth)
.filter_entry(move |entry| filter_picker_entry(entry, &absolute_root, dedup_symlinks));


// We want some dotfiles to remain visible
let mut defined_dots = vec!["github".to_string(),
"gitattributes".to_string(),
"gitignore".to_string()];
let mut defined_dots = vec![
"github".to_string(),
"gitattributes".to_string(),
"gitignore".to_string(),
];

if let Some(user_dots) = &config.file_picker.include_hidden {
defined_dots.extend(user_dots.to_owned().into_iter());
defined_dots.extend(user_dots.to_owned().into_iter());
}

let add_str = defined_dots.join(",").to_owned();


// We want to exclude files that the editor can't handle yet
let mut type_builder = TypesBuilder::new();
type_builder
.add(
"compressed",
"*.{zip,gz,bz2,zst,lzo,sz,tgz,tbz2,lz,lz4,lzma,lzo,z,Z,xz,7z,rar,cab}")
"*.{zip,gz,bz2,zst,lzo,sz,tgz,tbz2,lz,lz4,lzma,lzo,z,Z,xz,7z,rar,cab}",
)
.expect("Invalid type definition -- compressed");

type_builder
.add_defaults()
.add(
"hidden",
format!(".{{{}}}", add_str).as_str())
.add("hidden", format!(".{{{}}}", add_str).as_str())
.expect("Invalid type definition -- hidden");

type_builder.select("all");
type_builder.negate("compressed");

let defined_types = type_builder
.build()
.expect("failed to build excluded_types");
4 changes: 2 additions & 2 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
@@ -193,10 +193,10 @@ pub struct FilePickerConfig {
/// Maximum Depth to recurse directories in file picker and global search. Defaults to `None`.
pub max_depth: Option<usize>,
/// Enables user to define a list of dotfiles to be included when hidden is set to true
pub include_hidden: Option<Vec<String>>
pub include_hidden: Option<Vec<String>>,
}

impl Default for FilePickerConfig{
impl Default for FilePickerConfig {
fn default() -> Self {
Self {
hidden: true,