Skip to content

Commit

Permalink
Fix string.find end index
Browse files Browse the repository at this point in the history
  • Loading branch information
zombiezen committed Jan 29, 2025
1 parent eadc500 commit 2b97ad0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/lua/stringlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func stringFind(ctx context.Context, l *State) (int, error) {
return 1, nil
}
l.PushInteger(int64(init) + int64(matches[0]) + 1)
l.PushInteger(int64(init) + int64(matches[1]) + 1)
l.PushInteger(int64(init) + int64(matches[1]))
n, err := pushSubmatches(l, init, matches[2:], positionCaptures)
if err != nil {
return 0, fmt.Errorf("%s%v", Where(l, 1), err)
Expand Down
6 changes: 6 additions & 0 deletions internal/lua/stringlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ var patternTests []patternTest = []patternTest{
{"1 2 3 4 5", []int{0, 1}},
},
},
{
pattern: "%l*",
tests: []submatchIndexTest{
{"aloALO", []int{0, 3}},
},
},
}

var badPatternTests = []string{
Expand Down

0 comments on commit 2b97ad0

Please sign in to comment.