From 44b6995ac6e169ea7b5a239c300829f344d32f5c Mon Sep 17 00:00:00 2001 From: CharlesChen0823 Date: Wed, 7 Jan 2026 00:28:27 +0800 Subject: [PATCH] signature_help: Fix crash when typing CJK in debug mode (#45785) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in release mode: found many log error as `ERROR [rope::chunk] byte index 48 is not a char boundary; it is inside ',' (bytes 46..49)` This is easy testing, - enable signature help - typing any CJK character - crash in debug mode Release Notes: - N/A --- crates/editor/src/signature_help.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/editor/src/signature_help.rs b/crates/editor/src/signature_help.rs index 2554db2450103709275b3f7946076fd891326d84..e88ede2909b4080dee90f6b8348f4676c23b5191 100644 --- a/crates/editor/src/signature_help.rs +++ b/crates/editor/src/signature_help.rs @@ -94,11 +94,16 @@ impl Editor { } let buffer_snapshot = self.buffer().read(cx).snapshot(cx); - let bracket_range = |position: MultiBufferOffset| match (position, position + 1usize) { - (MultiBufferOffset(0), b) if b <= buffer_snapshot.len() => MultiBufferOffset(0)..b, - (MultiBufferOffset(0), b) => MultiBufferOffset(0)..b - 1, - (a, b) if b <= buffer_snapshot.len() => a - 1..b, - (a, b) => a - 1..b - 1, + let bracket_range = |position: MultiBufferOffset| { + let range = match (position, position + 1usize) { + (MultiBufferOffset(0), b) if b <= buffer_snapshot.len() => MultiBufferOffset(0)..b, + (MultiBufferOffset(0), b) => MultiBufferOffset(0)..b - 1, + (a, b) if b <= buffer_snapshot.len() => a - 1..b, + (a, b) => a - 1..b - 1, + }; + let start = buffer_snapshot.clip_offset(range.start, text::Bias::Left); + let end = buffer_snapshot.clip_offset(range.end, text::Bias::Right); + start..end }; let not_quote_like_brackets = |buffer: &BufferSnapshot, start: Range, end: Range| {