From 4564a4a18aaaee91195c4100cca056189842d5f7 Mon Sep 17 00:00:00 2001 From: Delan Azabani Date: Tue, 24 Jun 2025 20:06:22 +1000 Subject: [PATCH] Fix column numbering in getBreakpointPositionsCompressed handler Co-authored-by: atbrakhi Signed-off-by: Delan Azabani --- components/devtools/actors/source.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/devtools/actors/source.rs b/components/devtools/actors/source.rs index 999166b0448..ba659b2653f 100644 --- a/components/devtools/actors/source.rs +++ b/components/devtools/actors/source.rs @@ -192,11 +192,12 @@ impl Actor for SourceActor { let mut positions = BTreeMap::default(); if let Some(content) = self.content.as_ref() { for (line_number, line) in content.lines().enumerate() { - // Column numbers are in Unicode scalar values, not UTF-16 code units or grapheme clusters. - let column_count = line.chars().count(); - // Line and column numbers are one-based. + // Column numbers are in UTF-16 code units, not Unicode scalar values or grapheme clusters. + let column_count = line.encode_utf16().count(); + // Line number are one-based. Column numbers are zero-based. + // FIXME: the docs say column numbers are one-based, but this appears to be incorrect. // - positions.insert(line_number + 1, (1..=column_count).collect()); + positions.insert(line_number + 1, (0..column_count).collect()); } } let reply = GetBreakpointPositionsCompressedReply {