commit 3d7add8262c593d648b7e98f8974194e2c4081a9
parent e70d313e6a91886c2e96d23cb650b6768d55e261
Author: hhvn <dev@hhvn.uk>
Date: Sun, 20 Mar 2022 18:13:39 +0000
Improve help handling
Exact match - show only that:
/help format --> only help for /format
/help format. --> all the formats
Diffstat:
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/commands.c b/src/commands.c
@@ -1395,6 +1395,8 @@ command_help) {
hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_START :%s", commands[i].name);
for (j=0; commands[i].description[j]; j++)
hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP :%s", commands[i].description[j]);
+ if (strcmp(commands[i].name, str) == 0)
+ goto end; /* only print one for an exact match, i,e, /help format should only print the command, not all formats. */
}
}
@@ -1404,11 +1406,14 @@ command_help) {
found = 1;
hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_START :%s", config[i].name);
for (j=0; config[i].description[j]; j++)
- hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_UI :%s", config[i].description[j]);
+ hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP :%s", config[i].description[j]);
+ if (strcmp(config[i].name, str) == 0)
+ goto end;
}
}
}
+end:
if (found)
hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_END :end of help");
else
diff --git a/src/config.c b/src/config.c
@@ -356,7 +356,7 @@ struct Config config[] = {
.description = {
"Format of footer of /alias output", NULL}},
{"format.ui.help", 1, Val_string,
- .str = "${1}",
+ .str = " ${1}",
.strhandle = config_redraws,
.description = {
"Format of /alias output", NULL}},