From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13772 invoked by alias); 8 Jun 2018 16:16:42 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42959 Received: (qmail 8466 invoked by uid 1010); 8 Jun 2018 16:16:42 -0000 X-Qmail-Scanner-Diagnostics: from park01.gkg.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(205.235.26.22):SA:0(-1.4/5.0):. Processed in 2.005339 secs); 08 Jun 2018 16:16:42 -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=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_PASS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: SRS0=YYjJ=I2=yahoo.co.uk=okiddle@bounces.park01.gkg.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: by amavisd-new at gkg.net Authentication-Results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1528474577; bh=Zxxvur+dwx5HyXuNP++jOmBUjykrAjg8QGQaeBZjVA0=; h=From:To:Subject:Date:From:Subject; b=fX1LrSgvKEQ1cwvVrqGMAB2DRu5w7b1DEx2oSZ7FLradVfASCWoGaThAAJwG9OLqabbe9MSGyGepZGZN14YtX852sTSUxBLeY0KOWz1cG2m8hBaMNNuLBzwOQWiNVUrzQu44Syxn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3hLl6FPuEZUYpDdwR8__ c2efhGmxOuwGgu0nSYPCkdNxdi61xfOJ2YaYz2Jq3k.ehEUKBQu9rjAoy From: Oliver Kiddle To: Zsh workers Subject: PATCH: moving the cursor in before_complete() MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23894.1528473972.1@thecus> Date: Fri, 08 Jun 2018 18:06:13 +0200 Message-ID: <23895.1528473973@thecus> The following patch removes the functionality associated with the FC_INWORD flag from the completion code. The behaviour it causes has been annoying me for a while. When you have partial completion that results in the cursor being moved back, the next time you invoke completion, the actual visible position of the cursor is ignored and it treats it as having been at the end. You can reproduce it as follows: _users_hosts () { local ret=1 if [[ -prefix *@* ]]; then compadd -M 'r:|@=* r:|=*' -p "user@" host && ret=0 compadd -M 'r:|@=* r:|=*' -p "root@" host && ret=0 else compadd -M 'r:|@=* r:|=*' -s "@host" user root && ret=0 fi return ret } compdef _users_hosts foo foo @h After the first tab, the line is unchanged and the cursor is moved back before the @ to indicate that there is an ambiguity at that point. The second time you press tab, the -prefix test fails because the cursor got moved forward during before_complete. You can examine $CURSOR in the function and it has been affected. I've tried to fathom what purpose this originally served. Various things like repeating partial completions, _prefix, menu completion have crossed my mind but none seem to fit. As it is, this does fix an issue so unless someone else has some ideas, I'd prefer to apply it and wait to see if it breaks something. Oliver diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h index 3e9834560..de70ce843 100644 --- a/Src/Zle/comp.h +++ b/Src/Zle/comp.h @@ -350,7 +350,6 @@ typedef void (*CLPrintFunc)(Cmgroup, Cmatch *, int, int, int, int); /* Flags for fromcomp. */ #define FC_LINE 1 -#define FC_INWORD 2 /* Flags for special parameters. */ diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index fd415da89..f19e29ac9 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -260,12 +260,9 @@ mod_export LinkList allccs; /* This says what of the state the line is in when completion is started * * came from a previous completion. If the FC_LINE bit is set, the * - * string was inserted. If FC_INWORD is set, the last completion moved * - * the cursor into the word although it was at the end of it when the * - * last completion was invoked. * + * string was inserted. * * This is used to detect if the string should be taken as an exact * - * match (see do_ambiguous()) and if the cursor has to be moved to the * - * end of the word before generating the completions. */ + * match (see do_ambiguous()). */ /**/ int fromcomp; @@ -460,6 +457,12 @@ static int oldmenucmp; int before_complete(UNUSED(Hookdef dummy), int *lst) { + /* + * Currently this hook runs before metafication. + * This is the only hook of the three defined here of + * which that is true. + */ + oldmenucmp = menucmp; if (showagain && validlist) @@ -478,17 +481,6 @@ before_complete(UNUSED(Hookdef dummy), int *lst) return 1; } - /* We may have to reset the cursor to its position after the * - * string inserted by the last completion. */ - - /* - * Currently this hook runs before metafication. - * This is the only hook of the three defined here of - * which that is true. - */ - if ((fromcomp & FC_INWORD) && (zlecs = lastend) > zlell) - zlecs = zlell; - /* Check if we have to start a menu-completion (via automenu). */ if (startauto && lastambig && diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index 05799399d..8ad6bddf0 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -814,10 +814,8 @@ do_ambiguous(void) /* If REC_EXACT and AUTO_MENU are set and what we inserted is an * * exact match, we want menu completion the next time round * * so we set fromcomp, to ensure that the word on the line is not * - * taken as an exact match. Also we remember if we just moved the * - * cursor into the word. */ - fromcomp = ((isset(AUTOMENU) ? FC_LINE : 0) | - ((atend && zlemetacs != lastend) ? FC_INWORD : 0)); + * taken as an exact match. */ + fromcomp = (isset(AUTOMENU) ? FC_LINE : 0; /* Probably move the cursor to the end. */ if (movetoend == 3)