Skip to content

Commit

Permalink
Fix tree sitter chunking (helix-editor#7417)
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
A-Walrus authored and wes-adams committed Jul 3, 2023
1 parent 13d3e19 commit 2631943
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ impl LanguageLayer {
&mut |byte, _| {
if byte <= source.len_bytes() {
let (chunk, start_byte, _, _) = source.chunk_at_byte(byte);
chunk[byte - start_byte..].as_bytes()
&chunk.as_bytes()[byte - start_byte..]
} else {
// out of range
&[]
Expand Down

0 comments on commit 2631943

Please sign in to comment.