From cbce014e763674713f0eac0db7499042ebca97d6 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 8 Sep 2026 08:21:15 +0000 Subject: [PATCH] Optimize char access in LSP edit lookup Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- tools/lsp/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/lsp/src/lib.rs b/tools/lsp/src/lib.rs index 7ef4fad8..15caf177 100644 --- a/tools/lsp/src/lib.rs +++ b/tools/lsp/src/lib.rs @@ -752,11 +752,11 @@ impl LanguageServer for Backend { while let Some(pos_in_line) = line[start_pos..].find(&word) { let actual_pos = start_pos + pos_in_line; let char_before = if actual_pos > 0 { - line.chars().nth(actual_pos - 1) + line[..actual_pos].chars().next_back() } else { None }; - let char_after = line.chars().nth(actual_pos + word_len); + let char_after = line[actual_pos + word_len..].chars().next(); let is_boundary_before = char_before.map_or(true, |c| !c.is_alphanumeric() && c != '_'); @@ -803,11 +803,11 @@ impl LanguageServer for Backend { while let Some(pos_in_line) = line[start_pos..].find(&word) { let actual_pos = start_pos + pos_in_line; let char_before = if actual_pos > 0 { - line.chars().nth(actual_pos - 1) + line[..actual_pos].chars().next_back() } else { None }; - let char_after = line.chars().nth(actual_pos + word_len); + let char_after = line[actual_pos + word_len..].chars().next(); let is_boundary_before = char_before.map_or(true, |c| !c.is_alphanumeric() && c != '_');