summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2016-09-19 07:00:22 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2016-09-20 17:59:20 +0000
commit2c612c5ba10d7278b76e1d05374cc617ed5ad5fc (patch)
tree629b86b71336d0f64132fe74fb95247bb58fe1ff
parentbd94e13f34db02b0fed2414b54cc6787407436ad (diff)
downloadzsh-2c612c5ba10d7278b76e1d05374cc617ed5ad5fc.tar.gz
zsh-2c612c5ba10d7278b76e1d05374cc617ed5ad5fc.zip
39383: compadd: Restrict previous patch to the case where $PREFIX includes characters both from the -P prefix and from the (unprefixed) candidate completion word.
-rw-r--r--ChangeLog4
-rw-r--r--Src/Zle/compcore.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a8ba741b..ff313003b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2016-09-20 Daniel Shahaf <d.s@daniel.shahaf.name>
+ * 39383: Src/Zle/compcore.c: compadd: Restrict previous patch
+ to the case where $PREFIX includes characters both from the -P
+ prefix and from the (unprefixed) candidate completion word.
+
* 39372: Src/Zle/compcore.c: compadd: Match -P prefix
all-or-nothing rather than greedily.
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 05d27068a..5443018d8 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -2194,8 +2194,10 @@ addmatches(Cadata dat, char **argv)
/* Test if there is an existing -P prefix. */
if (dat->pre && *dat->pre) {
int prefix_length = pfxlen(dat->pre, lpre);
- if (dat->pre[prefix_length] == '\0') {
- /* $compadd_args[-P] is a prefix of ${PREFIX}. */
+ if (dat->pre[prefix_length] == '\0' ||
+ lpre[prefix_length] == '\0') {
+ /* $compadd_args[-P] is a prefix of ${PREFIX}, or
+ * vice-versa. */
llpl -= prefix_length;
lpre += prefix_length;
}