degesch: fix option completion
This commit is contained in:
parent
e3f1bcecae
commit
715def6555
19
degesch.c
19
degesch.c
@ -5212,12 +5212,21 @@ complete_option (struct app_context *ctx, struct completion *data,
|
||||
struct str_vector options;
|
||||
str_vector_init (&options);
|
||||
|
||||
// Wildcard expansion is an interesting side-effect
|
||||
char *x = xstrdup_printf ("%s*", word);
|
||||
dump_matching_options (ctx, x, &options);
|
||||
free (x);
|
||||
config_dump (ctx->config.root, &options);
|
||||
str_vector_sort (&options);
|
||||
|
||||
str_vector_add_vector (output, options.vector);
|
||||
// Wildcard expansion is an interesting side-effect
|
||||
char *mask = xstrdup_printf ("%s*", word);
|
||||
for (size_t i = 0; i < options.len; i++)
|
||||
{
|
||||
const char *line = options.vector[i];
|
||||
char *key = xstrndup (line, strcspn (line, " "));
|
||||
if (!fnmatch (mask, key, 0))
|
||||
str_vector_add_owned (output, key);
|
||||
else
|
||||
free (key);
|
||||
}
|
||||
free (mask);
|
||||
str_vector_free (&options);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user