Page 1 of 1

[Rseding91] [0.16.51] Autocompletion is not working properly for multiple commands having the same prefix

Posted: Fri Jan 25, 2019 4:30 pm
by Helldragger
I'm making a mod making full use of the custom command system, so I registered a bunch of custom command with a unique prefix to avoid mod incompatibilities: universe-<command>

When I try to autocomplete my commands though, only one is shown at first, universe-make-leader

Image

if I type a little more, this becomes the only option and the auto-completion completes the command.
But it now also recognize the other various commands:

Image

Writing /univ should have auto-completed to the only common prefix left "/universe-" and shown the remaining options instead of auto-completing the whole /universe-make-leader and ignoring the other /universe-<command> options.
Also it should not have matched /unignore or /unmute with the full /universe-make-leader.

Image

also testing /uni does hide correctly /unban and other not matching commands, so there is a problem when matching commands of either, a certain size, containing certain characters("-" maybe ?) or the matching is not left-to-right, which could be problematic.

This happens on any game, the mod I'm writing is only registering custom commands at launch, nothing more, there is no modifications or functionality yet, only commands. There is no variations depending on the order of autocompletion calls on the commands /un, /uni, /univ and /universe-make-leader

To reproduce this, load the following mod and just type /un, /uni, /univ or /universe-make-leader and use tabulation each time to call the autocompletion message

Re: [0.16.51] Autocompletion is not working properly for multiple commands having the same prefix

Posted: Fri Jan 25, 2019 10:09 pm
by Rseding91
Thanks for the report. The problem comes from the fact that every one of your commands uses the same help key which currently is how the game batches aliased commands together (/c and /command being the same thing).

I'll see if there's a more reliable method to say "these group of strings are all the same command". Until then, if you use different help keys it should bypass the problem.

Re: [Rseding91] [0.16.51] Autocompletion is not working properly for multiple commands having the same prefix

Posted: Fri Jan 25, 2019 11:10 pm
by TruePikachu
Theoretically, in a group of identical commands (sans names), exactly one of them should be the "canonical" version (e.g. out of /c and /command, I'd consider /command to be the canonical version). If the canonical version is referred to by the non-canonical "alias" versions (e.g. by holding a pointer, reference, or name), that should be enough for grouping purposes, even if the field itself isn't used for dispatch purposes.

Re: [Rseding91] [0.16.51] Autocompletion is not working properly for multiple commands having the same prefix

Posted: Sat Jan 26, 2019 1:30 am
by Helldragger
True pikachu is right, just specifying the canonical version when creating aliases should be enough, this way you could even only specify the help string for a specific command once, for the canonical one

Specifying the canonical as
Add_command("canonical name", "help string", function)

and specifying aliases as
add_command_alias( "canonical name", "alias name")

Should be enough

Re: [Rseding91] [0.16.51] Autocompletion is not working properly for multiple commands having the same prefix

Posted: Fri Feb 08, 2019 9:20 am
by Rseding91
It's now fixed for 0.17.