From: Sartak Date: Sun, 25 May 2008 17:33:28 +0000 (+0000) Subject: Fully recurse so that we can complete more precisely X-Git-Tag: v1.003015~110 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6c3218fee98e0dc35d1ed442197b99f8437b0bee;p=p5sagit%2FDevel-REPL.git Fully recurse so that we can complete more precisely git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@4399 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm b/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm index 6ea06d1..493a886 100644 --- a/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm +++ b/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm @@ -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,18 +81,7 @@ around complete => sub { -d $path or next INC; } - opendir((my $dirhandle), $path); - for my $match (grep { $_ =~ $final_re } readdir $dirhandle) - { - if ($match =~ /\./) { - $match =~ s/\..*// unless $keep_extension; - } - # this is another subdirectory, so we're not done completing - else { - $match .= $outsep; - } - push @found, join $outsep, @directories, $match; - } + $add_recursively->($path, 0); } return $orig->(@_), @found;