From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 43E2222F00 for ; Mon, 4 Mar 2024 02:44:36 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709516676; b=IAGy4bCxypzLgpiH+6ERsKqkRWPsYUx1MUF2q88PjA6JxUqam2JXtQR8SNXceSv7BKN0Yb2LeW otIPZhGAWVoLnlOigQM1aZDGDJDmUTkWmiy9jzyya2+awlP2t3jQKyZHxp85pwlU0qVt1nr/3o 5ea3ubXKPJZarEzAjiJx4gA+lB71De0Eg0GMFCQuGCkb4nnt+jBigyKTNidfE1PQ/rBV695evs ZLAT6pY1Hr9DWrjeEf8KQozkAfPMv0jTID+A0cz2D5T/mxyYcjxJ7+LkCAjV97I4UwgLShsoqO lkuA01YZ30tONiLi8VosMhFF1QZm1VF+PkooQWpIBhIL+A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtp-19.smtpout.orange.fr) smtp.remote-ip=80.12.242.19; dkim=pass header.d=orange.fr header.s=t20230301 header.a=rsa-sha256; dmarc=pass header.from=orange.fr; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1709516676; bh=/CQbWxyerxWOc7PsQkKix7Zfxb0b8nDE3VpQXVw9jhA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Content-Type:DKIM-Signature:DKIM-Signature; b=eatjejmPqvqDZRhnnuwhv+u35mHH9c5Jb9RJpsj2v6hg91G0EfGquEEe6rn3664hFfyRqTtw2Y zRKYiI68qqq2aquLbbyrUwBZkffkEsnBo7Q1RolSI2f0CQJqYULnMXQEhv6HfSIREM2hWuaKsm +hwmUyVNvmlKuZMealGwv0wuy1NiuhZuLnDfUgesf0LMbMD0RIKXQfIynhq8czhDBhgNgV3kX5 KJv1Cj/wC6b62pLr+gIHeisWr6wC5Km6NV/JzZVTyA+2aBtUbtUSEvcRAs8NnJMUJhdXAMwQfP rnT8MFKS4W/H6MPVVwr95IprGeCWc/uQwMwmFSdw3pI6iw==; 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:In-Reply-To:From:References:To: Subject:MIME-Version:Date:Message-ID:Content-Type:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=g9O3WnRMqhrFwDIBCPkRLzG8Om5GMrWdtjlvZVeDboA=; b=n6K1mbNF/14vlAU4VrtjXw5iTv ss+A5VcFPAf5jyysAfnG598tbKpvZmDqq0GGmjcYusAU7mzZj85n0EuyRBFDKohZtIe++IegGHJCf ByuQKkGsOP0TFbyw+VUlYzcXdpruZhNkACkBPb5c/hLv+39axm85XGuErFCf2DSieuWqhzLvKYjQ8 G3V9TAPud/Qe+jl1FqQhAyecfQjTkoZwQSuir+idW2m05G+p9nqvyn2h1VsyT8l0QO1jC5qmYX+qw Lsf2eeeu3Vf/V6OBF2t5BbRxnfPEIfDo+HEA2BlaHpF5Zj13drBNUKQ9JzNt22haKClffA1DoHQSn bliKjQCw==; Received: by zero.zsh.org with local id 1rgxNc-0009HI-GL; Mon, 04 Mar 2024 01:44:36 +0000 Authentication-Results: zsh.org; iprev=pass (smtp-19.smtpout.orange.fr) smtp.remote-ip=80.12.242.19; dkim=pass header.d=orange.fr header.s=t20230301 header.a=rsa-sha256; dmarc=pass header.from=orange.fr; arc=none Received: from smtp-19.smtpout.orange.fr ([80.12.242.19]:56421 helo=smtp.smtpout.orange.fr) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1rgxNK-0008z7-AP; Mon, 04 Mar 2024 01:44:18 +0000 Received: from [192.168.1.46] ([86.235.4.17]) by smtp.orange.fr with ESMTPA id gxNJrKhrzhB2WgxNJr2Ubm; Mon, 04 Mar 2024 02:44:17 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1709516657; bh=g9O3WnRMqhrFwDIBCPkRLzG8Om5GMrWdtjlvZVeDboA=; h=Date:Subject:To:References:From:In-Reply-To; b=QHTZUrjuXUENJGYXxmuWnAJkIxjPEuwZXY8LneVGvt/Zj0wNp+WTbqYk9Ymu9wNmO 46V3bSZN8wLvbJiTXLxvyhhn8twlAwPvDJzT0uGNyfy+EvJzG7BSEH2hgBHgQ3Ndoo i/XQkl0CsW03AfFiUX/swqGFvvh+dqNtCn03gQ7E1a+hK6f3BizK+OgbSi9NbSmjE+ ChcoXPKeG44FVaSsgVuSyv6rEzch5OjTDrAguJxr+H/cwh+0FDa+a7cqbBDWHbi7hv c6tz/mf+NLZYrEHsH1O3BxJTdbUm+uEMsxmYfkTLh72Qe9pNjGvV9Mj/cK7KVhqY0S TZCjjT4DCe+XA== X-ME-Helo: [192.168.1.46] X-ME-Auth: c2FteS5kdWxvckBvcmFuZ2UuZnI= X-ME-Date: Mon, 04 Mar 2024 02:44:17 +0100 X-ME-IP: 86.235.4.17 Content-Type: multipart/alternative; boundary="------------sWlwwN0mwLAzeLqvU475W6Vp" Message-ID: <90469bbe-acdf-6dad-baaa-fbf3d1e7ed6c@orange.fr> Date: Mon, 4 Mar 2024 02:44:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [BUG] complist interactive mode overwrites command line Content-Language: fr, en-US To: zsh-workers@zsh.org References: From: Samy Dulor In-Reply-To: X-Seq: 52657 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: This is a multi-part message in MIME format. --------------sWlwwN0mwLAzeLqvU475W6Vp Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 04/08/2021 18:30, Marlon Richert wrote: > % zmodload zsh/complist > % bindkey '^I' menu-select > % MENUMODE=interactive > % touch test{1,2} > % : ; foobar > ^ 1. Type the above line in its entirety. > 2. Place the cursor before the ; > 3. Press Tab. > 4. Press Enter. > % : test1 bar > ^ Completion is written over existing buffer contents. Hello, I think I have an acceptable solution to this issue, although I’m quite unaware of all the intricacies of the Zsh source code, and had 0 knowledge of Zsh internals until 2 days ago... All I can say is that it doesn’t cause the tests to fail, And that after a day of usage it doesn’t seem to break anything else (in my limited use-cases). Basically, when entering an interactive select completion menu, the first completion in the list gets “selected” (it’s highlighted) but not inserted in the command line. In the above test case, that would be “test1”. At that time, compresult.c:do_single was called with “test1” completion, then complist.c:domenuselect restored the command line to its original content. That means the minfo struct was updated by do_single. In that case, we would get minfo { .len = 5, .end = 7 }. When leaving the interactive mode (pressing Enter to accept the first completion, or selecting another completion like using arrow keys), minfo.lencharacters are removed to “insert the next” completion (5 characters, but in fact our command line is still “: ; foobar”, so only 1 character should be erased). So I just tried fixing it by correcting the values in minfo when domenuselect restores the command line content, Which seems to me, is what should happen as far as I understand : diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 9cb89a60d..f2eb3837d 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -2443,6 +2443,8 @@ domenuselect(Hookdef dummy, Chdata dat)              strncpy(zlemetaline, origline, l);              zlemetacs = origcs;              setmstatus(status, NULL, 0 , 0, NULL, NULL, NULL); +           minfo.len = origlpre; +           minfo.end = minfo.pos + minfo.len;          } else if (strpfx("search", s)) {              mode = (strstr(s, "back") ? MM_BSEARCH : MM_FSEARCH);          } --------------sWlwwN0mwLAzeLqvU475W6Vp Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 04/08/2021 18:30, Marlon Richert wrote:
% zmodload zsh/complist
% bindkey '^I' menu-select
% MENUMODE=interactive
% touch test{1,2}
% : ; foobar
    ^ 1. Type the above line in its entirety.
      2. Place the cursor before the ;
      3. Press Tab.
      4. Press Enter.
% : test1 bar
    ^ Completion is written over existing buffer contents.


Hello,

I think I have an acceptable solution to this issue, although I’m quite unaware of all the intricacies of the Zsh source code,
and had 0 knowledge of Zsh internals until 2 days ago...
All I can say is that it doesn’t cause the tests to fail,
And that after a day of usage it doesn’t seem to break anything else (in my limited use-cases).

Basically, when entering an interactive select completion menu, the first completion in the list gets “selected” (it’s highlighted) but not inserted in the command line.
In the above test case, that would be “test1”.
At that time, compresult.c:do_single was called with “test1” completion, then complist.c:domenuselect restored the command line to its original content.
That means the minfo struct was updated by do_single. In that case, we would get minfo { .len = 5, .end = 7 }.

When leaving the interactive mode (pressing Enter to accept the first completion, or selecting another completion like using arrow keys),
minfo.len
characters are removed to “insert the next” completion (5 characters, but in fact our command line is still “: ; foobar”, so only 1 character should be erased).

So I just tried fixing it by correcting the values in minfo when domenuselect restores the command line content,
Which seems to me, is what should happen as far as I understand :

diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 9cb89a60d..f2eb3837d 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -2443,6 +2443,8 @@ domenuselect(Hookdef dummy, Chdata dat)
             strncpy(zlemetaline, origline, l);
             zlemetacs = origcs;
             setmstatus(status, NULL, 0 , 0, NULL, NULL, NULL);
+           minfo.len = origlpre;
+           minfo.end = minfo.pos + minfo.len;
         } else if (strpfx("search", s)) {
             mode = (strstr(s, "back") ? MM_BSEARCH : MM_FSEARCH);
         }

--------------sWlwwN0mwLAzeLqvU475W6Vp--