From a7b9f8b2b1d1f71bbc6526047d60380725f6f5a1 Mon Sep 17 00:00:00 2001 From: Delan Azabani Date: Tue, 24 Jun 2025 17:49:40 +1000 Subject: [PATCH] Handle getBreakableLines in source actor Co-authored-by: atbrakhi Signed-off-by: Delan Azabani --- components/devtools/actors/source.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/components/devtools/actors/source.rs b/components/devtools/actors/source.rs index 487f34cef3d..3cf2d279183 100644 --- a/components/devtools/actors/source.rs +++ b/components/devtools/actors/source.rs @@ -63,6 +63,12 @@ struct SourceContentReply { source: String, } +#[derive(Serialize)] +struct GetBreakableLinesReply { + from: String, + lines: Vec, +} + impl SourceManager { pub fn new() -> Self { Self { @@ -155,6 +161,23 @@ impl Actor for SourceActor { }; request.reply_final(&reply)? }, + // Client wants to know which lines can have breakpoints. + // Sent when opening a source in the Sources panel, and controls whether the line numbers can be clicked. + "getBreakableLines" => { + // Tell the client that every line is breakable. + // TODO: determine which lines are actually breakable. + let line_count = self + .content + .as_ref() + .map_or(0, |content| content.lines().count()); + let reply = GetBreakableLinesReply { + from: self.name(), + // Line numbers are one-based. + // + lines: (1..=line_count).collect(), + }; + request.reply_final(&reply)? + }, _ => return Err(ActorError::UnrecognizedPacketType), }; Ok(())