Skip to content

Commit

Permalink
Use identical(,print) to check for autoprint
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed Dec 4, 2024
1 parent 2557fa2 commit 50cc877
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/print.data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
# Other options investigated (could revisit): Cstack_info(), .Last.value gets set first before autoprint, history(), sys.status(),
# topenv(), inspecting next statement in caller, using clock() at C level to timeout suppression after some number of cycles
SYS = sys.calls()
if (length(SYS) <= 2L || # "> DT" auto-print or "> print(DT)" explicit print (cannot distinguish from R 3.2.0 but that's ok)
if (identical(SYS[[1L]][[1L]], print) ||
( length(SYS) >= 3L && is.symbol(thisSYS <- SYS[[length(SYS)-2L]][[1L]]) &&
as.character(thisSYS) == 'source') ) { # suppress printing from source(echo = TRUE) calls, #2369
return(invisible(x))
Expand Down

0 comments on commit 50cc877

Please sign in to comment.