X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FCompletion.pm;h=ad7c25f1c17e546544de667349ab8a301d687014;hp=b54648818118b6667c2adf1a7c12e62a55bb8149;hb=33628ecb3689f2719563d0a9ae82d3ccec1a4cbb;hpb=ac71b56c5190c52154ecd3d54fffbfdd0ea0a3d4 diff --git a/lib/Devel/REPL/Plugin/Completion.pm b/lib/Devel/REPL/Plugin/Completion.pm index b546488..ad7c25f 100644 --- a/lib/Devel/REPL/Plugin/Completion.pm +++ b/lib/Devel/REPL/Plugin/Completion.pm @@ -54,9 +54,9 @@ around 'eval' => sub { my @ret = $self->$orig($line); # the namespace of the loaded module - if ($line =~ /use\s+(\S+)/) { + if ($line =~ /\buse\s+(\S+)/) { my $module = $1; - foreach my $keyword (keys %{$self->get_namespace($module)}) { + foreach my $keyword (keys %{$self->get_namespace($module) || {}}) { $self->push_completion($keyword); } } @@ -67,7 +67,7 @@ around 'eval' => sub { foreach my $var (keys %{$lex->get_context('_')}) { $var = substr($var, 1); # we drop the variable idiom as it confuses the completion $self->push_completion($var) unless - grep /^${var}$/, @{$self->term->Attribs->{completion_word}}; + grep $_ eq $var, @{$self->term->Attribs->{completion_word}}; } return @ret;