diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2015-03-20 14:13:09 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2015-03-20 14:13:11 +0100 |
commit | 8ec9c5f75200d7a54015cc3bd86cbe7a0836cc43 (patch) | |
tree | 292720349ba392d84e216d0d0669ec7308ba9f47 | |
parent | 7746c850acb53135b25161494b6fc980a8b9f7a9 (diff) |
Determine the depth level of completion from the longest common prefix.
-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; |