From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19861 invoked from network); 2 Sep 1999 11:06:16 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 2 Sep 1999 11:06:16 -0000 Received: (qmail 21528 invoked by alias); 2 Sep 1999 11:06:06 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7630 Received: (qmail 21521 invoked from network); 2 Sep 1999 11:06:05 -0000 Date: Thu, 2 Sep 1999 13:06:03 +0200 (MET DST) Message-Id: <199909021106.NAA02985@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk Subject: PATCH: cursor position after completion With `option_prefix=yes' and a global match spec `r:|-=*' trying completion on things like `pnmpad -' in a directory like the zsh `Src' directory gives you the options and all files containing a hyphen. Then the completion code positions the cursor on the first place where characters are missing which is before (on) the `-' in this case. Since this has annoyed me for too long now, the patch below makes the cursor be placed on the last position where characters are missing or differ. I hope that this gets it right in more cases than the previous code, although it isn't perfect either. Unfortunately, placing it at the position where the greatest number of matches differ is impossible since we can't really detect this without comparing the parts of all matches separately, which is too expensive. Bye Sven diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c --- os/Zle/zle_tricky.c Thu Sep 2 11:39:18 1999 +++ Src/Zle/zle_tricky.c Thu Sep 2 12:59:52 1999 @@ -7348,7 +7348,7 @@ inststrlen(s->line, 1, s->llen); else inststrlen(s->word, 1, s->wlen); - if (d < 0 && (s->flags & CLF_DIFF)) + if (s->flags & CLF_DIFF) d = cs; if (ins) { li += s->llen; @@ -7363,7 +7363,7 @@ } /* Remember the position if this is the first prefix with * missing characters. */ - if (pm < 0 && (l->flags & CLF_MISS) && !(l->flags & CLF_SUF)) + if ((l->flags & CLF_MISS) && !(l->flags & CLF_SUF)) pm = cs; pcs = cs; /* Insert the anchor. */ @@ -7384,7 +7384,7 @@ if (l->flags & CLF_MISS) { if (l->flags & CLF_MID) b = cs; - else if (sm < 0 && (l->flags & CLF_SUF)) + else if (l->flags & CLF_SUF) sm = cs; } /* And now insert the suffix or the original string. */ @@ -7402,10 +7402,11 @@ } } else { int hp = 0, hs = 0; + Cline js = NULL; for (j = -1, i = 0, s = l->suffix; s; s = s->next) { if (j < 0 && (s->flags & CLF_DIFF)) - j = i; + j = i, js = s; if (s->flags & CLF_LINE) { inststrlen(s->line, 0, s->llen); i += s->llen; pcs = cs + s->llen; @@ -7428,7 +7429,7 @@ if (hs) spos += i; cs += i; - if (d < 0 && j >= 0) + if (j >= 0) d = cs - j; } /* If we reached the right positions, re-insert the braces. */ -- Sven Wischnowsky wischnow@informatik.hu-berlin.de