mojira.dev
MC-78963

Command completion fails with multiple possibilities and other arguments set

It seems like this affects every command. If you enter arguments behind the tab completion and then press TAB, it fails when there are multiple possibilities

When you enter the beginning of a particle name, have the other values set and press TAB, it will only complete the name, if there is only one particle name with this start. I expected rather that it would cycle trough all the names like the game does for every other command.

How to reproduce:
Enter the code and press TAB ([CURSOR] shows the position where the mouse cursor should be)

/particle command completion works

/particle snows[CURSOR] ~ ~ ~ 1 1 1 10

/particle command completion fails

/particle snow[CURSOR] ~ ~ ~ 1 1 1 10

The reason

The reason for this seems to be that the onAutocompleteResponse(String[] p_146406_1_) method of the net.minecraft.client.gui.GuiChat class (MCP 1.8 names) does not remove anything after the next space when trying to complete. This means that the prefixes are identically but because one has the rest of the command behind it, the command pieces are treated as if the were not identically. This causes the common prefix "snow" to be replaced again with "snow".

public void onAutocompleteResponse(String[] p_146406_1_)
{
	if (this.waitingOnAutocomplete)
	{
		//...
		
		//Changed this 
		//String var6 = this.inputField.getText().substring(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false));
		String stringToComplete = this.inputField.getText().substring(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false));
		int nextSpace = stringToComplete.indexOf(" ");
		if (nextSpace == -1) nextSpace = stringToComplete.length();
		String var6 = stringToComplete.substring(0, nextSpace);
		
		//...
	}
}

Linked issues

Comments 7

Can't replicate. No such particle as "snows" or "snow". TAB cycles all particles listed.

Do you have the other arguments set?
I know that it works when you start with /particle snow, but it won't work with /particle snow[CURSOR] ~ ~ ~ 1 1 1 10

Confirmed for 1.9

Still in 1.9.1-pre1

Still in 1.9.1-pre3

Fixed in 18w30a or 18w30b.

marcono1234

(Unassigned)

Confirmed

/particle, command, completion, particle, tab-completion

Minecraft 1.8.3, Minecraft 15w37a, Minecraft 15w51b, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 1, ..., Minecraft 1.9.2, Minecraft 16w15b, Minecraft 16w35a, Minecraft 1.11, Minecraft 1.12.2

Minecraft 18w30b

Retrieved