Browse Source

Fix: StringHelper.Slice

AnnulusGames 1 year ago
parent
commit
75e86bd66f
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/Lua/Standard/Text/StringHelper.cs

+ 2 - 2
src/Lua/Standard/Text/StringHelper.cs

@@ -14,11 +14,11 @@ internal static class StringHelper
     public static ReadOnlySpan<char> Slice(string s, int i, int j)
     public static ReadOnlySpan<char> Slice(string s, int i, int j)
     {
     {
         if (i < 0) i = s.Length + i + 1;
         if (i < 0) i = s.Length + i + 1;
-        if (j < 0) i = s.Length + i + 1;
+        if (j < 0) j = s.Length + j + 1;
 
 
         if (i < 1) i = 1;
         if (i < 1) i = 1;
         if (j > s.Length) j = s.Length;
         if (j > s.Length) j = s.Length;
 
 
-        return i > j ? "" : s.AsSpan().Slice(i - 1, j - 1);
+        return i > j ? "" : s.AsSpan()[(i - 1)..j];
     }
     }
 }
 }