broot icon indicating copy to clipboard operation
broot copied to clipboard

Restrict search to visible files and directories

Open falconepl opened this issue 3 years ago • 3 comments

Let's assume this is a directory structure that shows up when calling broot:

/Users/me/broot-test
 ├──a …
 ├──a2
 │  ├──bar.txt
 │  └──foo.txt
 ├──a3
 │  ├──bar.txt
 │  └──foo.txt
 ├──a4
 │  ├──bar.txt
 │  └──foo.txt
 └──a5
    └──2 unlisted

When I type f then I've got the following view:

/Users/me/broot-test
 ├──a
 │  └──a/b
 │     └──a/b/c
 │        └──a/b/c/foo.txt
 ├──a2
 │  └──a2/foo.txt
 ├──a3
 │  └──a3/foo.txt
 ├──a4
 │  └──a4/foo.txt
(…)

What do you think about introducing an option in the configuration that allows to search/highlight only those files and directories in a tree that are currently visible? Namely, when enabled, in this example Broot would filter and show/highlight a2/foo.txt, a3/foo.txt and a4/foo.txt, but not a/b/c/foo.txt (because it's not listed before we've started typing).

I think such a feature could be really useful when someone wants to navigate directories with Broot similarly to plain ls + cd (but faster), rather than perform full deep fuzzy search. If there's already some option that allows that, sorry for the request - I couldn't find that in the documentation/issues.

PS: Thanks for the Broot! 🙇‍♂️ Hands down one of the best command line tools ever

falconepl avatar Jul 07 '22 15:07 falconepl

a configuration option doesn't seem convenient, unless I misunderstand your need. Maybe a flag set on the current search ? Or a command to "freeze" the tree ?

Canop avatar Jul 07 '22 15:07 Canop

I guess I will have that option enabled all the time in every session (in every broot run), so that's why I've chosen that term - configuration option. But if that seems to be an odd choice from the perspective of how other things are currently implemented in Broot, of course it could be a flag, a command etc.

It could be that "only visible files" is a bit misleading phrase and that's why the configuration option seems to be a weird choice at first. I think it would be more accurate to describe that new feature like so:

an option/command that restricts file/directory filtering (when typing some name) to only those elements that are present in the current directory as well as all those elements that were displayed before someone started typing

While the default Broot behavior is really powerful (it feels like we're almost searching everywhere, so it speeds things up) I think that this new option/command allows to use Broot in a more - let's call it - traditional way, where we narrow down results when typing only to the current context (the context being files in the current directory as well as those already visible, in some nested directories).

I would love to raise some PR, if this feature sounds useful, but at this moment I've got almost zero experience with Rust 😅 Maybe I could help next time, with some simpler bug fix or some little tweak

falconepl avatar Jul 08 '22 09:07 falconepl

I would love to raise some PR, if this feature sounds useful, but at this moment I've got almost zero experience with Rust

Changing this kind of thing in broot would need more than just experience with Rust. This is kind of complex and core.

Canop avatar Jul 08 '22 09:07 Canop