From eadce2ebe02ee77a526365afcbc6f8095e7aee4f Mon Sep 17 00:00:00 2001 From: Delan Azabani Date: Tue, 24 Jun 2025 19:12:34 +1000 Subject: [PATCH] Handle getBreakpointPositionsCompressed in source actor Co-authored-by: atbrakhi Signed-off-by: Delan Azabani --- components/devtools/actors/source.rs | 29 +++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/components/devtools/actors/source.rs b/components/devtools/actors/source.rs index 3cf2d279183..999166b0448 100644 --- a/components/devtools/actors/source.rs +++ b/components/devtools/actors/source.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use std::cell::RefCell; -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; use base::id::PipelineId; use serde::Serialize; @@ -69,6 +69,12 @@ struct GetBreakableLinesReply { lines: Vec, } +#[derive(Serialize)] +struct GetBreakpointPositionsCompressedReply { + from: String, + positions: BTreeMap>, +} + impl SourceManager { pub fn new() -> Self { Self { @@ -178,6 +184,27 @@ impl Actor for SourceActor { }; request.reply_final(&reply)? }, + // Client wants to know which columns in the line can have breakpoints. + // Sent when the user tries to set a breakpoint by clicking a line number in a source. + "getBreakpointPositionsCompressed" => { + // Tell the client that every column is breakable. + // TODO: determine which columns are actually breakable. + 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. + // + positions.insert(line_number + 1, (1..=column_count).collect()); + } + } + let reply = GetBreakpointPositionsCompressedReply { + from: self.name(), + positions, + }; + request.reply_final(&reply)? + }, _ => return Err(ActorError::UnrecognizedPacketType), }; Ok(())