summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn M Moore <code@sartak.org>2013-06-27 14:37:20 -0400
committerShawn M Moore <code@sartak.org>2013-06-27 14:37:20 -0400
commitff7e2097b3ff2e56337361cab9c1d348413166a4 (patch)
tree30e9d1a8647c1f455aca7162179bdfa31fbbc35a
parent848fe02434cc19f77a976763d563d76044496ea7 (diff)
downloadreply-ff7e2097b3ff2e56337361cab9c1d348413166a4.tar.gz
reply-ff7e2097b3ff2e56337361cab9c1d348413166a4.zip
Let readline present all matches and iterate over them
-rw-r--r--lib/Reply/Plugin/ReadLine.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Reply/Plugin/ReadLine.pm b/lib/Reply/Plugin/ReadLine.pm
index e0675b6..f4ef2cd 100644
--- a/lib/Reply/Plugin/ReadLine.pm
+++ b/lib/Reply/Plugin/ReadLine.pm
@@ -90,18 +90,23 @@ sub DESTROY {
sub _register_tab_complete {
my $self = shift;
+ my $term = $self->{term};
my $completion_handler = $self->{tab_handler};
- if ($self->{term}->ReadLine eq 'Term::ReadLine::Gnu') {
- $self->{term}->Attribs->{attempted_completion_function} = sub {
+ if ($term->ReadLine eq 'Term::ReadLine::Gnu') {
+ $term->Attribs->{attempted_completion_function} = sub {
my ($text, $line, $start, $end) = @_;
# discard everything after the cursor for completion purposes
substr($line, $end) = '';
my @matches = $completion_handler->($line);
+ my $match_index = 0;
- return @matches;
+ return $term->completion_matches($text, sub {
+ my ($text, $index) = @_;
+ return $matches[$index];
+ });
};
}
}