From eb81cf3c013232fb1b01c51e9f3edba4cf39d977 Mon Sep 17 00:00:00 2001 From: A-Walrus <58790821+A-Walrus@users.noreply.github.com> Date: Wed, 21 Jun 2023 17:52:42 +0300 Subject: [PATCH] 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... --- helix-core/src/syntax.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 2a5bb974d..f43b03ade 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -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 &[]