When you try to tab complete a command or player name but you selected the command partwise, the completion will append to the not selected characters.
- Type the following in the chat (you need to have cheats enabled)
- Now select a part of this text (by pressing SHIFT and using the left arrow key) (see "Chat selection.png")
- Press TAB
The reason why this happens is because the autocompletePlayerNames() method of the net.minecraft.client.gui.GuiChat class calls the deleteFromCursor(int p_146175_1_) method of the net.minecraft.client.gui.GuiTextField class (MCP 1.8 names). The latter however ignores the parameter in case text is selected (this is intended) and only removes the selected text. One way to fix this could be to call this method with a deletion index of 0 before trying to remove the prefix. This way it would in case text is selected, first remove the selected text and then remove the prefix.
As this method is also called when the prefixes do not match it would need to be changed in the onAutocompleteResponse(String p_146406_1_) method as well.