Port the subseq matcher to Go

This commit is contained in:
Kovid Goyal
2023-03-12 21:11:26 +05:30
parent b088ab91cf
commit 29dd2438c9
16 changed files with 331 additions and 998 deletions

View File

@@ -139,6 +139,9 @@ func Splitlines(x string, expected_number_of_lines ...int) (ans []string) {
return NewLineScanner("").Split(x, expected_number_of_lines...)
}
// Return a function that can be called sequentially with rune based offsets
// converting them to byte based offsets. The rune offsets must be monotonic,
// otherwise the function returns -1
func RuneOffsetsToByteOffsets(text string) func(int) int {
self := struct {
char_offset, byte_offset, last int