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

feat: hide specified files and dirs #2089

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

TobisLee
Copy link
Contributor

Try to fix #694.

Works with the given regex string:
https://github.com/TobisLee/yazi/blob/2fdd7b6f554dd4e15648ed8f611bd83cedd511c8/yazi-shared/src/url/urn.rs#L22
but failed with hidden_rule config:
https://github.com/TobisLee/yazi/blob/2fdd7b6f554dd4e15648ed8f611bd83cedd511c8/yazi-shared/src/url/urn.rs#L23

Cargo shows

error: cyclic package dependency: package `yazi-config v0.4.3 (/home/tlss/repos/rust_project/yazi/yazi-config)` depends on itself. Cycle:
package `yazi-config v0.4.3 (/home/tlss/repos/rust_project/yazi/yazi-config)`
    ... which satisfies path dependency `yazi-config` (locked to 0.4.3) of package `yazi-shared v0.4.3 (/home/tlss/repos/rust_project/yazi/yazi-shared)`
    ... which satisfies path dependency `yazi-shared` (locked to 0.4.3) of package `yazi-fs v0.4.3 (/home/tlss/repos/rust_project/yazi/yazi-fs)`
    ... which satisfies path dependency `yazi-fs` (locked to 0.4.3) of package `yazi-config v0.4.3 (/home/tlss/repos/rust_project/yazi/yazi-config)`
    ... which satisfies path dependency `yazi-config` (locked to 0.4.3) of package `yazi-adapter v0.4.3 (/home/tlss/repos/rust_project/yazi/yazi-adapter)`

@Laughing-q
Copy link

@sxyazi Hi! Thanks for your awesome work on this awesome file manager! Wanted to push this feature a little bit more here haha, recently I'm switching my primary file manager from lf to yazi, and as a python developer I really want to hide the annoying __pycache__ folders and files.
I used to use set hiddenfiles .*:__pycache__:*.pyc to hide it in lf manager. It'd be perfect if yazi has similar option to do so! Thanks!
jsSpPZr59Z

@sxyazi
Copy link
Owner

sxyazi commented Dec 31, 2024

@TobisLee This feature should not be implemented in yazi-shared/src/url/urn.rs because yazi-shared is a fairly low-level crate that provides shared functions and should not contain any business-related code.

You need to implement it in yazi-fs/src/files.rs and add it as a field in Files, similar to the existing filter: Option<Filter>:

filter: Option<Filter>,

Then, pass it from the outside, just like what the set_filter method does:

pub fn set_filter(&mut self, filter: Option<Filter>) -> bool {

@TobisLee TobisLee reopened this Jan 7, 2025
@TobisLee
Copy link
Contributor Author

TobisLee commented Jan 7, 2025

Hey, @sxyazi , I implement ignore_filter in files.rs as you said and test with my environment. I leave some comments about my confusion, hope to hear your thoughts. If there anything else I can do, please let me know.

@sxyazi
Copy link
Owner

sxyazi commented Jan 7, 2025

I leave some comments about my confusion, hope to hear your thoughts

Where these comments are? I didn't see them

@@ -24,7 +24,7 @@ impl Default for Folder {
Self {
url: Default::default(),
cha: Default::default(),
files: Files::new(MANAGER.show_hidden),
files: Files::new(MANAGER.show_hidden, Filter::new(MANAGER.ignore_rule.as_str(), yazi_fs::FilterCase::Smart).ok()),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better place to initialize ignore_filter?

@@ -321,6 +322,13 @@ impl Files {
}

fn split_files(&self, files: impl IntoIterator<Item = File>) -> (Vec<File>, Vec<File>) {
let mut files: Vec<File> = files.into_iter().collect();
if let Some(ignore_filter) = &self.ignore_filter {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if condition will be called lots of times, I think it just should be called when hover a dir? Should it be put in set_ignore_filter or other place?

@TobisLee
Copy link
Contributor Author

TobisLee commented Jan 7, 2025

I submit the review, the comments should be seen now.

@TobisLee
Copy link
Contributor Author

Hey, @sxyazi , can you review this code plz?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide specified files or directories
3 participants