From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20409 invoked from network); 17 Apr 2022 18:16:17 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 17 Apr 2022 18:16:17 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1650219377; b=BwKXv4b98yHT2nHpO/Rd4rF0N5PlPNxAzdPUSt4qq+xyw9vMio1ggBKxUPJ+Vszfxud51Q+BOs 4oWB91Cee/qR0EKTF62MiMGnmSL8t1YhNysDSYDhuUPqgDZBaIHBWwue8sbv4ZI0c1Tl1PQUh/ onn4nGlGKMwjWYUPjbi7pxHM++hb6k8E6e7vjybhQuOaKiSDYBaLkHXLFSYcjuD9qgchFTyBMo Cf5BtC6ApW9p2C4eUnu+4nxFVM/zeH5ZDqEpPxcpij6C+86MFG9ExEP/g90xbRH4t765GNCryg GPoLjq6qdCY2lDV6OEn3G5srgRGQstvyNextckIWm4CP6Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f49.google.com) smtp.remote-ip=209.85.218.49; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1650219377; bh=irLaFis0P7e3Z8EiHURr6/PcjZ42TxJbVZKT27sBWTQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=rBEamu7z9TSE4Rl5hAN8/MLuOpD/KDlcUyueCg9Of4BTuTHbi28y3OeYQnE6kNiOMTQV4iobOb xjqtDFMREgF2sEfngA8jJ036r4bHFfLQsHBA1D9CaX3nB1iXeIff2WYR2UTANNa6RmnmvL2MDx BnCJw0hgX9GudtOuUUiocCt2QSKvIZh76WodQzIPYgKtB75Xy93iCWfwmutN2Yv5OIr/W7fSpM spV5EegpySVXBjeb0T1p1grKgMfwPo2Ip9lCMJGSlbOcIkfBoAuJXlLvsirqPEPeNTdDkDRnwt FXUezcclT+KhcILMBuJqkLlMscvfFzW2gZKvnQ15/z/cYA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=j+bnntcVFANr9TS4L/zB3eiPitdGLcWg+3VqTWiKER4=; b=Kqi1UGKlNM0WyL+VIbUj1I0R8N BeYXjYf9D+Sn4a1Wv+88ZxR6XufzBDryE7f7/x0klx+4V0IDiRmDVaQfgHYBvs7MUIe2ExMNY8wPV b6MCVtje2XcbSco8OLe3VzU2eoR5diis0kGoN6AVZJW6AqGX1R/N+n1NO2RVEFRfI9E5KT8+/2KaN NL7UzlptdLCl5JE1YFBVeaL4W5WjwupDR8+AfVHgJTjK3+NyQcdeJR4AaJQZQUVt7yoMDQ3tPsYnv SF9QYNkIS6Fy7KOuRbf00sgezQHYtofljVlWFIAEzO81Z1eOL1Wizf9UywzdoaE6cRhm6t+X/Wqon 15gAiQlg==; Received: from authenticated user by zero.zsh.org with local id 1ng9RY-000GLO-14; Sun, 17 Apr 2022 18:16:16 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f49.google.com) smtp.remote-ip=209.85.218.49; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f49.google.com ([209.85.218.49]:43870) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1ng9Qr-000Fef-7I; Sun, 17 Apr 2022 18:15:33 +0000 Received: by mail-ej1-f49.google.com with SMTP id g18so23539768ejc.10 for ; Sun, 17 Apr 2022 11:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=j+bnntcVFANr9TS4L/zB3eiPitdGLcWg+3VqTWiKER4=; b=HMGe/OLle9TDGJGsuVgL+tpYW5yZ5EyW/5uit/In6owy1IatRfEmKphgB0ZkfyT/E1 eZkfwOeK1GVBM2OTsNk8xuvgoqi3C4Ef804W+jP3dmeatwJaTIpHunqYbXkhIh3QqxmY D6lhQ2jmUWjOV2GCJcgnfMCA6nsRgbp0bOxD231kQeOHuSdD2vLF4EmAhB3yW1X1XM+1 RdUmLJLYMjakxVCWtvvmGE2RwD9PEkwCpFdqAzaNT/n8KCRtYQ3RTYtoJ1w4aDHKRm7n 7LVTNpxQfe+Sm+kCDCB7nPhEIeMk0AA1i1YMXHatzZ56jRfT3kc3R6Dcyx3Vu/sNeoJk p7vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=j+bnntcVFANr9TS4L/zB3eiPitdGLcWg+3VqTWiKER4=; b=DCTj+qo1okKQzOYrAZ2nbgSGa1nnfWaHrgaK2B6V0VAhm9NrxR1bs4ZoIR1b4C4Uvl /W8sxqL6ev/LiJQojAd1ouqyRnnKLVD/4v4Cwb5BxkQ+ZZm3nX09f0L/1SkBE7ABKsCK 5eAwVA5ABWrvtBT84xOspjrB9Ent7c25cea4i0wvUWYYdd3Jjg3R6kfPeg+FAf0Z5NzO 215Z3ZJpyGqyQWM5O5XiKWCZhTFgxPm0gtHsEeq1jNeDWLlE/jsCS2YvExUyEEQLVooi veljOjf+roTTP/koQffgEPrASy31HdmqAHRHBNfB/4yy35AtErzBmztcnPByU7OChgu+ YXRQ== X-Gm-Message-State: AOAM533GkFM2Gl/QrMEQMPjZW6q/62WH02JwapNdpUd9C8Ae5mDm7PKh p4xWEcfdybBjP2Q8e+n4OEjQBIOv7vReEGOLW7AyJBuDe20f94di X-Google-Smtp-Source: ABdhPJwW8RBzVfEBNkp5wS3maKX68lL03qmsu6LRBIpNv5b3o8mboeKc+WUokKAlgN6t5yyQAE0ji6opCA7iM8QDEiI= X-Received: by 2002:a17:907:62a1:b0:6da:7952:d4d2 with SMTP id nd33-20020a17090762a100b006da7952d4d2mr6302917ejc.260.1650219332716; Sun, 17 Apr 2022 11:15:32 -0700 (PDT) MIME-Version: 1.0 References: <860877fd-ec69-0323-3f2a-8a40e96e6aee@rayninfo.co.uk> <2b388cce-1412-36cd-9a90-d58f853ee830@rayninfo.co.uk> <20220410010441.GA24829@polanet.pl> <20220410143222.GA21848@polanet.pl> <20220417161727.GA31153@polanet.pl> In-Reply-To: <20220417161727.GA31153@polanet.pl> From: Bart Schaefer Date: Sun, 17 Apr 2022 11:15:21 -0700 Message-ID: Subject: Re: cd /u/N/v/ tab expansion To: Tomasz Pala Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 27661 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Sun, Apr 17, 2022 at 9:17 AM Tomasz Pala wrote: > > On Sat, Apr 16, 2022 at 20:00:18 -0700, Bart Schaefer wrote: > > > I don't seem to be able to re-create the setup for your "ctrl-g > > toggling of behaviour" incident. Can you specify? > > Sure, minimal config that exposes this "state-leaking": > > setopt glob_complete This is the trigger again, the other settings just make it possible to see the difference. I'm again suspicious of menu=yes being forced on by _path_files for globcomplete. On the first tab, menu completion is entered. When you hit ctrl+g, you exit menu completion, but do not exit/restart the ZLE editor. That leaves $_lastcomp initialized, so when you hit tab again, _main_complete line 83 sees that the word on the line has not changed and therefore deliberately re-enters completion with the state from the previous attempt. Even though the command line shows the cursor at the end of the word, the unambiguous_cursor position is used, which splits the word into SUFFIX=/g and PREFIX=a/b/d/e and the rest of the behavior follows from that. The next ctrl+g has the same effect -- leaves menu completion but leaves $_lastcomp alone -- so the behavior isn't really "toggling". What's different on the third (and fifth, etc.) tab presses is that the last trial completion ("a/b/d/e /g" with space) is no longer the same as the word on the line ("a/b/d/e/g"), so _main_complete behaves as if you've started a whole new completion, which generates the same menu as the first tab. The important part here is that it is not wrong (in most cases) to re-enter completion with the preserved state when the word on the line has not changed, so resetting _lastcomp is not the answer. One possible fix is this: diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_co mplete index 169ca1f40..4ab572894 100644 --- a/Completion/Base/Core/_main_complete +++ b/Completion/Base/Core/_main_complete @@ -82,7 +82,8 @@ fi if [[ "$compstate[pattern_match]" = "*" && "$_lastcomp[unambiguous]" = "$PREFIX" && - -n "$_lastcomp[unambiguous_cursor]" ]]; then + -n "$_lastcomp[unambiguous_cursor]" && + "$CURSOR" -eq "$_lastcomp[unambiguous_cursor]" ]]; then integer upos="$_lastcomp[unambiguous_cursor]" SUFFIX="$PREFIX[upos,-1]$SUFFIX" PREFIX="$PREFIX[1,upos-1]" However, I'm concerned that will negatively affect behavior in other circumstances, particularly when always_to_end is set or complete_in_word is not set. The question to be answered is whether Tomasz's expection that ctrl+g will reset the state is correct, and if so, how to make that happen when exiting menu completion that way.