summaryrefslogtreecommitdiff
path: root/lib/perl5db.pl
diff options
context:
space:
mode:
authorSteffen Mueller <smueller@cpan.org>2009-05-31 21:57:24 +0200
committerSteffen Mueller <smueller@cpan.org>2009-05-31 22:36:29 +0200
commitd22862789d0938361a070647ab6fe995d674f77c (patch)
treeeccf93dc62cdb7503a3755f1d6d2a0e47618d4d5 /lib/perl5db.pl
parentc494f1f4488c4f068dec8514f981347f6dae60a6 (diff)
downloadperl-d22862789d0938361a070647ab6fe995d674f77c.tar.gz
Auto-complete lexicals in the debugger shell
When typing the name of a lexical variable in the debugger shell, its name can now be tab auto-completed just like package variables. Requires PadWalker to be available. Silently skips lexicals if it's not.
Diffstat (limited to 'lib/perl5db.pl')
-rw-r--r--lib/perl5db.pl29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index 9162d16212..b8512123a6 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -8610,7 +8610,6 @@ If there's only one hit, and it's a package qualifier, and it's not equal to the
=cut
if ( $text =~ /^[\$@%]/ ) { # symbols (in $package + packages in main)
-
=pod
=over 4
@@ -8634,6 +8633,32 @@ We set the prefix to the item's sigil, and trim off the sigil to get the text to
$prefix = substr $text, 0, 1;
$text = substr $text, 1;
+ my @out;
+
+=pod
+
+=item *
+
+We look for the lexical scope above DB::DB and auto-complete lexical variables
+if PadWalker could be loaded.
+
+=cut
+
+ if (not $text =~ /::/ and eval "require PadWalker; 1" and not $@ ) {
+ my $level = 1;
+ while (1) {
+ my @info = caller($level);
+ $level++;
+ $level = -1, last
+ if not @info;
+ last if $info[3] eq 'DB::DB';
+ }
+ if ($level > 0) {
+ my $lexicals = PadWalker::peek_my($level);
+ push @out, grep /^\Q$prefix$text/, keys %$lexicals;
+ }
+ }
+
=pod
=item *
@@ -8642,7 +8667,7 @@ If the package is C<::> (C<main>), create an empty list; if it's something else,
=cut
- my @out = map "$prefix$_", grep /^\Q$text/,
+ push @out, map "$prefix$_", grep /^\Q$text/,
( grep /^_?[a-zA-Z]/, keys %$pack ),
( $pack eq '::' ? () : ( grep /::$/, keys %:: ) );