Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Melkiades committed Oct 10, 2023
1 parent 378efff commit 1f5a872
Showing 1 changed file with 9 additions and 29 deletions.
38 changes: 9 additions & 29 deletions R/pagination.R
Original file line number Diff line number Diff line change
Expand Up @@ -893,28 +893,6 @@ setGeneric("has_page_title", function(obj) standardGeneric("has_page_title"))

setMethod("has_page_title", "ANY", function(obj) length(page_titles(obj)) > 0)

# Retain listing key column formatting with pagination
paginate_listing_strings <- function(df, i, mpf) {
l_mfs <- lapply(i, function(ii) {
mf_strings(matrix_form(df[ii, ]))
})

if (length(l_mfs) > 1) {
l_res <- lapply(l_mfs[-1], function(x) {
x[-1, ] # remove header row
})

l_mfs <- c(l_mfs[1], l_res)
}

new_mpf_strings <- do.call(rbind, l_mfs)

stopifnot(identical(dim(new_mpf_strings), dim(mf_strings(mpf))))

mf_strings(mpf) <- new_mpf_strings
mpf
}

#' @rdname paginate_indices
#' @export
paginate_to_mpfs <- function(obj,
Expand All @@ -938,7 +916,7 @@ paginate_to_mpfs <- function(obj,
rep_cols = num_rep_cols(obj),
col_gap = 2,
verbose = FALSE) {

browser()
mpf <- matrix_form(obj, TRUE, TRUE, indent_size = indent_size)
if(is.null(colwidths))
colwidths <- mf_col_widths(mpf) %||% propose_column_widths(mpf)
Expand Down Expand Up @@ -1015,13 +993,15 @@ paginate_to_mpfs <- function(obj,
rep_cols = rep_cols,
verbose = verbose)

if (any(class(obj) == "listing_df")) {
mpf <- paginate_listing_strings(obj, page_indices$pag_row_indices, mpf)
if (any(inherits(obj, "listing_df"))) {
pagmats <- lapply(page_indices$pag_row_indices,
function(ii) matrix_form(lsting[ii, ], TRUE, TRUE,
indent_size = indent_size))
} else {
pagmats <- lapply(page_indices$pag_row_indices, function(ii) {
mpf_subset_rows(mpf, ii)
})
}
pagmats <- lapply(page_indices$pag_row_indices, function(ii) {
mpf_subset_rows(mpf, ii)
})

## these chunks now carry around their (correctly subset) col widths...
res <- lapply(pagmats, function(matii) {
lapply(page_indices$pag_col_indices, function(jj) {
Expand Down

0 comments on commit 1f5a872

Please sign in to comment.