Skip to content

Commit

Permalink
Merge pull request #98 from mlverse/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
edgararuiz authored May 2, 2024
2 parents cd96c9a + 4c91123 commit 5ed63d0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
3 changes: 1 addition & 2 deletions R/app-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
Expand Down
10 changes: 6 additions & 4 deletions R/ch-r.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 3 additions & 1 deletion R/chattr-defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 9 additions & 1 deletion R/chattr.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 5ed63d0

Please sign in to comment.