diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-01-30 21:51:32 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-01-30 21:51:32 +0100 |
commit | 4370f75ce6755a928908c14f3f3028515135cb72 (patch) | |
tree | f8a853790807627014081ac3891b48dd2650f3e4 /src/core/hook | |
parent | b02a10aa48b3164e510e6128acec226932dfe406 (diff) | |
download | weechat-4370f75ce6755a928908c14f3f3028515135cb72.zip |
core: improve prioritization of commands starting with same chars in similar commands
Diffstat (limited to 'src/core/hook')
-rw-r--r-- | src/core/hook/wee-hook-command.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/core/hook/wee-hook-command.c b/src/core/hook/wee-hook-command.c index 641b345a1..dbe3b0653 100644 --- a/src/core/hook/wee-hook-command.c +++ b/src/core/hook/wee-hook-command.c @@ -539,11 +539,11 @@ hook_command_similar_get_relevance (const char *cmd1, int length_cmd1, const char *cmd2, int length_cmd2) { const char *pos; - int relevance, factor; + int relevance; /* perfect match if commands are the same (different case) */ if (strcmp (cmd1, cmd2) == 0) - return -1; + return -99; /* init relevance with Levenshtein distance (lower is better) */ relevance = string_levenshtein (cmd1, cmd2, 1); @@ -553,11 +553,10 @@ hook_command_similar_get_relevance (const char *cmd1, int length_cmd1, strstr (cmd2, cmd1) : strstr (cmd1, cmd2); if (pos) { - factor = 4; + relevance /= 4; /* extra bonus if match is at beginning */ if ((pos == cmd1) || (pos == cmd2)) - factor = 5; - relevance /= factor; + relevance -= 2; } else { |