Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions R/session/vsc.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ show_view <- !identical(getOption("vsc.view", "Two"), FALSE)
if (show_view) {
get_column_def <- function(name, field, value) {
filter <- TRUE
tooltip <- sprintf(
"class: [%s], type: %s",
toString(class(value)),
typeof(value)
)
if (is.numeric(value)) {
type <- "numericColumn"
if (is.null(attr(value, "class"))) {
Expand All @@ -335,6 +340,7 @@ if (show_view) {
}
list(
headerName = name,
headerTooltip = tooltip,
field = field,
type = type,
filter = filter
Expand All @@ -348,26 +354,26 @@ if (show_view) {

if (is.data.frame(data)) {
.nrow <- nrow(data)
colnames <- colnames(data)
if (is.null(colnames)) {
colnames <- sprintf("V%d", seq_len(ncol(data)))
.colnames <- colnames(data)
if (is.null(.colnames)) {
.colnames <- sprintf("V%d", seq_len(ncol(data)))
} else {
colnames <- trimws(colnames)
.colnames <- trimws(.colnames)
}
if (.row_names_info(data) > 0L) {
rownames <- rownames(data)
rownames(data) <- NULL
} else {
rownames <- seq_len(.nrow)
}
colnames <- c("(row)", colnames)
fields <- sprintf("x%d", seq_along(colnames))
.colnames <- c("(row)", .colnames)
fields <- sprintf("x%d", seq_along(.colnames))
data <- c(list(" " = rownames), .subset(data))
names(data) <- fields
class(data) <- "data.frame"
attr(data, "row.names") <- .set_row_names(.nrow)
columns <- .mapply(get_column_def,
list(colnames, fields, data),
list(.colnames, fields, data),
NULL
)
list(
Expand Down
1 change: 1 addition & 0 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ export async function getTableHtml(webview: Webview, file: string): Promise<stri
pagination: true,
enableCellTextSelection: true,
ensureDomOrder: true,
tooltipShowDelay: 100,
onGridReady: function (params) {
gridOptions.api.sizeColumnsToFit();
autoSizeAll(false);
Expand Down