Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7366

Console tab complete cuts off old input when Vanilla commands use offset Brigadier suggestions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • None
    • This server is running CraftBukkit version 3760-Spigot-7d7b241-1f2dd8e (MC: 1.19.4) (Implementing API version 1.19.4-R0.1-SNAPSHOT)
    • Yes

      To reproduce:

      1. Launch a Spigot server and wait for the startup to complete
      2. Type "tp @e" into the console
      3. Press tab. The text in the console is replaced by "tp [" when it should have become "tp @e[".
      4. Type "tp @e[" into the console
      5. Press tab. The suggestions ["advancements=", "distance=", "dx=", ...] appear above the command line but the text in the console is replaced by "tp " when it should have stayed as "tp @e[". Press tab again. The previous suggestions (["advancements=", "distance=", "dx=", ...]) are discarded, and instead, new suggestions are displayed, those being ["@a", "@e", "@p", ...].

       

      The issue is that tab completion for vanilla commands in the console sometimes does not work. This seems to happen when commands do not start their suggestions directly after the last space in the current command input. For example, "tp @e" wants to suggest "[" at position 5 to make "tp @e[". However, Spigot places the tab completion at position 3 to make "tp [", which is incorrect.

      This seems to happen because `org.bukkit.craftbukkit.command.VanillaCommandWrapper` only considers the result of `com.mojang.brigadier.suggestion.Suggestion#getText` when converting the Brigadier Suggestions object to a list of Strings for Spigot to display. (See VanillaCommandWrapper#tabComplete). To fix this issue, this method would likely need to take into account the result of `Suggestion#getRange` somehow to offset the suggestions to the intended location.

       

      Note that this problem does not occur for tab completion for the player, since that packet exchange is fully handled by Brigadier in the case of Vanilla commands.

            Unassigned Unassigned
            WillKroboth Will Kroboth
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: