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

:open should support globbing / wildcards #5706

Open
LeoniePhiline opened this issue Jan 27, 2023 · 11 comments · Fixed by #9709 · May be fixed by #9723
Open

:open should support globbing / wildcards #5706

LeoniePhiline opened this issue Jan 27, 2023 · 11 comments · Fixed by #9709 · May be fixed by #9723
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@LeoniePhiline
Copy link
Contributor

I haven't found a bug report for this yet - sorry if I missed one!

I had just now wanted to open a whole range of files via :open ~/path/to/prefix_*.

Helix created a new buffer with that name instead of expanding the * and opening all matching files. It would be real neat if globbing was supported!

@LeoniePhiline LeoniePhiline added the C-enhancement Category: Improvements label Jan 27, 2023
@kirawi kirawi added A-helix-term Area: Helix term improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Feb 5, 2023
@mslot
Copy link

mslot commented Feb 9, 2023

Should we have an upper recursive and directory limit that can be overridden? Imagine opening /**/*, or just a directory with one million files in it.

@askreet
Copy link
Contributor

askreet commented Feb 10, 2023

The behavior in (n)vim seems to be:

  • If something looks like a glob pattern, try to match it into a file list.
  • If that works, check to see if there are "too many" files and error out.
  • If that doesn't work, open a buffer with the filename including glob-like characters.

Would we want the mirror that behavior? Seems generally OK to me. The alternative to #3 would be something like error out if no files match and provide a way to escape the glob pattern should you want to edit a file called "file*".

@mslot
Copy link

mslot commented Feb 10, 2023

The behavior in (n)vim seems to be:

* If something looks like a glob pattern, try to match it into a file list.

* If that works, check to see if there are "too many" files and error out.

* If that doesn't work, open a buffer with the filename including glob-like characters.

Would we want the mirror that behavior? Seems generally OK to me. The alternative to #3 would be something like error out if no files match and provide a way to escape the glob pattern should you want to edit a file called "file*".

I think that is a good algorithm. I can accept that.

@Pablu23
Copy link

Pablu23 commented Feb 10, 2023

Hi I would like to try and implement this. Its my first time collaborating, so I was curious if it is allowed to use crates, I would try to implement this with the glob crate.

@the-mikedavis
Copy link
Member

I'm not sure we need globbing support. IMO this overlaps with the file picker and I would rather see multiple selections in the file-picker (#4837) than extending :open. We try to keep the dependency count small so pulling in a new crate just for this would not be ideal.

@the-mikedavis the-mikedavis removed E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Feb 10, 2023
@mslot
Copy link

mslot commented Feb 11, 2023

I'm not sure we need globbing support. IMO this overlaps with the file picker and I would rather see multiple selections in the file-picker (#4837) than extending :open. We try to keep the dependency count small so pulling in a new crate just for this would not be ideal.

I can't see why this shouldn't be supported with :open, because this is one of those things where you would want to quickly point out what to open, and globbing is perfect for that.

I do agree that pulling in another crate is not what we want.

How should globbing be supported? Basic: ** for "all directories under parent" and * for all files in current?

@mo8it
Copy link
Contributor

mo8it commented Feb 22, 2024

A manual implementation would be a waste of dev time and confusing for users in the best case because it won't meet every expectation. I think that we should use a well known implementation. glob is one crate without any dependencies. I would like to implement this if you agree and @Pablu23 doesn't have time (because he asked first).

@the-mikedavis
Copy link
Member

the-mikedavis commented Feb 22, 2024

Actually we recently added globs for file-types using glob globset: #8006

Yeah on second thought I think this would be a reasonable improvement. This is right around where we should expand globs:

let path = helix_stdx::path::expand_tilde(&path);

@pascalkuthe
Copy link
Member

pascalkuthe commented Feb 22, 2024

(We should be using globset and not the glob crate tough)

@mo8it
Copy link
Contributor

mo8it commented Feb 24, 2024

This is not closed 😅 The merged PR is just slightly related.

BTW, globset doesn't offer a recursive iterator. Should I implement it myself or should we add glob?

@gabydd gabydd reopened this Feb 24, 2024
@pascalkuthe
Copy link
Member

You may be able to tell ignore directly to o ly whitelist paths that match a certain glob. If not you should implement an ignore filter that checks a globset glov. You should not be pulling any new libraries in or writing significant amounts of code

@mo8it mo8it linked a pull request Feb 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants