zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: cursor position after completion
Date: Thu, 2 Sep 1999 13:06:03 +0200 (MET DST)	[thread overview]
Message-ID: <199909021106.NAA02985@beta.informatik.hu-berlin.de> (raw)


With `option_prefix=yes' and a global match spec `r:|-=*' trying
completion on things like `pnmpad -<TAB>' 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


             reply	other threads:[~1999-09-02 11:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-02 11:06 Sven Wischnowsky [this message]
1999-09-15  5:28 Felix Rosencrantz
1999-09-15  8:18 Sven Wischnowsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199909021106.NAA02985@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).