Skip to content

Commit b6f52bb

Browse files
committed
updated condition
1 parent 202011d commit b6f52bb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

R/print.data.table.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ char.trunc = function(x, trunc.char = getOption("datatable.prettyprint.char")) {
261261
dt_width = function(x, nrow, class, row.names, col.names) {
262262
widths = apply(nchar(x, type='width'), 2L, max)
263263
if (class) widths = pmax(widths, 6L)
264-
names_widths = if (col.names == "none") rep(0L, ncol(x)) else sapply(colnames(x), nchar, type = "width")
265-
dt_widths = pmax(widths, names_widths)
264+
if (col.names != "none") names = sapply(colnames(x), nchar, type="width") else names = 0L
265+
dt_widths = pmax(widths, names)
266266
rownum_width = if (row.names) as.integer(ceiling(log10(nrow))+2.0) else 0L
267267
cumsum(dt_widths + 1L) + rownum_width
268268
}

inst/tests/tests.Rraw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21130,7 +21130,7 @@ test(2311.2, nlevels(DT$V1), 2L) # used to be 3
2113021130
DF = list(rep(iconv("\uf8", from = "UTF-8", to = "latin1"), 2e6))
2113121131
test(2312, fwrite(DF, nullfile(), encoding = "UTF-8", nThread = 2L), NULL)
2113221132

21133-
# New tests for GitHub #6882 (col.names='none' column widths)
21133+
# tests for #6882 (col.names='none' column widths)
2113421134
test(2313.1, {
2113521135
dt <- data.table(short=1:3, verylongcolumnname=4:6)
2113621136
print(dt, col.names="none")

0 commit comments

Comments
 (0)