Skip to content

Commit f56ae3f

Browse files
committed
Update notebook
1 parent 675e156 commit f56ae3f

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

R/notebook.R

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,20 @@ local({
2121
cat(sprintf("[%s]\n%s\n", request$time, request$expr))
2222
str <- tryCatch({
2323
expr <- parse(text = request$expr)
24-
out <- eval(expr, globalenv())
25-
list(
26-
type = "output",
27-
result = paste0(utils::capture.output(print(out)), collapse = "\n")
28-
)
24+
out <- withVisible(eval(expr, globalenv()))
25+
if (out$visible) {
26+
print_text <- utils::capture.output(print(out$value))
27+
res <- list(
28+
type = "text",
29+
result = paste0(print_text, collapse = "\n")
30+
)
31+
} else {
32+
res <- list(
33+
type = "text",
34+
result = ""
35+
)
36+
}
37+
res
2938
}, error = function(e) {
3039
list(
3140
type = "error",

src/notebook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { dirname } from 'path';
55
import getPort = require('get-port');
66

77
interface REvalOutput {
8-
type: 'output' | 'error';
8+
type: 'text' | 'plot' | 'viewer' | 'browser' | 'error';
99
result: string;
1010
}
1111

0 commit comments

Comments
 (0)