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

This subforum contains all the issues which we already resolved.
Post Reply
Helldragger
Burner Inserter
Burner Inserter
Posts: 11
Joined: Mon May 15, 2017 11:20 pm
Contact:

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

Post by Helldragger » Fri Jan 25, 2019 4:30 pm

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
Attachments
alone-together_0.0.1.zip
mod registering the commands
(45.51 KiB) Downloaded 19 times
factorio-current.log
logs of my last testing session
(910.66 KiB) Downloaded 14 times

Rseding91
Factorio Staff
Factorio Staff
Posts: 9477
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 » Fri Jan 25, 2019 10:09 pm

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.
If you want to get ahold of me I'm almost always on Discord.

User avatar
TruePikachu
Filter Inserter
Filter Inserter
Posts: 865
Joined: Sat Apr 09, 2016 8:39 pm
Contact:

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

Post by TruePikachu » Fri Jan 25, 2019 11:10 pm

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.

Helldragger
Burner Inserter
Burner Inserter
Posts: 11
Joined: Mon May 15, 2017 11:20 pm
Contact:

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

Post by Helldragger » Sat Jan 26, 2019 1:30 am

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

Rseding91
Factorio Staff
Factorio Staff
Posts: 9477
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 » Fri Feb 08, 2019 9:20 am

It's now fixed for 0.17.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Resolved Problems and Bugs”

Who is online

Users browsing this forum: Bilka