Skip to content

Commit 11444ad

Browse files
committed
Make pro-active breakpoints opt-in
1 parent a6974a6 commit 11444ad

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

crates/ark/src/console/console_repl.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const DEBUG_COMMANDS_CONTINUE: &[&str] = &["n", "f", "c", "cont", "Q"];
3535
static R_INIT: once_cell::sync::OnceCell<()> = once_cell::sync::OnceCell::new();
3636

3737
/// An enum representing the different modes in which the R session can run.
38-
#[derive(PartialEq, Clone, Copy)]
38+
#[derive(Debug, PartialEq, Clone, Copy)]
3939
pub enum SessionMode {
4040
/// A session with an interactive console (REPL), such as in Positron.
4141
Console,
@@ -192,6 +192,7 @@ pub(crate) struct KernelInfo {
192192
pub(crate) banner: String,
193193
pub(crate) input_prompt: Option<String>,
194194
pub(crate) continuation_prompt: Option<String>,
195+
pub(crate) session_mode: SessionMode,
195196
}
196197

197198
/// The kind of prompt we're handling in the REPL.
@@ -485,7 +486,7 @@ impl Console {
485486
log::info!(
486487
"R has started and ark handlers have been registered, completing initialization."
487488
);
488-
Self::complete_initialization(console.banner.take(), kernel_init_tx);
489+
Self::complete_initialization(console.banner.take(), console.session_mode, kernel_init_tx);
489490

490491
// Spawn handler loop for async messages from other components (e.g., LSP).
491492
// Note that we do it after init is complete to avoid deadlocking
@@ -576,7 +577,11 @@ impl Console {
576577
/// # Safety
577578
///
578579
/// Can only be called from the R thread, and only once.
579-
fn complete_initialization(banner: Option<String>, mut kernel_init_tx: Bus<KernelInfo>) {
580+
fn complete_initialization(
581+
banner: Option<String>,
582+
session_mode: SessionMode,
583+
mut kernel_init_tx: Bus<KernelInfo>,
584+
) {
580585
let version = unsafe {
581586
let version = Rf_findVarInFrame(R_BaseNamespace, r_symbol!("R.version.string"));
582587
RObject::new(version).to::<String>().unwrap()
@@ -591,6 +596,7 @@ impl Console {
591596
banner: banner.unwrap_or_default(),
592597
input_prompt: Some(input_prompt),
593598
continuation_prompt: Some(continuation_prompt),
599+
session_mode,
594600
};
595601

596602
// Set `R_INIT` before broadcasting so that threads unblocked by the

crates/ark/src/shell.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use tokio::sync::mpsc::UnboundedSender as AsyncUnboundedSender;
4545
use crate::ark_comm::ArkComm;
4646
use crate::console::Console;
4747
use crate::console::KernelInfo;
48+
use crate::console::SessionMode;
4849
use crate::data_explorer::r_data_explorer::DATA_EXPLORER_COMM_NAME;
4950
use crate::help::r_help::RHelp;
5051
use crate::help_proxy;
@@ -144,6 +145,11 @@ impl ShellHandler for Shell {
144145
continuation_prompt: kernel_info.continuation_prompt.clone(),
145146
}),
146147
};
148+
let mut supported_features = vec![String::from("debugger")];
149+
if matches!(kernel_info.session_mode, SessionMode::Notebook) {
150+
supported_features.push(String::from("proactive breakpoints"));
151+
}
152+
147153
Ok(KernelInfoReply {
148154
status: Status::Ok,
149155
banner: kernel_info.banner.clone(),
@@ -152,7 +158,7 @@ impl ShellHandler for Shell {
152158
language_info: info,
153159
implementation: String::from("ark"),
154160
implementation_version: String::from(env!("CARGO_PKG_VERSION")),
155-
supported_features: vec![String::from("debugger")],
161+
supported_features,
156162
})
157163
}
158164

0 commit comments

Comments
 (0)