diff --git a/components/devtools/actors/source.rs b/components/devtools/actors/source.rs index 9f8dfcde3cd..d1bb564def8 100644 --- a/components/devtools/actors/source.rs +++ b/components/devtools/actors/source.rs @@ -64,6 +64,12 @@ struct SourceContentReply { source: String, } +#[derive(Serialize)] +struct GetBreakableLinesReply { + from: String, + lines: Vec, +} + impl SourceManager { pub fn new() -> Self { Self { @@ -157,6 +163,24 @@ impl Actor for SourceActor { let _ = stream.write_json_packet(&reply); ActorMessageStatus::Processed }, + // 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(), + }; + let _ = stream.write_json_packet(&reply); + ActorMessageStatus::Processed + }, _ => ActorMessageStatus::Ignored, }) }