summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/comp.h1
-rw-r--r--Src/Zle/compcore.c90
-rw-r--r--Src/Zle/compmatch.c20
3 files changed, 59 insertions, 52 deletions
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index 3b49b2c25..bd0401800 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -196,6 +196,7 @@ struct cline {
#define CLF_LINE 32
#define CLF_JOIN 64
#define CLF_MATCHED 128
+#define CLF_SKIP 256
/* Information for ambiguous completions. One for fignore ignored and *
* one for normal completion. */
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 60f73c635..1b16870d1 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1740,55 +1740,57 @@ addmatches(Cadata dat, char **argv)
llpl -= gfl;
}
}
- s = dat->ppre ? dat->ppre : dupstring("");
- if ((ml = match_str(lpre, s, &bpl, 0, NULL, 0, 0, 1)) >= 0) {
- if (matchsubs) {
- Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, 0);
-
- tmp->prefix = matchsubs;
- if (matchlastpart)
- matchlastpart->next = tmp;
+ if ((s = dat->ppre)) {
+ if ((ml = match_str(lpre, s, &bpl, 0, NULL, 0, 0, 1)) >= 0) {
+ if (matchsubs) {
+ Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, 0);
+
+ tmp->prefix = matchsubs;
+ if (matchlastpart)
+ matchlastpart->next = tmp;
+ else
+ matchparts = tmp;
+ }
+ pline = matchparts;
+ lpre += ml;
+ llpl -= ml;
+ bcp = ml;
+ bpadd = strlen(s) - ml;
+ } else {
+ if (llpl <= lpl && strpfx(lpre, s))
+ lpre = dupstring("");
+ else if (llpl > lpl && strpfx(s, lpre))
+ lpre += lpl;
else
- matchparts = tmp;
+ *argv = NULL;
+ bcp = lpl;
}
- pline = matchparts;
- lpre += ml;
- llpl -= ml;
- bcp = ml;
- bpadd = strlen(s) - ml;
- } else {
- if (llpl <= lpl && strpfx(lpre, s))
- lpre = dupstring("");
- else if (llpl > lpl && strpfx(s, lpre))
- lpre += lpl;
- else
- *argv = NULL;
- bcp = lpl;
}
- s = dat->psuf ? dat->psuf : dupstring("");
- if ((ml = match_str(lsuf, s, &bsl, 0, NULL, 1, 0, 1)) >= 0) {
- if (matchsubs) {
- Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, CLF_SUF);
-
- tmp->suffix = matchsubs;
- if (matchlastpart)
- matchlastpart->next = tmp;
+ if ((s = dat->psuf)) {
+ if ((ml = match_str(lsuf, s, &bsl, 0, NULL, 1, 0, 1)) >= 0) {
+ if (matchsubs) {
+ Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, CLF_SUF);
+
+ tmp->suffix = matchsubs;
+ if (matchlastpart)
+ matchlastpart->next = tmp;
+ else
+ matchparts = tmp;
+ }
+ sline = revert_cline(matchparts);
+ lsuf[llsl - ml] = '\0';
+ llsl -= ml;
+ bcs = ml;
+ bsadd = strlen(s) - ml;
+ } else {
+ if (llsl <= lsl && strsfx(lsuf, s))
+ lsuf = dupstring("");
+ else if (llsl > lsl && strsfx(s, lsuf))
+ lsuf[llsl - lsl] = '\0';
else
- matchparts = tmp;
+ *argv = NULL;
+ bcs = lsl;
}
- sline = revert_cline(matchparts);
- lsuf[llsl - ml] = '\0';
- llsl -= ml;
- bcs = ml;
- bsadd = strlen(s) - ml;
- } else {
- if (llsl <= lsl && strsfx(lsuf, s))
- lsuf = dupstring("");
- else if (llsl > lsl && strsfx(s, lsuf))
- lsuf[llsl - lsl] = '\0';
- else
- *argv = NULL;
- bcs = lsl;
}
if (comppatmatch && *comppatmatch) {
int is = (*comppatmatch == '*');
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index 3a9ea6a40..884946b97 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -411,7 +411,8 @@ add_match_sub(Cmatcher m, char *l, int ll, char *w, int wl)
/* And add the cline. */
if (wl || ll) {
- n = get_cline(l, ll, w, wl, NULL, 0, flags);
+ n = get_cline(l, ll, w, wl, NULL, 0,
+ flags | ((m && m->wlen == -2) ? CLF_SKIP : 0));
if (matchlastsub)
matchlastsub->next = n;
else
@@ -1925,9 +1926,9 @@ join_clines(Cline o, Cline n)
Cline t, tn, tt, to = NULL;
for (t = n; (tn = t->next); t = tn)
- if (!(tn->flags & CLF_NEW)) {
+ if (!(tn->flags & CLF_NEW) && (tn->flags & CLF_SKIP)) {
for (tt = o; (to = tt->next); tt = to)
- if (!(to->flags & CLF_NEW) &&
+ if (!(to->flags & CLF_NEW) && (to->flags & CLF_SKIP) &&
cmp_anchors(tn, to, 1))
break;
if (to)
@@ -1953,8 +1954,9 @@ join_clines(Cline o, Cline n)
n = n->next;
continue;
} else {
- for (t = o; (to = t->next) && !cmp_anchors(n, to, 1);
- t = to);
+ for (t = o; (to = t->next); t = to)
+ if ((to->flags & CLF_SKIP) && cmp_anchors(n, to, 1))
+ break;
if (to) {
diff = sub_join(n, o, to, 1);
@@ -1975,9 +1977,11 @@ join_clines(Cline o, Cline n)
continue;
} else {
for (tt = NULL, t = n; (tn = t->next); t = tn) {
- for (tt = o;
- (to = tt->next) &&
- !cmp_anchors(tn, to, 1); tt = to);
+ if (tn->flags & CLF_SKIP)
+ for (tt = o; (to = tt->next); tt = to)
+ if ((to->flags & CLF_SKIP) &&
+ cmp_anchors(tn, to, 1))
+ break;
if (to)
break;
}