diff options
-rwxr-xr-x | icevault | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -224,7 +224,8 @@ sub sendCommand(@) { } # Get all identities with the given $prefix. If there are multiple -# matches and $all is false, limit the output to one depth. +# matches and $all is false, limit the output to one depth more than the +# longuest common prefix. sub complete($;$) { my $prefix = shift // ''; my $all = shift; @@ -283,8 +284,12 @@ sub complete($;$) { } return @matches if $all or $#matches < 1; - if ($prefix =~ /\A[A-Za-z0-9-]+:\/\/[^\P{Graph}:\/]+(?::\d+)?\//) { - } elsif ($prefix =~ /\A[A-Za-z0-9-]+:\/\//) { + # find the longest common prefix to determine the depth level of completion + my $p = $matches[0]; + do { chop $p until /\A\Q$p\E/ } foreach @matches; + + if ($p =~ /\A[A-Za-z0-9-]+:\/\/[^\P{Graph}:\/]+(?::\d+)?\//) { + } elsif ($p =~ /\A[A-Za-z0-9-]+:\/\//) { s#/[^\P{Print}\/]+\z#/# foreach @matches; } elsif (defined $s) { s#://[^\P{Graph}\/]+/[^\P{Print}\/]+\z#://# foreach @matches; |