diff options
Diffstat (limited to 'lib/Reply/Plugin/Autocomplete')
-rw-r--r-- | lib/Reply/Plugin/Autocomplete/Globals.pm | 7 | ||||
-rw-r--r-- | lib/Reply/Plugin/Autocomplete/Lexicals.pm | 10 | ||||
-rw-r--r-- | lib/Reply/Plugin/Autocomplete/Methods.pm | 6 |
3 files changed, 15 insertions, 8 deletions
diff --git a/lib/Reply/Plugin/Autocomplete/Globals.pm b/lib/Reply/Plugin/Autocomplete/Globals.pm index 99ab864..ac2ca3e 100644 --- a/lib/Reply/Plugin/Autocomplete/Globals.pm +++ b/lib/Reply/Plugin/Autocomplete/Globals.pm @@ -7,6 +7,8 @@ use base 'Reply::Plugin'; use Package::Stash; +use Reply::Util qw($fq_ident_rx $fq_varname_rx); + =head1 SYNOPSIS ; .replyrc @@ -32,7 +34,7 @@ sub tab_handler { my $self = shift; my ($line) = @_; - my ($maybe_var) = $line =~ /([\$\@\%\&\*]\s*[0-9A-Z_a-z:]*)$/; + my ($maybe_var) = $line =~ /($fq_varname_rx)$/; return unless $maybe_var; $maybe_var =~ s/\s+//g; @@ -90,8 +92,7 @@ sub _recursive_symbols { # to not also block out punctuation variables. # XXX fix for unicode # XXX fix for variables like ${^GLOBAL_PHASE} - next unless $name =~ /^[A-Z_a-z][0-9A-Z_a-z]*(?:::)?$/ - || length($name) == 1; + next unless $name =~ /^$fq_ident_rx(?:::)?$/ || length($name) == 1; if ($name =~ s/::$//) { my $next = Package::Stash->new(join('::', $stash_name, $name)); diff --git a/lib/Reply/Plugin/Autocomplete/Lexicals.pm b/lib/Reply/Plugin/Autocomplete/Lexicals.pm index 08d4c02..dd953bf 100644 --- a/lib/Reply/Plugin/Autocomplete/Lexicals.pm +++ b/lib/Reply/Plugin/Autocomplete/Lexicals.pm @@ -5,6 +5,8 @@ use warnings; use base 'Reply::Plugin'; +use Reply::Util qw($varname_rx); + =head1 SYNOPSIS ; .replyrc @@ -18,9 +20,6 @@ Perl code. =cut -# XXX unicode? -my $var_name_rx = qr/[\$\@\%]\s*(?:[A-Z_a-z][0-9A-Z_a-z]*)?/; - sub new { my $class = shift; @@ -41,11 +40,14 @@ sub tab_handler { my $self = shift; my ($line) = @_; - my ($var) = $line =~ /($var_name_rx)$/; + my ($var) = $line =~ /($varname_rx)$/; return unless $var; my ($sigil, $name_prefix) = $var =~ /(.)(.*)/; + # these can't be lexicals + return if $sigil eq '&' || $sigil eq '*'; + my $env = { map { %$_ } values %{ $self->{env} } }; my @env = keys %$env; diff --git a/lib/Reply/Plugin/Autocomplete/Methods.pm b/lib/Reply/Plugin/Autocomplete/Methods.pm index 4b1c4f5..7421226 100644 --- a/lib/Reply/Plugin/Autocomplete/Methods.pm +++ b/lib/Reply/Plugin/Autocomplete/Methods.pm @@ -9,6 +9,8 @@ use MRO::Compat; use Package::Stash; use Scalar::Util 'blessed'; +use Reply::Util qw($ident_rx $fq_ident_rx $fq_varname_rx); + =head1 SYNOPSIS ; .replyrc @@ -50,8 +52,10 @@ sub tab_handler { my $self = shift; my ($line) = @_; - my ($invocant, $method) = $line =~ /((?:\$\s*)?[A-Z_a-z][0-9A-Z_a-z:]*)->([A-Z_a-z][0-9A-Z_a-z]*)?$/; + my ($invocant, $method) = $line =~ /($fq_varname_rx|$fq_ident_rx)->($ident_rx)?$/; return unless $invocant; + # XXX unicode + return unless $invocant =~ /^[\$A-Z_a-z]/; $method = '' unless defined $method; |