Accounted for last character being a newline when checking for EOS (we can be at the second-last character if the last one is a newline

master
Aadhavan Srinivasan 4 weeks ago
parent e36310b32d
commit 393769f152

@ -90,7 +90,8 @@ func (s State) checkAssertion(str []rune, idx int) bool {
return idx == 0 return idx == 0
} }
if s.assert == EOS { if s.assert == EOS {
return idx == len(str) // Index is at the end of the string, or it points to the last character which is a newline
return idx == len(str) || (idx == len(str)-1 && str[len(str)-1] == '\n')
} }
if s.assert == WBOUND { if s.assert == WBOUND {
return isWordBoundary(str, idx) return isWordBoundary(str, idx)

Loading…
Cancel
Save