Handle getBreakableLines in source actor

Co-authored-by: atbrakhi <atbrakhi@igalia.com>
Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
Delan Azabani 2025-06-24 17:49:40 +10:00
parent e140ca9630
commit a7b9f8b2b1

View file

@ -63,6 +63,12 @@ struct SourceContentReply {
source: String,
}
#[derive(Serialize)]
struct GetBreakableLinesReply {
from: String,
lines: Vec<usize>,
}
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.
// <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#source-locations>
lines: (1..=line_count).collect(),
};
request.reply_final(&reply)?
},
_ => return Err(ActorError::UnrecognizedPacketType),
};
Ok(())