[Bps-public-commit] Prophet branch, master, updated. 0.73-26-gd29766d

sartak at bestpractical.com sartak at bestpractical.com
Wed Dec 23 16:31:17 EST 2009


The branch, master has been updated
       via  d29766da296be3323d6f951f101cc7033c90f4f9 (commit)
      from  3344d7b071efe847fef79fb283606033fc57a31f (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Shell.pm |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit d29766da296be3323d6f951f101cc7033c90f4f9
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Dec 23 16:31:10 2009 -0500

    Fix shell completion

diff --git a/lib/Prophet/CLI/Command/Shell.pm b/lib/Prophet/CLI/Command/Shell.pm
index e7a3924..e1d508b 100644
--- a/lib/Prophet/CLI/Command/Shell.pm
+++ b/lib/Prophet/CLI/Command/Shell.pm
@@ -25,7 +25,7 @@ has term => (
 
         require Term::ReadLine;
         my $term = Term::ReadLine->new("Prophet shell");
-        $term->Attribs->{attempted_completion_function} = sub {
+        $term->Attribs->{completion_function} = sub {
             $weakself->_complete(@_);
         };
         return $term;
@@ -96,15 +96,18 @@ sub _run {
 }
 
 sub _complete {
-    my ($self, $last_word, $line, $start, $end) = @_;
+    my ($self, $last_word, $line, $start) = @_;
 
-    # discard everything after the cursor for completion purposes
-    # we can't just use $text because we want all the text before the cursor to
+    # we can't just use $last_word because we want all the text before the cursor to
     # matter, not just the current word
-    substr($line, $end) = '';
 
     my $dispatcher = $self->cli->dispatcher_class->new(cli => $self->cli);
-    my @matches = $dispatcher->complete($line);
+
+    # We're supposed to return only the completion of $last_word, not replacements
+    # of $line. So for a completion that returns multiple words, this could screw
+    # up and return only its last word.
+    my @matches = map { s/^.* //; $_ } $dispatcher->complete($line);
+
     return @matches;
 }
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list