From 1ed6000dd2a995bcd67e99b1c89aa1e2c4a6f1e6 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Wed, 3 Apr 2024 11:43:49 +0200 Subject: Add completion to execute Completes on the command, not on following arguments if written directly at the prompt. --- src/main/cmds.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/main/cmds.c') diff --git a/src/main/cmds.c b/src/main/cmds.c index d28924b..4dc84ed 100644 --- a/src/main/cmds.c +++ b/src/main/cmds.c @@ -54,11 +54,23 @@ int32_t write_file(struct command_ctx ctx, int argc, const char *argv[]) { return 0; } +static void run_interactive_comp_inserted() { minibuffer_execute(); } + int32_t run_interactive(struct command_ctx ctx, int argc, const char *argv[]) { if (argc == 0) { + struct completion_provider providers[] = {commands_provider()}; + enable_completion(minibuffer_buffer(), + ((struct completion_trigger){ + .kind = CompletionTrigger_Input, + .input = + (struct completion_trigger_input){ + .nchars = 0, .trigger_initially = false}}), + providers, 1, run_interactive_comp_inserted); + return minibuffer_prompt(ctx, "execute: "); } + disable_completion(minibuffer_buffer()); struct command *cmd = lookup_command(ctx.commands, argv[0]); if (cmd != NULL) { return execute_command(cmd, ctx.commands, ctx.active_window, ctx.buffers, -- cgit v1.2.3