Browse Source

String.indexOf result fix

Fixes TestOps line 95
PeyTy 10 years ago
parent
commit
1cdcb3bc66
1 changed files with 2 additions and 1 deletions
  1. 2 1
      std/lua/_std/String.hx

+ 2 - 1
std/lua/_std/String.hx

@@ -46,7 +46,8 @@ class String {
 	public function indexOf( str : String, ?startIndex : Int ) : Int {
 	public function indexOf( str : String, ?startIndex : Int ) : Int {
 		if (startIndex == null) startIndex = 1;
 		if (startIndex == null) startIndex = 1;
 		else startIndex += 1;
 		else startIndex += 1;
-		return lua.StringTools.find(this, str, startIndex, str.length, true);
+		var r = lua.StringTools.find(this, str, startIndex, str.length, true);
+		return untyped r && (r - 1) || (-1);
 	}
 	}
 	public function lastIndexOf( str : String, ?startIndex : Int ) : Int {
 	public function lastIndexOf( str : String, ?startIndex : Int ) : Int {
 		var i = 0;
 		var i = 0;