X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FCompletionDriver%2FGlobals.pm;h=a8b42a9a1fd1980e292e93ddf3e3eaf0ad6b382c;hp=798ba510be3a65650ddfc6ada53bda93536d4440;hb=6631e15ccd2313ff350fd9bfa44c1ccdbac77100;hpb=908733a9f76e870c4518684ccd9c20ea692fd98c diff --git a/lib/Devel/REPL/Plugin/CompletionDriver/Globals.pm b/lib/Devel/REPL/Plugin/CompletionDriver/Globals.pm index 798ba51..a8b42a9 100644 --- a/lib/Devel/REPL/Plugin/CompletionDriver/Globals.pm +++ b/lib/Devel/REPL/Plugin/CompletionDriver/Globals.pm @@ -2,6 +2,10 @@ package Devel::REPL::Plugin::CompletionDriver::Globals; use Devel::REPL::Plugin; use namespace::clean -except => [ 'meta' ]; +with qw( + Devel::REPL::Plugin::Completion +); + around complete => sub { my $orig = shift; my ($self, $text, $document) = @_; @@ -9,9 +13,10 @@ around complete => sub { my $last = $self->last_ppi_element($document); return $orig->(@_) - unless $last->isa('PPI::Token::Symbol'); + unless $last->isa('PPI::Token::Symbol') + || $last->isa('PPI::Token::Word'); - my $sigil = substr($last, 0, 1, ''); + my $sigil = $last =~ s/^[\$\@\%\&\*]// ? $1 : undef; my $re = qr/^\Q$last/; my @package_fragments = split qr/::|'/, $last; @@ -49,3 +54,15 @@ around complete => sub { 1; +__END__ + +=head1 NAME + +Devel::REPL::Plugin::CompletionDriver::Globals - Complete global variables, packages, namespaced functions + +=head1 AUTHOR + +Shawn M Moore, C<< >> + +=cut +