mirror of https://github.com/helix-editor/helix
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...pull/7435/head
parent
18160a667b
commit
eb81cf3c01
|
@ -1402,7 +1402,7 @@ impl LanguageLayer {
|
||||||
&mut |byte, _| {
|
&mut |byte, _| {
|
||||||
if byte <= source.len_bytes() {
|
if byte <= source.len_bytes() {
|
||||||
let (chunk, start_byte, _, _) = source.chunk_at_byte(byte);
|
let (chunk, start_byte, _, _) = source.chunk_at_byte(byte);
|
||||||
chunk[byte - start_byte..].as_bytes()
|
&chunk.as_bytes()[byte - start_byte..]
|
||||||
} else {
|
} else {
|
||||||
// out of range
|
// out of range
|
||||||
&[]
|
&[]
|
||||||
|
|
Loading…
Reference in New Issue