[Bast-commits] r4399 - trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver

Sartak at dev.catalyst.perl.org Sartak at dev.catalyst.perl.org
Sun May 25 18:33:29 BST 2008


Author: Sartak
Date: 2008-05-25 18:33:28 +0100 (Sun, 25 May 2008)
New Revision: 4399

Modified:
   trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm
Log:
Fully recurse so that we can complete more precisely


Modified: trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm
===================================================================
--- trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm	2008-05-25 17:13:51 UTC (rev 4398)
+++ trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm	2008-05-25 17:33:28 UTC (rev 4399)
@@ -49,6 +49,29 @@
 
   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 @@
       -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;




More information about the Bast-commits mailing list