Skip to content

Commit 8d2c19c

Browse files
committed
Update Variables comm contract
1 parent 56fe788 commit 8d2c19c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

crates/amalthea/src/comm/variables_comm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ pub enum VariablesBackendReply {
295295
ClipboardFormatReply(FormattedVariable),
296296

297297
/// The ID of the viewer that was opened.
298-
ViewReply(String),
298+
ViewReply(Option<String>),
299299

300300
}
301301

crates/ark/src/variables/r_variables.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,16 +367,16 @@ impl RVariables {
367367
/// Open a data viewer for the given variable.
368368
///
369369
/// - `path`: The path to the variable to view, as an array of access keys
370-
fn view(&mut self, path: &Vec<String>) -> Result<String, harp::error::Error> {
370+
///
371+
/// Returns the ID of the comm managing the view, if any.
372+
fn view(&mut self, path: &Vec<String>) -> Result<Option<String>, harp::error::Error> {
371373
r_task(|| {
372374
let env = self.env.get().clone();
373375
let obj = PositronVariable::resolve_data_object(env.clone(), &path)?;
374376

375377
if r_is_function(obj.sexp) {
376378
harp::as_result(view(&obj, &path, &env))?;
377-
378-
// Return a falsy `viewerId`. Should ideally be a more explicit `None`.
379-
return Ok(String::from(""));
379+
return Ok(None);
380380
}
381381

382382
let name = unsafe { path.get_unchecked(path.len() - 1) };
@@ -392,7 +392,7 @@ impl RVariables {
392392
Some(binding),
393393
self.comm_manager_tx.clone(),
394394
)?;
395-
Ok(viewer_id)
395+
Ok(Some(viewer_id))
396396
})
397397
}
398398

0 commit comments

Comments
 (0)