Skip to content

Commit 2b97ad0

Browse files
committed
Fix string.find end index
1 parent eadc500 commit 2b97ad0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

internal/lua/stringlib.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func stringFind(ctx context.Context, l *State) (int, error) {
203203
return 1, nil
204204
}
205205
l.PushInteger(int64(init) + int64(matches[0]) + 1)
206-
l.PushInteger(int64(init) + int64(matches[1]) + 1)
206+
l.PushInteger(int64(init) + int64(matches[1]))
207207
n, err := pushSubmatches(l, init, matches[2:], positionCaptures)
208208
if err != nil {
209209
return 0, fmt.Errorf("%s%v", Where(l, 1), err)

internal/lua/stringlib_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ var patternTests []patternTest = []patternTest{
105105
{"1 2 3 4 5", []int{0, 1}},
106106
},
107107
},
108+
{
109+
pattern: "%l*",
110+
tests: []submatchIndexTest{
111+
{"aloALO", []int{0, 3}},
112+
},
113+
},
108114
}
109115

110116
var badPatternTests = []string{

0 commit comments

Comments
 (0)