From 4d1ee0dd55c40fd4c8248c80528634b1283f7391 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Sun, 6 Feb 2022 10:17:40 +0000 Subject: [PATCH 1/3] refactoring: colnames -> .colnames --- R/session/vsc.R | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/R/session/vsc.R b/R/session/vsc.R index af1d25fed..a79a564de 100644 --- a/R/session/vsc.R +++ b/R/session/vsc.R @@ -348,11 +348,11 @@ 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) @@ -360,14 +360,14 @@ if (show_view) { } 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( From 55cd32772be29ffc175d0df9dd60a4f98e987271 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Sun, 6 Feb 2022 10:59:10 +0000 Subject: [PATCH 2/3] add type of column to headerTooltip --- R/session/vsc.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/session/vsc.R b/R/session/vsc.R index a79a564de..525e69cf2 100644 --- a/R/session/vsc.R +++ b/R/session/vsc.R @@ -321,6 +321,7 @@ show_view <- !identical(getOption("vsc.view", "Two"), FALSE) if (show_view) { get_column_def <- function(name, field, value) { filter <- TRUE + tooltip <- typeof(value) if (is.numeric(value)) { type <- "numericColumn" if (is.null(attr(value, "class"))) { @@ -335,6 +336,7 @@ if (show_view) { } list( headerName = name, + headerTooltip = tooltip, field = field, type = type, filter = filter From 11fac90bc3323bac935fc0a0fbc35acbc12e7c4a Mon Sep 17 00:00:00 2001 From: Kun Ren Date: Sun, 6 Feb 2022 19:58:11 +0800 Subject: [PATCH 3/3] Update tooltip text and delay --- R/session/vsc.R | 6 +++++- src/session.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/R/session/vsc.R b/R/session/vsc.R index 525e69cf2..a6cd406e3 100644 --- a/R/session/vsc.R +++ b/R/session/vsc.R @@ -321,7 +321,11 @@ show_view <- !identical(getOption("vsc.view", "Two"), FALSE) if (show_view) { get_column_def <- function(name, field, value) { filter <- TRUE - tooltip <- typeof(value) + tooltip <- sprintf( + "class: [%s], type: %s", + toString(class(value)), + typeof(value) + ) if (is.numeric(value)) { type <- "numericColumn" if (is.null(attr(value, "class"))) { diff --git a/src/session.ts b/src/session.ts index b544a0e2c..3a5394253 100644 --- a/src/session.ts +++ b/src/session.ts @@ -497,6 +497,7 @@ export async function getTableHtml(webview: Webview, file: string): Promise