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

Toggle hidden files in file picker #7846

Closed
Connortsui20 opened this issue Aug 6, 2023 · 11 comments
Closed

Toggle hidden files in file picker #7846

Connortsui20 opened this issue Aug 6, 2023 · 11 comments
Labels
C-enhancement Category: Improvements

Comments

@Connortsui20
Copy link
Contributor

Following discussion #7291.

I think it would be really nice to be able to toggle hidden files, not just for the reasons mentioned above, but also because for large directories (~), there is a 100,000 limit for the number of files, and I had a situation where I had quite a lot of hidden files, and was not able to find my non-hidden files without turning this off in my config. Edge case example I guess: the things mentioned in #7291 make sense to me.

I think behavior could be something like this:

  • Triggering a command (maybe ctrl + h or something like that) is equivalent to toggling hidden under [editor.file-picker], but it updates at runtime inside the file picker
  • The currently selected file does not change when hitting ctrl + h, but more files "fill up" around it (not sure where the selected file will actually be on the screen...)
  • If a hidden file is selected when we toggle back to hiding hidden files, then it recalculates an entry based on what is entered in the search bar (or if nothing is there, maybe it goes to the closest thing to what was previously selected?)

Implementation wise, this might be a bit awkward since WalkBuilder from the ignore crate is being used as soon as the file picker is opened. If hidden is set to true, then it will bring in all of the files that are not hidden, and no more. It will then use these files as a basis for the file picker.

This sort of presents a problem: If hidden is set to true by default, and we want to be able to toggle hidden files, we either have to manually bring in hidden files (bad), rebuild the Walk iterator and get the files again (also bad), or 2 other things that I can think of. 1 option is to build another WalkBuilder and carry two vectors of files around, which shouldn't introduce that much overhead unless the file is really large.

A better option, and one that I think could work well with low overhead, is to tag each file path in the vector with hidden or unhidden, so that we only carry around 1 vector of paths (either as a tuple with a bool flag or an enum). Build two WalkBuilder, one with hidden set to true and the other false, and depending on their diffs mark a path as hidden or unhidden (could use the iter_diff crate here for this). When ctrl + h or similar is pressed, we just set matches in Picker accordingly. Even with 100,000 files in one of those iterators this should be low overhead. It even presents a nice additional feature: if 100,000 files are in the file picker, we can prioritize the ones that are not hidden.

I'd love to give this implementation a go, but if the behavior above seems ridiculous to people, I'd like to hear that before working on it.

@Connortsui20 Connortsui20 added the C-enhancement Category: Improvements label Aug 6, 2023
@pascalkuthe
Copy link
Member

pascalkuthe commented Aug 6, 2023

I am not in favor of adding these bindings at all. Hidden files specifically can be enabled in your cinfig and you can use negative matches to remove them if they are needed.

There are about 5 settings that ci tril which fukes are hidden from the picker. Should we really have a picker krybindjng for all if them? I also don't see the usecase if tiggeling these while the licker is Olen. You can simply :toggle the existing config option.

Implementation wise any implementation should wait for #7814. That PR enables all oicmers to stream in matches and also makes the file picker run in background. That atleast alleviates the file limit and the concern about slowness if crawling hidden files (which is signicant). But I still don't think this should have dedicated picker keybindings over just using :set/toggle.

Thus could be to add as an optionak binding once #5505 is resolved but U don't think we should add 5 different binding to the oikcer by default (or choose inky one iof them)

@gabydd
Copy link
Member

gabydd commented Aug 6, 2023

not sure if we do need this but my preferred solution would be one keybinding/command to rewalk the directory and then #5505 for custom keybindings to toggle each file-picker option. So there doesn't have to be a command for each option

@pascalkuthe
Copy link
Member

Ah it seems there was a new discussion. I thought you came from the old one.

In that case duplicate of #7712

@pascalkuthe pascalkuthe closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2023
@pascalkuthe
Copy link
Member

pascalkuthe commented Aug 6, 2023

not sure if we do need this but my preferred solution would be one keybinding/command to rewalk the directory and then #5505 for custom keybindings to toggle each file-picker option. So there doesn't have to be a command for each option

Yeah that's reasonable but any implementation needs to wait until #5505 is resolved (potentially quite a while away)

@Connortsui20
Copy link
Contributor Author

Ah #5505 seems very nice and yes it would be good to wait for that

@Connortsui20
Copy link
Contributor Author

I am not in favor of adding these bindings at all. Hidden files specifically can be enabled in your cinfig and you can use negative matches to remove them if they are needed.

How would you use negative matches for getting rid of hidden files?

@pascalkuthe
Copy link
Member

#7712 (comment)

You can enable hidden files and then make the fuzzy matter filter them. Nucleo (the new fuzzy matcher) will be fast enough to make this always practical altough it works on mater too

@Connortsui20
Copy link
Contributor Author

I feel like that is something worthy of being in the docs

@pascalkuthe
Copy link
Member

Not necessarily in the docs, thoseare supposed to be a concise technical manual but it would be a good fit for the communicrt wiki

@Connortsui20
Copy link
Contributor Author

Just realized something (didn't know where else to comment this), if a directory has more than 100,000 files, even if someone hides the hidden files with !/. !^., it might not show all of the non-hidden files because it cuts off 100,000 before that filter, and even though 100,000 seems like a lot, if you are in ~ it is actually quite easy to get to that number

@gabydd
Copy link
Member

gabydd commented Aug 6, 2023

Once #7814 is merged we won't be limited to 1000 files anymore because the walker results are streamed to the fuzzy matcher we don't need to limit the amount of files anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

3 participants