diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-01-30 22:09:36 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-01-30 22:09:36 +0100 |
commit | e78d96686c6146d969d96431cdd117da945072e5 (patch) | |
tree | 86880b61bc09e940c754930a4a308404bd999187 /src | |
parent | 4370f75ce6755a928908c14f3f3028515135cb72 (diff) | |
download | weechat-e78d96686c6146d969d96431cdd117da945072e5.zip |
core: inform that commands are case sensitive when another command with different case is found (issue #1877)
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hook/wee-hook-command.c | 11 | ||||
-rw-r--r-- | src/core/hook/wee-hook-command.h | 3 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/core/hook/wee-hook-command.c b/src/core/hook/wee-hook-command.c index dbe3b0653..55bc68a24 100644 --- a/src/core/hook/wee-hook-command.c +++ b/src/core/hook/wee-hook-command.c @@ -543,7 +543,7 @@ hook_command_similar_get_relevance (const char *cmd1, int length_cmd1, /* perfect match if commands are the same (different case) */ if (strcmp (cmd1, cmd2) == 0) - return -99; + return HOOK_COMMAND_SIMILAR_DIFF_CASE_ONLY; /* init relevance with Levenshtein distance (lower is better) */ relevance = string_levenshtein (cmd1, cmd2, 1); @@ -673,7 +673,7 @@ hook_command_display_error_unknown (const char *command) struct t_arraylist *list_commands; struct t_hook_command_similar *cmd_similar; char **str_commands; - int i, list_size, found; + int i, list_size, found, found_diff_case_only; if (!command || !command[0]) return; @@ -690,6 +690,7 @@ hook_command_display_error_unknown (const char *command) } found = 0; + found_diff_case_only = 0; list_size = arraylist_size (list_commands); for (i = 0; i < list_size; i++) { @@ -701,6 +702,8 @@ hook_command_display_error_unknown (const char *command) string_dyn_concat (str_commands, ", ", -1); string_dyn_concat (str_commands, cmd_similar->command, -1); found++; + if (cmd_similar->relevance == HOOK_COMMAND_SIMILAR_DIFF_CASE_ONLY) + found_diff_case_only++; if (found >= 5) break; } @@ -710,6 +713,10 @@ hook_command_display_error_unknown (const char *command) gui_chat_printf_date_tags ( NULL, 0, GUI_FILTER_TAG_NO_FILTER, + (found_diff_case_only > 0) ? + _("%sUnknown command \"%s\" (commands are case sensitive, " + "type /help for help), " + "commands with similar name: %s") : _("%sUnknown command \"%s\" (type /help for help), " "commands with similar name: %s"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], diff --git a/src/core/hook/wee-hook-command.h b/src/core/hook/wee-hook-command.h index cec93e575..ab56ee3b0 100644 --- a/src/core/hook/wee-hook-command.h +++ b/src/core/hook/wee-hook-command.h @@ -37,6 +37,9 @@ struct t_gui_buffer; #define HOOK_COMMAND_EXEC_AMBIGUOUS_INCOMPLETE -3 #define HOOK_COMMAND_EXEC_RUNNING -4 +/* same command found with a different case */ +#define HOOK_COMMAND_SIMILAR_DIFF_CASE_ONLY -99 + typedef int (t_hook_callback_command)(const void *pointer, void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol); |