Fix tree sitter chunking (#7417)
Call as bytes before slicing, that way you can take bytes that aren't
aligned to chars. Should technically also be slightly faster since you
don't have to check alignment...
commiteb81cf3c013232fb1b01c51e9f3edba4cf39d977
authorA-Walrus <58790821+A-Walrus@users.noreply.github.com>
dateWed 21 Jun 2023, 17:52 (3 years ago)
parent18160a6
helix-core/src/syntax.rs+1−1
@@ -1402,7 +1402,7 @@ impl LanguageLayer {
14021402 &mut |byte, _| {
14031403 if byte <= source.len_bytes() {
14041404 let (chunk, start_byte, _, _) = source.chunk_at_byte(byte);
1405− chunk[byte - start_byte..].as_bytes()
1405+ &chunk.as_bytes()[byte - start_byte..]
14061406 } else {
14071407 // out of range
14081408 &[]