Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] compstate[to_end] and suffixes
- X-seq: zsh-workers 39981
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] compstate[to_end] and suffixes
- Date: Sat, 19 Nov 2016 06:23:56 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=56wG1o0lStHCWAK 7riP3W3ECuBY=; b=Ek3etuTmyoN+E/QICSvPSeO7CqrnfYntknG5zIFtlFvPutH S2/+3ib6gT4lDX3lNsheTwKeyLws1WaeUDl5rxbzd5CZK/UrvdzIJCx4oMYNfi8f WiyWN9kqMtaR0+dKvd39palKXRYcPWud1S6/1fVoQL4zeBocqFrMw5yQCvAc=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=56wG1o0lStHCWA K7riP3W3ECuBY=; b=APPO2WDJH8aNvbhhNpMX/NopWrLpif0mJK94myBZFq7t9l 73hIrlRrelroifXvzvqOey4hBhoeYoKBGVuvlFS1aHLNPkV8qt8XKLWkxJMM6vdw uM9m9x2/8cChQhTnskPOpMv6W+qr8d+AIRNX0D5PFHocAOwWewuqLsS1WAojQ=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
I wrote in workers/39930:
> Known issue: completing «git -c user.em<CURSOR>=foo» inserts "ail."
> (properly) but puts cursor to the right of the dot, rather than to its
> left.
An offlist discussion resulted in a patch for that; bringing that
discussion back on-list (quoting with permission).
Oliver Kiddle wrote:
> Daniel Shahaf wrote:
> > Oliver Kiddle wrote on Sun, Nov 13, 2016 at 00:05:06 +0100:
> > > I'm inclined to think that the default behaviour of compstate[to_end]
> > > should move the cursor after the suffix if it added one. It looks
> > > like one of those cases where completions early bias towards shell
> > > words is still apparent.
> > >
> > > diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
> > > index b7ec18f..9934fd8 100644
> > > --- a/Src/Zle/compresult.c
> > > +++ b/Src/Zle/compresult.c
> > > @@ -1174,6 +1174,7 @@ do_single(Cmatch m)
> > > zlemetacs = minfo.end;
> > > if (zlemetacs + m->qisl == lastend)
> > > zlemetacs += minfo.insc;
> > > + zlemetacs += m->suf ? strlen(m->suf) : 0;
> > > }
> > > {
> > > Cmatch *om = minfo.cur;
> >
> > The following patch achieves that. However, I don't know whether it is
> > correct; perhaps a more correct fix would be to monkey with
> > add_match_data() such that this if() in do_single() would be taken?
>
> Your patch seems to work with tests I've thrown at it, e.g suffix
> not added due to ambiguous completion. I've also checked prefixes.
>
> I think it should also allow for a hidden suffix, however (compadd -s).
> But not for an ignored suffix.
>
Here's an updated patch to handle 'compadd -s' as well:
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index b7ec18f..0579939 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -1174,6 +1174,10 @@ do_single(Cmatch m)
zlemetacs = minfo.end;
if (zlemetacs + m->qisl == lastend)
zlemetacs += minfo.insc;
+
+ /* Advance CURSOR past compadd -s/-S suffixes. */
+ zlemetacs += strlen(psuf);
+ zlemetacs += m->suf ? strlen(m->suf) : 0;
}
{
Cmatch *om = minfo.cur;
What's a minimal example that triggers this code? (So I can add a unit
test)
> There aren't too many cases where we set compstate[to_end] – just
> _urls and _path_files. I've checked both and the change doesn't
> affect either - no suffix is being used. Took me a while to work
> out how to use the one in _path_files. It was added back in
> workers/6686.
>
> On further reflection, I'm convinced it really is just a bug and
> placing the cursor after the suffix is the right thing to do. If
> it really does turn out that the current beahviour has a point, it
> probably wouldn't be hard to add compstate[to_end]=suffix for the
> new behaviour.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author