complete_api_path: minimize completions

This commit is contained in:
Dietmar Maurer 2018-07-24 11:29:22 +02:00
parent 6b66e46c72
commit a00bef992d

View File

@ -203,21 +203,20 @@ sub complete_api_path {
if (my $children = $info->{children}) { if (my $children = $info->{children}) {
foreach my $c (@$children) { foreach my $c (@$children) {
my $ctext = $c->{text}; my $ctext = $c->{text};
push @$res, "${prefix}$ctext" if $ctext =~ m/^\Q$rest/;
if ($ctext =~ m/^\{(\S+)\}$/) { if ($ctext =~ m/^\{(\S+)\}$/) {
push @$res, "$prefix$ctext"; if (length($rest) && $rest ne $ctext) {
push @$res, "$prefix$ctext/";
if (length($rest)) {
push @$res, "$prefix$rest"; push @$res, "$prefix$rest";
push @$res, "$prefix$rest/";
} }
} elsif ($ctext =~ m/^\Q$rest/) {
push @$res, "$prefix$ctext";
push @$res, "$prefix$ctext/" if $c->{children};
} }
} }
} }
} }
if (scalar(@$res) == 1) {
$res = [$res->[0], "$res->[0]/"];
}
return $res; return $res;
} }