Properly handle zero length strings when trimming
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 2 Oct 2020 14:45:00 +0000 (17:45 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 2 Oct 2020 14:47:48 +0000 (17:47 +0300)
src/main/java/eu/svjatoslav/commons/string/String2.java

index 8d7273d..c18633a 100755 (executable)
@@ -86,7 +86,7 @@ public class String2 {
         if (actualCutAmount > getLength())
             actualCutAmount = getLength();
 
-        chars.subList(0, actualCutAmount).clear();
+        if (actualCutAmount > 0) chars.subList(0, actualCutAmount).clear();
 
         return this;
     }