Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Qmail-Scanner-Diagnostics: from nm18-vm9.bullet.mail.ir2.yahoo.com by f.primenet.com.au (envelope-from <okiddle@yahoo.co.uk>, uid 7791) with qmail-scanner-2.11 
 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1.  
 Clear:RC:0(212.82.96.233):SA:0(0.0/5.0):. 
 Processed in 0.134464 secs); 11 Aug 2016 19:42:23 -0000
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS,
	T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1
X-Envelope-From: okiddle@yahoo.co.uk
X-Qmail-Scanner-Mime-Attachments: |
X-Qmail-Scanner-Zip-Files: |
Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.mail.yahoo.com designates 212.82.96.233 as permitted sender)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1470944099; bh=+I36RqrQsLnD6tVVrDsEOwE3Rooq6mUZjY9LNNeiyzg=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=CXYOTpowm2fvLbaTXcVoA0osoD5OUEBVm4L9EGRDiPNf901zZmtqj1ueCcQkKKyMKVJYXIk0z9WayIeSsg5G4QYfqJSMnTk58cxe1R+KlpoaEcb6QFnA0OacpokUZIjzP6uihjaVARk0E0x245/YU3AZAa+orif7sM8m31j4Zw1KxQzKoG6KiRv9JUoi3QuWj8U7yVcMOWQ3s3odWX7UEhTpF3wIWkMWImK23oIa7hggbeAlYCS23wnA3a3N9Z6XXshp3Uu+Vo1vb1Md0pKRLCJAHHCSnkE/v2zb6pzsalxxmO5C++oqdz3EjbevAV03vA9Aa9MkES1kio5kiXNVtA==
X-Yahoo-Newman-Id: 397804.39202.bm@smtp110.mail.ir2.yahoo.com
X-Yahoo-Newman-Property: ymail-3
X-YMail-OSG: sWQWNy0VM1lWjHHTOyH1dP.M_a_jk3W2w91oS4hXE7TGH_J
 KtwVw6Dr9dmhyh2BRw.FI7aP2_5TuNd6sYsx.uYbKXiN3jbLMUwd1oW3sXAt
 NYHLdgNm4HZ3exUqtU14e1mWzeOFXCagnajlVBPDz7Bwo4HiK80RX2Wpj_L4
 mCsMB2Ei0b66HCtNLxOMndEvu6yLhu9vD1yITdby2FLFSlkxAzsQXbcRCoj1
 tPjJGI9pdLFozlHJ9qQG47jXTkAhRd9dPIcOqmRbq9vMetm.nu3StuO7k3gg
 CWO0yvnjM3PTTJfBHcfhARjTReHEUIH8FyvHMo2hnntDKnTOV2g8jfDM2x3.
 OkpHTw58X2IaXU3eRr6l2Zp5Yjy_YwAgEhMLpNz0lq.o2HU4GnMd3JZAbFRu
 PKcmmuDsCZ3mqBTB_cEVBqJlHst9IxsNlTppSJC9j_XDHqboZ3JevW8y8uzX
 nVMAmo70IKUabwrKsEuUdAQ0paK_Iq.afXRBJzyK2Jw6K0MCXElCSmY3aqyN
 hqJj__pwCKlXtA_GCBdB5hiQHv_EQxKsB3AEHpuUvYUs-
X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI-
In-reply-to: <CAHYJk3R6DV_w-r1qtGdRMWkMMqFziS5i8scNYpq=Sxstz5pQbA@mail.gmail.com>
From: Oliver Kiddle <okiddle@yahoo.co.uk>
References: <CAHYJk3R6DV_w-r1qtGdRMWkMMqFziS5i8scNYpq=Sxstz5pQbA@mail.gmail.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: typeset completion with arguments after cursor
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <83209.1470944098.1@hydra.kiddle.eu>
Date: Thu, 11 Aug 2016 21:34:58 +0200
Message-ID: <83210.1470944098@hydra.kiddle.eu>
X-Seq: zsh-workers 39026

Mikael Magnusson wrote:
> When you do this
> typeset -<tab> a
> it just completes an equal sign, instead of the correct options.
> Without the `a` present it works fine, but I'm not sure what is
> missing from the completion to make this work correctly, and it seems
> to use some extra magic than usual as well. "This function uses whacky
> features of _arguments"

This is a bug in the way the -A option is handled. It is trying the
pattern against all arguments. So the "a" argument doesn't match "-A" and
it disables all option completion. This patch prevents the pattern check for
arguments preceding (and including) the one we are currently completing.

I'm resending this message as it didn't come through from the list first
time. Sorry if it now arrives twice.

Oliver

diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 0028ac1..ecfa2bc 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -2167,9 +2167,11 @@ ca_parse_line(Cadef d, int multi, int first)
 #endif
 		   )
 	    return 1;
-	else if (state.arg && (!napat || !pattry(napat, line))) {
+	else if (state.arg &&
+		 (!napat || cur <= compcurrent || !pattry(napat, line))) {
 	    /* Otherwise it's a normal argument. */
-	    if (napat && ca_inactive(d, NULL, cur + 1, 1, NULL))
+	    if (napat && cur <= compcurrent &&
+		    ca_inactive(d, NULL, cur + 1, 1, NULL))
 		return 1;
 
 	    arglast = 1;

