diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2025-12-05 14:53:04 -0700 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-12-05 17:29:12 -0700 |
| commit | 402bc58112c5881d814ee6b04559d7369d455a9f (patch) | |
| tree | f9b028b2c8e4b8b65da5055ebd2ed9c31f375cdd /vis-cmds.c | |
| parent | 1baf9352ae760f576f2ad213256649bdb266ddfb (diff) | |
| download | vis-402bc58112c5881d814ee6b04559d7369d455a9f.tar.gz vis-402bc58112c5881d814ee6b04559d7369d455a9f.tar.xz | |
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
Diffstat (limited to 'vis-cmds.c')
| -rw-r--r-- | vis-cmds.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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) { |
