From b1412c1ea4083c22053ef3417cb31f61d0d3835e Mon Sep 17 00:00:00 2001 From: venom1204 Date: Wed, 10 Jun 2026 21:06:32 +0000 Subject: [PATCH 01/13] new pr --- NEWS.md | 2 ++ R/print.data.table.R | 33 +++++++++++++++++++++------------ inst/tests/tests.Rraw | 7 +++++++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/NEWS.md b/NEWS.md index 45a36dcf0c..269aa59719 100644 --- a/NEWS.md +++ b/NEWS.md @@ -56,6 +56,8 @@ 11. `between()` now supports `Date` and `IDate` bounds with default `NAbounds=TRUE`, avoiding errors like "Not yet implemented NAbounds=TRUE for this non-numeric and non-character type" when date bounds contain `NA`, [#7281](https://github.com/Rdatatable/data.table/issues/7281). Thanks @grcatlin for the report and fix, and @ben-schwen and @aitap for assistance. +12. `print.data.table()` now correctly truncates long character columns and list-column summaries to avoid horizontal console overflow, [#7718](https://github.com/Rdatatable/data.table/issues/7718). When `datatable.prettyprint.char` is `NULL` (the default), the truncation limit is now dynamically calculated as `getOption("width") - 5L`. Thanks @tdhock for the report and @venom1204 for the fix. + ### Notes 1. {data.table} now depends on R 3.5.0 (2018). diff --git a/R/print.data.table.R b/R/print.data.table.R index 88ff4ea505..b6d219c669 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -88,7 +88,13 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"), } require_bit64_if_needed(x) classes = classes1(toprint) - toprint=format.data.table(toprint, na.encode=FALSE, timezone = timezone, ...) # na.encode=FALSE so that NA in character cols print as + + trunc.char = getOption("datatable.prettyprint.char") + if (is.null(trunc.char)) { + rn_w = if (isTRUE(row.names)) nchar(as.character(max(rn))) + 2L else 0L + trunc.char = max(0L, getOption("width") - rn_w - 3L) + } + toprint=format.data.table(toprint, na.encode=FALSE, timezone = timezone, trunc.char = trunc.char, ...) # na.encode=FALSE so that NA in character cols print as # FR #353 - add row.names = logical argument to print.data.table if (isTRUE(row.names)) rownames(toprint)=paste0(format(rn,right=TRUE,scientific=FALSE),":") else rownames(toprint)=rep.int("", nrow(toprint)) @@ -155,12 +161,12 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"), invisible(x) } -format.data.table = function(x, ..., justify="none") { +format.data.table = function(x, ..., trunc.char = getOption("datatable.prettyprint.char"), justify="none") { if (is.atomic(x) && !is.null(x)) { ## future R can use if (is.atomic(x)) stopf("Internal structure doesn't seem to be a list. Possibly corrupt data.table.") } - do.call(cbind, lapply(x, format_col, ..., justify=justify)) + do.call(cbind, lapply(x, format_col, ..., trunc.char = trunc.char, justify=justify)) } shouldPrint = function(x) { @@ -198,13 +204,13 @@ has_format_method = function(x) { any(vapply_1b(class(x), f)) } -format_col.default = function(x, ...) { +format_col.default = function(x, ..., trunc.char = getOption("datatable.prettyprint.char")) { if (!is.null(dim(x))) "" else if (is.list(x)) - vapply_1c(x, format_list_item, ...) + vapply_1c(x, format_list_item, ..., trunc.char = trunc.char) else - format(char.trunc(x), ...) # relevant to #37 + format(char.trunc(x, trunc.char = trunc.char), ...) # relevant to #37 } # #2842 -- different columns can have different tzone, so force usage in output @@ -221,10 +227,10 @@ format_col.POSIXct = function(x, ..., timezone=FALSE) { } # #3011 -- expression columns can wrap to newlines which breaks printing -format_col.expression = function(x, ...) format(char.trunc(as.character(x)), ...) +format_col.expression = function(x, ..., trunc.char = getOption("datatable.prettyprint.char")) format(char.trunc(as.character(x), trunc.char = trunc.char), ...) -format_list_item.default = function(x, ...) { - if (is.null(x)) # NULL item in a list column +format_list_item.default = function(x, ..., trunc.char = getOption("datatable.prettyprint.char")) { + res = if (is.null(x)) # NULL item in a list column "[NULL]" # not '' or 'NULL' to distinguish from those "common" string values in data else if (is.atomic(x) || inherits(x, "formula")) # FR #2591 - format.data.table issue with columns of class "formula" paste(c(format(head(x, 6L), ...), if (length(x) > 6L) sprintf("...[%d]", length(x))), collapse=",") # fix for #5435, #37, and #605 - format has to be added here... @@ -235,6 +241,7 @@ format_list_item.default = function(x, ...) { } else { paste0("<", class1(x), paste_dims(x), ">") } + char.trunc(res, trunc.char = trunc.char) } # #6592 -- nested 1-column frames breaks printing @@ -247,12 +254,14 @@ format_list_item.data.frame = function(x, ...) { # Current implementation may have issues when dealing with strings that have combinations of full-width and half-width characters, # if this becomes a problem in the future, we could consider string traversal instead. char.trunc = function(x, trunc.char = getOption("datatable.prettyprint.char")) { + if (is.null(trunc.char)) return(x) trunc.char = max(0L, suppressWarnings(as.integer(trunc.char[1L])), na.rm=TRUE) if (!is.character(x) || trunc.char <= 0L) return(x) - nchar_width = nchar(x, 'width') # Check whether string is full-width or half-width, #5096 - nchar_chars = nchar(x, 'char') + nchar_width = nchar(x, 'width', allowNA = TRUE) + nchar_chars = nchar(x, 'char', allowNA = TRUE) is_full_width = nchar_width > nchar_chars - idx = !is.na(x) & pmin(nchar_width, nchar_chars) > trunc.char + is_full_width[is.na(is_full_width)] = FALSE + idx = !is.na(x) & !is.na(nchar_width) & pmin(nchar_width, nchar_chars) > trunc.char x[idx] = paste0(strtrim(x[idx], trunc.char * fifelse(is_full_width[idx], 2L, 1L)), "...") x } diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 687bf929ed..a50b2a38ff 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -21660,3 +21660,10 @@ test(2374.08, key(DT[, .(a, a)]), NULL) test(2374.09, key(subset(DT, select=c(a, a))), NULL) DT = data.table(a=1:2, a.1=3:4, val=10:11) test(2374.10, key(DT[, .(a.1, sum(val)), keyby=.(a, a)]), NULL) + +# print.data.table truncates long character columns based on width +test(2375.1, capture.output(print(data.table(x="1234567890"))), output="1234...", options=list(width=10, datatable.prettyprint.char=NULL)) +test(2375.2, capture.output(print(data.table(L=list(1:20)))), output="1,2,3,4,...", options=list(width=15, datatable.prettyprint.char=NULL)) +test(2375.3, capture.output(print(data.table(x=c("short", "abcdefghijklmnopqrstuvwxyz")))), output="abcdefghijklmn...", options=list(width=20, datatable.prettyprint.char=NULL)) +test(2375.4, capture.output(print(data.table(x="abcdefghijklmnopqrstuvwxyz"))), output="abcdefghijklmnopqrstuvwxyz", options=list(width=200, datatable.prettyprint.char=NULL)) +test(2375.5, capture.output(print(data.table(id=1L, score=99.1, txt="abcdefghijklmnopqrstuvwxyz"))), output="abcdefghijklmn...", options=list(width=20, datatable.prettyprint.char=NULL)) From 460da17f6189068de955ee57f8bd71fad39a68dc Mon Sep 17 00:00:00 2001 From: venom1204 Date: Wed, 10 Jun 2026 21:26:19 +0000 Subject: [PATCH 02/13] .. --- R/print.data.table.R | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/R/print.data.table.R b/R/print.data.table.R index b6d219c669..7311bd14eb 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -204,7 +204,10 @@ has_format_method = function(x) { any(vapply_1b(class(x), f)) } -format_col.default = function(x, ..., trunc.char = getOption("datatable.prettyprint.char")) { +format_col.default = function(x, ...) { + dots = list(...) + trunc.char = if ("trunc.char" %in% names(dots)) dots$trunc.char else getOption("datatable.prettyprint.char") + if (!is.null(dim(x))) "" else if (is.list(x)) @@ -227,9 +230,15 @@ format_col.POSIXct = function(x, ..., timezone=FALSE) { } # #3011 -- expression columns can wrap to newlines which breaks printing -format_col.expression = function(x, ..., trunc.char = getOption("datatable.prettyprint.char")) format(char.trunc(as.character(x), trunc.char = trunc.char), ...) +format_col.expression = function(x, ...) { + dots = list(...) + trunc.char = if ("trunc.char" %in% names(dots)) dots$trunc.char else getOption("datatable.prettyprint.char") + format(char.trunc(as.character(x), trunc.char = trunc.char), ...)} -format_list_item.default = function(x, ..., trunc.char = getOption("datatable.prettyprint.char")) { +format_list_item.default = function(x, ...) { + dots = list(...) + trunc.char = if ("trunc.char" %in% names(dots)) dots$trunc.char else getOption("datatable.prettyprint.char") + res = if (is.null(x)) # NULL item in a list column "[NULL]" # not '' or 'NULL' to distinguish from those "common" string values in data else if (is.atomic(x) || inherits(x, "formula")) # FR #2591 - format.data.table issue with columns of class "formula" From 74f6b1aec55311c78516f86c6819865fde501a72 Mon Sep 17 00:00:00 2001 From: venom1204 Date: Wed, 10 Jun 2026 21:35:40 +0000 Subject: [PATCH 03/13] lint --- R/print.data.table.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/print.data.table.R b/R/print.data.table.R index 7311bd14eb..ac58b02ab9 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -238,7 +238,6 @@ format_col.expression = function(x, ...) { format_list_item.default = function(x, ...) { dots = list(...) trunc.char = if ("trunc.char" %in% names(dots)) dots$trunc.char else getOption("datatable.prettyprint.char") - res = if (is.null(x)) # NULL item in a list column "[NULL]" # not '' or 'NULL' to distinguish from those "common" string values in data else if (is.atomic(x) || inherits(x, "formula")) # FR #2591 - format.data.table issue with columns of class "formula" From 4fb6707f3ab028c3c412aa62e2f2390da2e75631 Mon Sep 17 00:00:00 2001 From: venom1204 Date: Wed, 10 Jun 2026 21:43:38 +0000 Subject: [PATCH 04/13] . --- R/print.data.table.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/print.data.table.R b/R/print.data.table.R index ac58b02ab9..21feb066da 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -207,7 +207,6 @@ has_format_method = function(x) { format_col.default = function(x, ...) { dots = list(...) trunc.char = if ("trunc.char" %in% names(dots)) dots$trunc.char else getOption("datatable.prettyprint.char") - if (!is.null(dim(x))) "" else if (is.list(x)) From 72b6b7294ddd3e46c00dc4d4bfd08ddc525c459d Mon Sep 17 00:00:00 2001 From: venom1204 Date: Wed, 10 Jun 2026 22:59:34 +0000 Subject: [PATCH 05/13] updated list(...) , news, tests --- NEWS.md | 2 +- R/print.data.table.R | 23 ++++++++--------------- inst/tests/tests.Rraw | 1 + man/print.data.table.Rd | 7 ++++--- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/NEWS.md b/NEWS.md index 269aa59719..659abb36a4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -56,7 +56,7 @@ 11. `between()` now supports `Date` and `IDate` bounds with default `NAbounds=TRUE`, avoiding errors like "Not yet implemented NAbounds=TRUE for this non-numeric and non-character type" when date bounds contain `NA`, [#7281](https://github.com/Rdatatable/data.table/issues/7281). Thanks @grcatlin for the report and fix, and @ben-schwen and @aitap for assistance. -12. `print.data.table()` now correctly truncates long character columns and list-column summaries to avoid horizontal console overflow, [#7718](https://github.com/Rdatatable/data.table/issues/7718). When `datatable.prettyprint.char` is `NULL` (the default), the truncation limit is now dynamically calculated as `getOption("width") - 5L`. Thanks @tdhock for the report and @venom1204 for the fix. +12. `print.data.table()` now correctly truncates long character columns and list-column summaries to avoid horizontal console overflow, [#7718](https://github.com/Rdatatable/data.table/issues/7718). When `datatable.prettyprint.char` is `NULL` (the default), the truncation limit is now dynamically calculated based on the available console width. Thanks @tdhock for the report and @venom1204 for the fix. ### Notes diff --git a/R/print.data.table.R b/R/print.data.table.R index 21feb066da..856fe311d2 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -204,9 +204,7 @@ has_format_method = function(x) { any(vapply_1b(class(x), f)) } -format_col.default = function(x, ...) { - dots = list(...) - trunc.char = if ("trunc.char" %in% names(dots)) dots$trunc.char else getOption("datatable.prettyprint.char") +format_col.default = function(x, ..., trunc.char = getOption("datatable.prettyprint.char")) { if (!is.null(dim(x))) "" else if (is.list(x)) @@ -229,21 +227,16 @@ format_col.POSIXct = function(x, ..., timezone=FALSE) { } # #3011 -- expression columns can wrap to newlines which breaks printing -format_col.expression = function(x, ...) { - dots = list(...) - trunc.char = if ("trunc.char" %in% names(dots)) dots$trunc.char else getOption("datatable.prettyprint.char") - format(char.trunc(as.character(x), trunc.char = trunc.char), ...)} +format_col.expression = function(x, ..., trunc.char = getOption("datatable.prettyprint.char")) { + format(char.trunc(as.character(x), trunc.char = trunc.char), ...) +} -format_list_item.default = function(x, ...) { - dots = list(...) - trunc.char = if ("trunc.char" %in% names(dots)) dots$trunc.char else getOption("datatable.prettyprint.char") +format_list_item.default = function(x, ..., trunc.char = getOption("datatable.prettyprint.char")) { res = if (is.null(x)) # NULL item in a list column - "[NULL]" # not '' or 'NULL' to distinguish from those "common" string values in data - else if (is.atomic(x) || inherits(x, "formula")) # FR #2591 - format.data.table issue with columns of class "formula" - paste(c(format(head(x, 6L), ...), if (length(x) > 6L) sprintf("...[%d]", length(x))), collapse=",") # fix for #5435, #37, and #605 - format has to be added here... + "[NULL]" + else if (is.atomic(x) || inherits(x, "formula")) + paste(c(format(head(x, 6L), ...), if (length(x) > 6L) sprintf("...[%d]", length(x))), collapse=",") else if (has_format_method(x) && length(formatted<-format(x, ...))==1L) { - # the column's class does not have a format method (otherwise it would have been used by format_col and this - # format_list_item would not be reached) but this particular list item does have a format method so use it formatted } else { paste0("<", class1(x), paste_dims(x), ">") diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index a50b2a38ff..abeb4c15f5 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -21667,3 +21667,4 @@ test(2375.2, capture.output(print(data.table(L=list(1:20)))), output="1,2,3,4,.. test(2375.3, capture.output(print(data.table(x=c("short", "abcdefghijklmnopqrstuvwxyz")))), output="abcdefghijklmn...", options=list(width=20, datatable.prettyprint.char=NULL)) test(2375.4, capture.output(print(data.table(x="abcdefghijklmnopqrstuvwxyz"))), output="abcdefghijklmnopqrstuvwxyz", options=list(width=200, datatable.prettyprint.char=NULL)) test(2375.5, capture.output(print(data.table(id=1L, score=99.1, txt="abcdefghijklmnopqrstuvwxyz"))), output="abcdefghijklmn...", options=list(width=20, datatable.prettyprint.char=NULL)) +test(2375.6, tail(capture.output(print(data.table(x=rep("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1000000)), topn=1)), 1), output="1000000: ABCDEFGHIJKLM...", options=list(width=25, datatable.prettyprint.char=NULL)) diff --git a/man/print.data.table.Rd b/man/print.data.table.Rd index 7d51a55fc1..6ec0c69205 100644 --- a/man/print.data.table.Rd +++ b/man/print.data.table.Rd @@ -30,17 +30,18 @@ timezone=FALSE, \dots) format_col(x, \dots) - \method{format_col}{default}(x, \dots) + \method{format_col}{default}(x, \dots, trunc.char = getOption("datatable.prettyprint.char")) \method{format_col}{POSIXct}(x, \dots, timezone=FALSE) - \method{format_col}{expression}(x, \dots) + \method{format_col}{expression}(x, \dots, trunc.char = getOption("datatable.prettyprint.char")) format_list_item(x, \dots) - \method{format_list_item}{default}(x, \dots) + \method{format_list_item}{default}(x, \dots, trunc.char = getOption("datatable.prettyprint.char")) } \arguments{ \item{x}{ A \code{data.table}. } \item{topn}{ The number of rows to be printed from the beginning and end of tables with more than \code{nrows} rows. } \item{nrows}{ The number of rows which will be printed before truncation is enforced. } + \item{trunc.char}{The number of characters at which character columns and list-column summaries are truncated. If \code{NULL} (the default), it is dynamically calculated based on the available console width.} \item{class}{ If \code{TRUE}, the resulting output will include above each column its storage class (or a self-evident abbreviation thereof). When combined with \code{col.names="auto"} and tables >20 rows, classes will also appear at the bottom.} \item{row.names}{ If \code{TRUE}, row indices will be printed alongside \code{x}. } \item{col.names}{ One of three flavours for controlling the display of column names in output. \code{"auto"} includes column names above the data, as well as below the table if \code{nrow(x) > 20} (when \code{class=TRUE}, column classes will also appear at the bottom). \code{"top"} excludes this lower register when applicable, and \code{"none"} suppresses column names altogether (as well as column classes if \code{class = TRUE}. } From 6a1d3a815f37ffabb2f7a0ccf19dcdaff027905a Mon Sep 17 00:00:00 2001 From: venom1204 Date: Wed, 10 Jun 2026 23:04:31 +0000 Subject: [PATCH 06/13] lintr --- R/print.data.table.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/print.data.table.R b/R/print.data.table.R index 856fe311d2..ffb6bc522d 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -233,9 +233,9 @@ format_col.expression = function(x, ..., trunc.char = getOption("datatable.prett format_list_item.default = function(x, ..., trunc.char = getOption("datatable.prettyprint.char")) { res = if (is.null(x)) # NULL item in a list column - "[NULL]" - else if (is.atomic(x) || inherits(x, "formula")) - paste(c(format(head(x, 6L), ...), if (length(x) > 6L) sprintf("...[%d]", length(x))), collapse=",") + "[NULL]" + else if (is.atomic(x) || inherits(x, "formula")) + paste(c(format(head(x, 6L), ...), if (length(x) > 6L) sprintf("...[%d]", length(x))), collapse=",") else if (has_format_method(x) && length(formatted<-format(x, ...))==1L) { formatted } else { From 741974bbfc76356d4f86dc77abfeb7213eb90d74 Mon Sep 17 00:00:00 2001 From: venom1204 Date: Thu, 11 Jun 2026 18:19:16 +0000 Subject: [PATCH 07/13] added examples in doc --- man/print.data.table.Rd | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/man/print.data.table.Rd b/man/print.data.table.Rd index 6ec0c69205..abe116a269 100644 --- a/man/print.data.table.Rd +++ b/man/print.data.table.Rd @@ -135,5 +135,13 @@ iris_agg = iris[ , .(reg = list(lm(Sepal.Length ~ Petal.Length))), by = Species] format_list_item.lm = function(x, ...) sprintf('', format(x$call$formula)) print(iris_agg) + + # Truncation based on console width + old = options(width = 25, datatable.prettyprint.char = NULL) + data.table(x = "abcdefghijklmnopqrstuvwxyz", L = list(1:25)) + + # Dynamic truncation: Content shrinks as row labels grow + print(data.table(x = rep("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1e6)), topn = 1) + options(old) } From aa8c344643b86105c8fae7b2485ac2b7f7345ee8 Mon Sep 17 00:00:00 2001 From: venom1204 Date: Thu, 11 Jun 2026 18:22:36 +0000 Subject: [PATCH 08/13] added descriptive news --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 659abb36a4..e428fb25b3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -56,7 +56,7 @@ 11. `between()` now supports `Date` and `IDate` bounds with default `NAbounds=TRUE`, avoiding errors like "Not yet implemented NAbounds=TRUE for this non-numeric and non-character type" when date bounds contain `NA`, [#7281](https://github.com/Rdatatable/data.table/issues/7281). Thanks @grcatlin for the report and fix, and @ben-schwen and @aitap for assistance. -12. `print.data.table()` now correctly truncates long character columns and list-column summaries to avoid horizontal console overflow, [#7718](https://github.com/Rdatatable/data.table/issues/7718). When `datatable.prettyprint.char` is `NULL` (the default), the truncation limit is now dynamically calculated based on the available console width. Thanks @tdhock for the report and @venom1204 for the fix. +12. `print.data.table()` now truncates long character columns and list-column summaries by default to avoid horizontal console overflow, [#7718](https://github.com/Rdatatable/data.table/issues/7718). When `datatable.prettyprint.char` is `NULL` (the default), the truncation limit is now dynamically calculated based on the available console width. Thanks @tdhock for the report and @venom1204 for the fix. ### Notes From 470053dd2c48d04f1c6f992a106e373724dbe388 Mon Sep 17 00:00:00 2001 From: venom1204 Date: Sat, 13 Jun 2026 13:00:18 +0530 Subject: [PATCH 09/13] Update NEWS.md Co-authored-by: Toby Dylan Hocking --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index e428fb25b3..78df5463ad 100644 --- a/NEWS.md +++ b/NEWS.md @@ -56,7 +56,7 @@ 11. `between()` now supports `Date` and `IDate` bounds with default `NAbounds=TRUE`, avoiding errors like "Not yet implemented NAbounds=TRUE for this non-numeric and non-character type" when date bounds contain `NA`, [#7281](https://github.com/Rdatatable/data.table/issues/7281). Thanks @grcatlin for the report and fix, and @ben-schwen and @aitap for assistance. -12. `print.data.table()` now truncates long character columns and list-column summaries by default to avoid horizontal console overflow, [#7718](https://github.com/Rdatatable/data.table/issues/7718). When `datatable.prettyprint.char` is `NULL` (the default), the truncation limit is now dynamically calculated based on the available console width. Thanks @tdhock for the report and @venom1204 for the fix. +12. `print.data.table()` now truncates long character columns and list-column summaries by default to avoid horizontal console overflow, [#7718](https://github.com/Rdatatable/data.table/issues/7718). When `datatable.prettyprint.char` is `NULL` (the default), the truncation limit is now dynamically calculated based on the available console width. Use `options(datatable.prettyprint.char=Inf` for the old default behavior (never truncate). Thanks @tdhock for the report and @venom1204 for the fix. ### Notes From b832b601c25351d15102b698f877d49116a7b365 Mon Sep 17 00:00:00 2001 From: venom1204 Date: Sat, 13 Jun 2026 13:00:37 +0530 Subject: [PATCH 10/13] Update man/print.data.table.Rd Co-authored-by: Toby Dylan Hocking --- man/print.data.table.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/print.data.table.Rd b/man/print.data.table.Rd index abe116a269..442194b231 100644 --- a/man/print.data.table.Rd +++ b/man/print.data.table.Rd @@ -41,7 +41,7 @@ \item{x}{ A \code{data.table}. } \item{topn}{ The number of rows to be printed from the beginning and end of tables with more than \code{nrows} rows. } \item{nrows}{ The number of rows which will be printed before truncation is enforced. } - \item{trunc.char}{The number of characters at which character columns and list-column summaries are truncated. If \code{NULL} (the default), it is dynamically calculated based on the available console width.} + \item{trunc.char}{The number of characters at which character columns and list-column summaries are truncated. If \code{NULL} (the default), it is dynamically calculated based on \code{getOption("width")}.} \item{class}{ If \code{TRUE}, the resulting output will include above each column its storage class (or a self-evident abbreviation thereof). When combined with \code{col.names="auto"} and tables >20 rows, classes will also appear at the bottom.} \item{row.names}{ If \code{TRUE}, row indices will be printed alongside \code{x}. } \item{col.names}{ One of three flavours for controlling the display of column names in output. \code{"auto"} includes column names above the data, as well as below the table if \code{nrow(x) > 20} (when \code{class=TRUE}, column classes will also appear at the bottom). \code{"top"} excludes this lower register when applicable, and \code{"none"} suppresses column names altogether (as well as column classes if \code{class = TRUE}. } From 0830289f0125d2335b4a2e706e1add1d5a40492f Mon Sep 17 00:00:00 2001 From: venom1204 Date: Sat, 13 Jun 2026 07:32:33 +0000 Subject: [PATCH 11/13] .. --- inst/tests/tests.Rraw | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index abeb4c15f5..2de4d7544f 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -21663,6 +21663,7 @@ test(2374.10, key(DT[, .(a.1, sum(val)), keyby=.(a, a)]), NULL) # print.data.table truncates long character columns based on width test(2375.1, capture.output(print(data.table(x="1234567890"))), output="1234...", options=list(width=10, datatable.prettyprint.char=NULL)) +test(2375.11, print(data.table(x="1234567890")), output="1234567890", options=list(width=10, datatable.prettyprint.char=Inf)) test(2375.2, capture.output(print(data.table(L=list(1:20)))), output="1,2,3,4,...", options=list(width=15, datatable.prettyprint.char=NULL)) test(2375.3, capture.output(print(data.table(x=c("short", "abcdefghijklmnopqrstuvwxyz")))), output="abcdefghijklmn...", options=list(width=20, datatable.prettyprint.char=NULL)) test(2375.4, capture.output(print(data.table(x="abcdefghijklmnopqrstuvwxyz"))), output="abcdefghijklmnopqrstuvwxyz", options=list(width=200, datatable.prettyprint.char=NULL)) From 26493ff63019bc4e1f49e38b760b7bdde5ccf83e Mon Sep 17 00:00:00 2001 From: venom1204 Date: Sun, 14 Jun 2026 17:47:42 +0530 Subject: [PATCH 12/13] Update NEWS.md Co-authored-by: Toby Dylan Hocking --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 78df5463ad..9de21ce6f7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -56,7 +56,7 @@ 11. `between()` now supports `Date` and `IDate` bounds with default `NAbounds=TRUE`, avoiding errors like "Not yet implemented NAbounds=TRUE for this non-numeric and non-character type" when date bounds contain `NA`, [#7281](https://github.com/Rdatatable/data.table/issues/7281). Thanks @grcatlin for the report and fix, and @ben-schwen and @aitap for assistance. -12. `print.data.table()` now truncates long character columns and list-column summaries by default to avoid horizontal console overflow, [#7718](https://github.com/Rdatatable/data.table/issues/7718). When `datatable.prettyprint.char` is `NULL` (the default), the truncation limit is now dynamically calculated based on the available console width. Use `options(datatable.prettyprint.char=Inf` for the old default behavior (never truncate). Thanks @tdhock for the report and @venom1204 for the fix. +12. `print.data.table()` now truncates long character columns and list-column summaries by default to avoid horizontal console overflow, [#7718](https://github.com/Rdatatable/data.table/issues/7718). When `datatable.prettyprint.char` is `NULL` (the default), the truncation limit is now dynamically calculated based on the available console width. Use `options(datatable.prettyprint.char=Inf)` for the old default behavior (never truncate). Thanks @tdhock for the report and @venom1204 for the fix. ### Notes From f3cc0edba231b1554ba656d04ca75741de857dd4 Mon Sep 17 00:00:00 2001 From: venom1204 Date: Tue, 16 Jun 2026 01:37:12 +0530 Subject: [PATCH 13/13] Update R/print.data.table.R Co-authored-by: Toby Dylan Hocking --- R/print.data.table.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/print.data.table.R b/R/print.data.table.R index ffb6bc522d..e602f80d69 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -88,7 +88,6 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"), } require_bit64_if_needed(x) classes = classes1(toprint) - trunc.char = getOption("datatable.prettyprint.char") if (is.null(trunc.char)) { rn_w = if (isTRUE(row.names)) nchar(as.character(max(rn))) + 2L else 0L