Skip to content

Commit

Permalink
set_last_value()
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed Oct 26, 2023
1 parent 5336475 commit b2f2909
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions share/jupyter/kernels/xr/resources/execute.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ handle_error <- function(e) {
}

handle_value <- function(execution_counter) function(obj, visible) {
set_last_value(obj)
if (!visible) return()

# only doing text-plain for now
Expand Down
6 changes: 6 additions & 0 deletions share/jupyter/kernels/xr/resources/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ namedlist <- function() {
`names<-`(list(), character())
}

set_last_value <- function(obj) {
unlockBinding(".Last.value", .BaseNamespaceEnv)
assign(".Last.value", obj, .BaseNamespaceEnv)
lockBinding(".Last.value", .BaseNamespaceEnv)
}

# borrowed from IRkernel
plot_builds_upon <- function(prev, current) {
if (is.null(prev)) {
Expand Down

0 comments on commit b2f2909

Please sign in to comment.