qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Dongli Zhang <dongli.zhang@oracle.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Cc: dgilbert@redhat.com, joe.jin@oracle.com
Subject: Re: [PATCH 1/1] readline: fix hmp completion issue
Date: Tue, 14 Feb 2023 14:39:27 +0100	[thread overview]
Message-ID: <ea791a1e-8f9c-ac64-8ff2-0d2d3fdb3f97@redhat.com> (raw)
In-Reply-To: <20230207045241.8843-1-dongli.zhang@oracle.com>

On 07/02/2023 05.52, Dongli Zhang wrote:
> Subject:
> [PATCH 1/1] readline: fix hmp completion issue
> From:
> Dongli Zhang <dongli.zhang@oracle.com>
> Date:
> 07/02/2023, 05.52
> 
> To:
> qemu-devel@nongnu.org
> CC:
> dgilbert@redhat.com, joe.jin@oracle.com
> 
> 
> The auto completion does not work in some cases.
> 
> Case 1.
> 
> 1. (qemu) info reg
> 2. Press 'Tab'.
> 3. It does not auto complete.
> 
> Case 2.
> 
> 1. (qemu) block_resize flo
> 2. Press 'Tab'.
> 3. It does not auto complete 'floppy0'.
> 
> Since the readline_add_completion_of() may add any completion when
> strlen(pfx) is zero, we remove the check with (name[0] == '\0') because
> strlen() always returns zero in that case.
> 
> Fixes: 52f50b1e9f8f ("readline: Extract readline_add_completion_of() from monitor")
> Cc: Joe Jin<joe.jin@oracle.com>
> Signed-off-by: Dongli Zhang<dongli.zhang@oracle.com>
> ---
>   monitor/hmp.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/monitor/hmp.c b/monitor/hmp.c
> index 2aa85d3982..fee410362f 100644
> --- a/monitor/hmp.c
> +++ b/monitor/hmp.c
> @@ -1189,9 +1189,7 @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
>           }
>           memcpy(cmd, pstart, len);
>           cmd[len] = '\0';
> -        if (name[0] == '\0') {
> -            readline_add_completion_of(mon->rs, name, cmd);
> -        }
> +        readline_add_completion_of(mon->rs, name, cmd);
>           if (*p == '\0') {
>               break;
>           }
> @@ -1335,9 +1333,7 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
>               /* block device name completion */
>               readline_set_completion_index(mon->rs, strlen(str));
>               while ((blk = blk_next(blk)) != NULL) {
> -                if (str[0] == '\0') {
> -                    readline_add_completion_of(mon->rs, str, blk_name(blk));
> -                }
> +                readline_add_completion_of(mon->rs, str, blk_name(blk));
>               }
>               break;
>           case 's':
> -- 2.34.1
> 

Thanks, this fixes the completion for me, too:

Tested-by: Thomas Huth <thuth@redhat.com>



      parent reply	other threads:[~2023-02-14 14:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07  4:52 [PATCH 1/1] readline: fix hmp completion issue Dongli Zhang
2023-02-08 11:05 ` Philippe Mathieu-Daudé
2023-02-08 12:33 ` Markus Armbruster
2023-02-14 13:39 ` Thomas Huth [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea791a1e-8f9c-ac64-8ff2-0d2d3fdb3f97@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=dongli.zhang@oracle.com \
    --cc=joe.jin@oracle.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).