[Bps-public-commit] Prophet branch, master, updated. 0.73-25-g3344d7b

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


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

Summary of changes:
 lib/Prophet/CLI/Command/Shell.pm |   35 ++++-------------------------------
 1 files changed, 4 insertions(+), 31 deletions(-)

- Log -----------------------------------------------------------------
commit 3344d7b071efe847fef79fb283606033fc57a31f
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Dec 23 16:23:28 2009 -0500

    Simplify the completion logic. It's still broken, but closer

diff --git a/lib/Prophet/CLI/Command/Shell.pm b/lib/Prophet/CLI/Command/Shell.pm
index 90e201a..e7a3924 100644
--- a/lib/Prophet/CLI/Command/Shell.pm
+++ b/lib/Prophet/CLI/Command/Shell.pm
@@ -32,18 +32,6 @@ has term => (
     },
 );
 
-has current_matches => (
-    is      => 'rw',
-    isa     => 'ArrayRef',
-    default => sub { [] },
-);
-
-has match_index => (
-    is      => 'rw',
-    isa     => 'Int',
-    default => 0,
-);
-
 our $HIST = $ENV{PROPHET_HISTFILE}
         || (($ENV{HOME} || (getpwuid($<))[7]) . "/.prophetreplhist");
 our $LEN = $ENV{PROPHET_HISTLEN} || 500;
@@ -108,31 +96,16 @@ sub _run {
 }
 
 sub _complete {
-    my ($self, $text, $line, $start, $end) = @_;
+    my ($self, $last_word, $line, $start, $end) = @_;
 
-    # we're discarding everything after the cursor for completion purposes. in the
-    # future we may be able to be smarter, but for now it's good enough.
-    # we can't just use $text because we want all the code before the cursor to
+    # discard everything after the cursor for completion purposes
+    # we can't just use $text 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);
-
-    # iterate through the completions
-    return $self->term->completion_matches($line, sub {
-        my ($text, $state) = @_;
-
-        if (!$state) {
-            $self->current_matches(\@matches);
-            $self->match_index(0);
-        }
-        else {
-            $self->match_index($self->match_index + 1);
-        }
-
-        return $self->current_matches->[$self->match_index];
-    });
+    return @matches;
 }
 
 # make the REPL history persistent

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



More information about the Bps-public-commit mailing list