From 246dc34835e7ffb67121eaeb57018ab6f55819b3 Mon Sep 17 00:00:00 2001 From: Myles Date: Thu, 14 Dec 2017 21:25:42 +0000 Subject: [PATCH] Fix tab completion not completing mid-word, also makes code simpler --- .../ProtocolSnapshotTo1_12_2.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java index 06901ff5c..e02a34fbe 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java @@ -67,15 +67,10 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol { index = input.length(); length = 0; } else { - // Otherwise find the last space - int lastSpace = input.lastIndexOf(" "); - if (lastSpace == -1) { - index = 0; - length = input.length(); - } else { - index = lastSpace; - length = input.length() - lastSpace; - } + // Otherwise find the last space (+1 as we include it) + int lastSpace = input.lastIndexOf(" ") + 1; + index = lastSpace; + length = input.length() - lastSpace; } // Write index + length wrapper.write(Type.VAR_INT, index);