fix: use a partial write capable case folding writer in Buffer.find_all_ranges
This fixes case insensitive search. Previously the case folding would fail on input slices that contain partial utf8 sequences, which is normal in the buffer write process design. Now these partial utf8 sequences are not consumed and instead pushed to the next write call where they will be completed from the main buffer contents.
This commit is contained in:
parent
68b17301cd
commit
99f9f95dbc
2 changed files with 71 additions and 7 deletions
|
|
@ -989,9 +989,9 @@ const Node = union(enum) {
|
|||
.case_folded => {
|
||||
const input_consume_size = @min(ctx.buf.len - ctx.rest.len, input.len);
|
||||
var writer = std.Io.Writer.fixed(ctx.buf[ctx.rest.len..]);
|
||||
unicode.case_folded_write(&writer, input[0..input_consume_size]) catch return error.WriteFailed;
|
||||
ctx.rest = ctx.buf[0 .. ctx.rest.len + writer.end];
|
||||
input = input[input_consume_size..];
|
||||
const folded = unicode.case_folded_write_partial(&writer, input[0..input_consume_size]) catch return error.WriteFailed;
|
||||
ctx.rest = ctx.buf[0 .. ctx.rest.len + folded.len];
|
||||
input = input[folded.len..];
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue