X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FCompletionDriver%2FINC.pm;h=493a886c2ddcd394c3a613ba51a4d34582b6fbad;hb=6c3218fee98e0dc35d1ed442197b99f8437b0bee;hp=d2996e37fa6d2eb13c017c2dcd2cf4d4f27f45c6;hpb=f1f5a418da8015158eba44556eed1cce6341dc38;p=p5sagit%2FDevel-REPL.git diff --git a/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm b/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm index d2996e3..493a886 100644 --- a/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm +++ b/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm @@ -30,14 +30,14 @@ around complete => sub { # require "Module" if ($package->isa('PPI::Token::Quote')) { - $outsep = $insep = '/'; - $keep_extension = 1; + $outsep = $insep = '/'; + $keep_extension = 1; } elsif ($package =~ /'/) { - # the goofball is using the ancient ' package sep, we'll humor him - $outsep = q{'}; - $insep = "'|::"; + # the goofball is using the ancient ' package sep, we'll humor him + $outsep = q{'}; + $insep = "'|::"; } my @directories = split $insep, $package; @@ -49,6 +49,29 @@ around complete => sub { my @found; + my $add_recursively; + $add_recursively = sub { + my ($path, $iteration, @more) = @_; + opendir((my $dirhandle), $path); + for (readdir $dirhandle) + { + next if /^\.+$/; # skip . and .. + next if $iteration == 0 && $_ !~ $final_re; + + my $match = $_; + my $fullmatch = File::Spec->rel2abs($match, $path); + if (-d $fullmatch) + { + $add_recursively->($fullmatch, $iteration + 1, @more, $match); + } + else + { + $match =~ s/\..*// unless $keep_extension; + push @found, join $outsep, @directories, @more, $match; + } + } + }; + INC: for (@INC) { my $path = $_; @@ -58,12 +81,7 @@ around complete => sub { -d $path or next INC; } - opendir((my $dirhandle), $path); - for my $match (grep { $_ =~ $final_re } readdir $dirhandle) - { - $match =~ s/\..*// unless $keep_extension; - push @found, join $outsep, @directories, $match; - } + $add_recursively->($path, 0); } return $orig->(@_), @found;