]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiTag.pm
lei: always pass $lei to LeiAuth->op_merge
[public-inbox.git] / lib / PublicInbox / LeiTag.pm
index 9bbf0d79c391a7963f029117781334a7ae37bed5..77654d1a2f2246d270ce5a3ed68888e499f46c36 100644 (file)
@@ -49,7 +49,7 @@ sub lei_tag { # the "lei tag" method
        grep(defined, @$vmd_mod{qw(+kw +L -L -kw)}) or
                return $lei->fail('no keywords or labels specified');
        my $ops = {};
-       $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
+       $lei->{auth}->op_merge($ops, $self, $lei) if $lei->{auth};
        (my $op_c, $ops) = $lei->workers_start($self, 1, $ops);
        $lei->{wq1} = $self;
        $lei->{-err_type} = 'non-fatal';
@@ -74,7 +74,7 @@ sub ipc_atfork_child {
 # Workaround bash word-splitting s to ['kw', ':', 'keyword' ...]
 # Maybe there's a better way to go about this in
 # contrib/completion/lei-completion.bash
-sub _complete_mark_common ($) {
+sub _complete_tag_common ($) {
        my ($argv) = @_;
        # Workaround bash word-splitting URLs to ['https', ':', '//' ...]
        # Maybe there's a better way to go about this in
@@ -104,16 +104,18 @@ sub _complete_mark_common ($) {
 # FIXME: same problems as _complete_forget_external and similar
 sub _complete_tag {
        my ($self, @argv) = @_;
+       require PublicInbox::LeiImport;
+       my @in = PublicInbox::LeiImport::_complete_import(@_);
        my @L = eval { $self->_lei_store->search->all_terms('L') };
-       my @all = ((map { ("+kw:$_", "-kw:$_") } @PublicInbox::LeiInput::KW),
+       my @kwL = ((map { ("+kw:$_", "-kw:$_") } @PublicInbox::LeiInput::KW),
                (map { ("+L:$_", "-L:$_") } @L));
-       return @all if !@argv;
-       my ($cur, $re) = _complete_mark_common(\@argv);
-       map {
+       my ($cur, $re) = _complete_tag_common(\@argv);
+       my @m = map {
                # only return the part specified on the CLI
                # don't duplicate if already 100% completed
                /\A$re(\Q$cur\E.*)/ ? ($cur eq $1 ? () : $1) : ();
-       } grep(/$re\Q$cur/, @all);
+       } grep(/$re\Q$cur/, @kwL);
+       (@in, (@m ? @m : @kwL));
 }
 
 no warnings 'once'; # the following works even when LeiAuth is lazy-loaded