Skip to content

Behavior of options(browse =) outside of Positron #588

@DavisVaughan

Description

@DavisVaughan

Right now we always override options(browse =) and add our special Positron specific behavior. This isn't great for Jupyter kernels

unsafe fn ps_browse_url_impl(url: SEXP) -> anyhow::Result<SEXP> {
// Extract URL.
let url = RObject::view(url).to::<String>()?;
let _span = tracing::trace_span!("browseURL", url = %url).entered();
// Handle help server requests.
if is_help_url(&url) {
log::trace!("Help is handling URL");
handle_help_url(url)?;
return Ok(Rf_ScalarLogical(1));
} else {
log::trace!("Help is not handling URL");
}
// For all other URLs, create a ShowUrl event and send it to the main
// thread; Positron will handle it.
let params = ShowUrlParams { url };
let event = UiFrontendEvent::ShowUrl(params);
RMain::with(|main| main.send_frontend_event(event));
Ok(Rf_ScalarLogical(1))
}

From @lionel-

The right thing to do outside Positron is to use the default action, i.e. open in a web browser. So we should not set up that option unless Positron is connected. Ideally Positron would inject the option via its init file. Or the UI comm could launch an idle task to do it, but there would a short time where the option is not set with this approach.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions