diff --git a/R/tbl-format-setup.R b/R/tbl-format-setup.R index 1f2ce2198..9311addc0 100644 --- a/R/tbl-format-setup.R +++ b/R/tbl-format-setup.R @@ -114,8 +114,9 @@ tbl_format_setup.tbl <- function(x, width, ..., # Number of rows rows <- nrow(x) - if (is.na(rows)) { - df <- df_head(x, n + 1) + lazy <- is.na(rows) + if (lazy) { + df <- as.data.frame(head(x, n + 1)) if (nrow(df) <= n) { rows <- nrow(df) } else { @@ -147,7 +148,7 @@ tbl_format_setup.tbl <- function(x, width, ..., colonnade <- ctl_colonnade( df, - has_row_id = if (.row_names_info(x) > 0) "*" else TRUE, + has_row_id = if (!lazy && .row_names_info(x) > 0) "*" else TRUE, width = width, controller = x, focus = focus diff --git a/tests/testthat/_snaps/tbl-format-setup.md b/tests/testthat/_snaps/tbl-format-setup.md index 293473f07..7b0fdfb6f 100644 --- a/tests/testthat/_snaps/tbl-format-setup.md +++ b/tests/testthat/_snaps/tbl-format-setup.md @@ -1420,7 +1420,7 @@ # A data frame: ?? x 3 Girth Height Volume - * + 1 8.3 70 10.3 2 8.6 65 10.3 3 8.8 63 10.2 @@ -1439,7 +1439,7 @@ # A data frame: ?? x 3 Girth Height Volume - * + 1 8.3 70 10.3 2 8.6 65 10.3 3 8.8 63 10.2 @@ -1459,7 +1459,7 @@ # A data frame: ?? x 3 Girth Height Volume - * + 1 8.3 70 10.3 2 8.6 65 10.3 3 8.8 63 10.2