From 402bc58112c5881d814ee6b04559d7369d455a9f Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Fri, 5 Dec 2025 14:53:04 -0700 Subject: vis-lua: complete_command: utilize map_prefix() instead of grep we already have a function for filtering by a prefix. No need for snprintf and extra grep process for filtering. also use simpler buffer_append for appending instead of going through string formatting --- vis-cmds.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'vis-cmds.c') diff --git a/vis-cmds.c b/vis-cmds.c index b543683..adb5822 100644 --- a/vis-cmds.c +++ b/vis-cmds.c @@ -695,11 +695,12 @@ static bool print_cmd(const char *key, void *value, void *data) { static bool print_cmd_name(const char *key, void *value, void *data) { CommandDef *cmd = value; - return buffer_appendf(data, "%s\n", cmd->name); + bool result = buffer_append(data, cmd->name, strlen(cmd->name)); + return result && buffer_append(data, "\n", 1); } -void vis_print_cmds(Vis *vis, Buffer *buf) { - map_iterate(vis->cmds, print_cmd_name, buf); +void vis_print_cmds(Vis *vis, Buffer *buf, const char *prefix) { + map_iterate(map_prefix(vis->cmds, prefix), print_cmd_name, buf); } static bool print_option(const char *key, void *value, void *txt) { -- cgit v1.2.3