From b0a52a4cf7b6e754c5c25d73bb14f0dbc42c54dc Mon Sep 17 00:00:00 2001 From: wizjany Date: Sat, 26 Apr 2014 00:21:05 -0400 Subject: [PATCH] Revert a breaking change to fuzzy item/block lookup. --- src/main/java/com/sk89q/util/StringUtil.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sk89q/util/StringUtil.java b/src/main/java/com/sk89q/util/StringUtil.java index 9158ffa2d..a8ff8cfde 100644 --- a/src/main/java/com/sk89q/util/StringUtil.java +++ b/src/main/java/com/sk89q/util/StringUtil.java @@ -289,7 +289,7 @@ public final class StringUtil { return null; } - int minDist = Integer.MAX_VALUE; + int minDist = -1; for (Map.Entry entry : lookup.entrySet()) { final String key = entry.getKey(); @@ -299,16 +299,12 @@ public final class StringUtil { int dist = getLevenshteinDistance(key, testName); - if (dist >= minDist) { + if ((dist < minDist || minDist == -1) && dist < 2) { minDist = dist; type = entry.getValue(); } } - if (minDist > 1) { - return null; - } - return type; } }