About 1, Path.wildcard uses File.ls underneath, so it would be the same.

About 2, Path.wildcard ignores all dots by default after reading them from
File.ls. We probably want something like this: unless the user explicitly
starts the last segment with a dot, we ignore dots.

Both of these in practice means something like this:

with {:ok, files} <- FIle.ls(dir) do
  if last == "" do
    Enum.reject(files, &String.starts_with?(&1, "."))
  else
    Enum.filter(files, &String.starts_with?(&1, last))
  end
end

Thoughts?

On Thu, Dec 3, 2020 at 5:47 PM Frank Hunleth <fhunl...@troodon-software.com>
wrote:

> On Thu, Dec 3, 2020 at 11:23 AM José Valim <jose.va...@dashbit.co> wrote:
> >
> > Thanks Frank, this sounds good to me. Perhaps the only change I would do
> is to use FIle.ls instead of Path.wildcard. Basically split anything after
> the last "/", ls the directory, and then do String.starts_with?(results,
> last). It will also protect us from wildcard characters and so on. What do
> you think? Would you like to send a PR?
>
> Funny enough, that was my first try. It had two issues: 1. I was
> concerned that tab completion in a directory with tons of files would
> result in large lists being passed around and that Path.wildcard could
> filter earlier, and 2. there was an annoying edge case (with handling
> dots, I think) and Path.wildcard was particularly convenient for
> working around that. At any rate, I'll look again for the PR, since I
> agree that filtering wildcards doesn't seem right.
>
> Yes, I'll send a PR. I'm feeling slow given that a lot is going on
> this week, but I'm on it! (And I'll collect and incorporate any other
> comments posted here too)
>
> Thanks!
> Frank
>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/CA%2B-urNSWw__tZpA8j6FkdEnsbYq37jC%3DbVT3ubNCmRqQU3i7cg%40mail.gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2B-PxxWyV5T98RM_JycaX9VZoCMUEgZ6SQ4VEaw%3DpX_Dw%40mail.gmail.com.

Reply via email to