From 2c612c5ba10d7278b76e1d05374cc617ed5ad5fc Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 19 Sep 2016 07:00:22 +0000 Subject: 39383: compadd: Restrict previous patch to the case where $PREFIX includes characters both from the -P prefix and from the (unprefixed) candidate completion word. --- ChangeLog | 4 ++++ Src/Zle/compcore.c | 6 ++++-- 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 + * 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; } -- cgit 1.4.1