gdbus-tool: Ignore unknown options for the 'emit' subcommand when completing

When completing, we parse the options that the user has typed so far. Up
until now we've been doing this without ignoring unknown options. This
leads to broken completions when the user has typed an incomplete
parameter.

For example, when doing the following:

  $ gdbus emit --session --obj<tab>

We expect --object-path to be completed, but it is currently not. What
happens is that we fail to parse the options, therefore don't act on
--session and so don't connect to the session bus, then we early-exit
because we need to know which bus to operate on for later completions.

Instead we can ignore the half-completed --obj, parse --session, get
connected to the bus and then move on to the later completion code.

https://bugzilla.gnome.org/show_bug.cgi?id=793597
This commit is contained in:
Iain Lane 2018-02-21 12:15:41 +00:00 committed by Philip Withnall
parent 03e86d000f
commit 1717a8c965

View File

@ -583,6 +583,8 @@ handle_emit (gint *argc,
modify_argv0_for_command (argc, argv, "emit");
o = g_option_context_new (NULL);
if (request_completion)
g_option_context_set_ignore_unknown_options (o, TRUE);
g_option_context_set_help_enabled (o, FALSE);
g_option_context_set_summary (o, _("Emit a signal."));
g_option_context_add_main_entries (o, emit_entries, GETTEXT_PACKAGE);