diff --git a/R/app-server.R b/R/app-server.R index 7fa26b1..4c08ac3 100644 --- a/R/app-server.R +++ b/R/app-server.R @@ -99,8 +99,7 @@ app_server <- function(input, output, session) { error <- ch_r_error() if (!is.null(error)) { stopApp() - print(error) - abort("Streaming returned error") + abort(error) } }) } diff --git a/R/ch-r.R b/R/ch-r.R index b408383..6555193 100644 --- a/R/ch-r.R +++ b/R/ch-r.R @@ -46,11 +46,13 @@ ch_r_output <- function() { ch_r_error <- function() { out <- NULL - if (!is.null(ch_env$r_session)) { - read_session <- ch_env$r_session$read() - if (!is.null(read_session)) { - out <- read_session$error + err <- ch_env$r_session$read_error() + if (err != "") { + error_marker <- "! {error}" + if(substr(err, 1, nchar(error_marker)) == error_marker) { + err <- substr(err, nchar(error_marker) + 1, nchar(err)) } + out <- err } out } diff --git a/R/chattr-defaults.R b/R/chattr-defaults.R index c15e881..6bf3dd8 100644 --- a/R/chattr-defaults.R +++ b/R/chattr-defaults.R @@ -68,10 +68,12 @@ chattr_defaults <- function(type = "default", type <- "console" } else { type <- ui_current() - if (type == "markdown") type <- "notebook" + } } + if (type == "markdown") type <- "notebook" + if (force) { ch_env$defaults <- NULL } diff --git a/R/chattr.R b/R/chattr.R index 05fc984..b8f1ec2 100644 --- a/R/chattr.R +++ b/R/chattr.R @@ -43,7 +43,15 @@ chattr <- function(prompt = NULL, while (ch_r_state() == "busy") { curr_text <- ch_r_output() ret <- c(ret, curr_text) - ide_paste_text(curr_text) + if(ui_current() == "markdown") { + cat(curr_text) + } else { + ide_paste_text(curr_text) + } + } + error <- ch_r_error() + if (!is.null(error)) { + abort(error) } } else { ret <- ch_submit(