Changeset 76e0e4a


Ignore:
Timestamp:
Sep 30, 2009, 1:02:36 AM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
6035008
Parents:
b06a888
git-author:
David Benjamin <davidben@mit.edu> (09/23/09 00:34:20)
git-committer:
David Benjamin <davidben@mit.edu> (09/30/09 01:02:36)
Message:
Reimplement complete_filter using shift_words

Fixes bug with -c and -b appearing in completion suggestions.

Signed-off-by: David Benjamin <davidben@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl/Complete/Client.pm

    rb06a888 r76e0e4a  
    161161}
    162162
    163 sub complete_filter_args {
    164     my $ctx = shift;
    165     my $arg = shift;
    166     return complete_filter_name() unless $arg;
    167     my $idx = 2; # skip the filter name
    168     while ($idx < $ctx->word) {
    169         last unless ($ctx->words->[$idx] =~ m{^-});
    170         $idx += 2; # skip the flag and the argument
    171     }
    172     return complete_filter_expr($ctx, $idx);
    173 }
    174 
    175163sub complete_help {
    176164    my $ctx = shift;
     
    194182sub complete_filter {
    195183    my $ctx = shift;
     184    # Syntax: filter FILTERNAME FLAGS EXPR
     185
     186    # FILTERNAME
     187    return complete_filter_name() if $ctx->word == 1;
     188
     189    # FLAGS
     190    $ctx = $ctx->shift_words(1); # complete_flags starts at the second word
    196191    return complete_flags($ctx,
    197192        [qw()],
     
    200195           "-b" => \&complete_color,
    201196        },
    202          \&complete_filter_args
     197        # EXPR
     198        sub {
     199            my $ctx = shift;
     200            my $arg = shift;
     201
     202            # We pass stop_at_nonflag, so we can rewind to the start
     203            my $idx = $ctx->word - $arg;
     204            return complete_filter_expr($ctx, $idx);
     205        },
     206        stop_at_nonflag => 1
    203207        );
    204208}
Note: See TracChangeset for help on using the changeset viewer.