MCPcopy Index your code
hub / github.com/REditorSupport/vscode-R / previewEnvironment

Function previewEnvironment

src/preview.ts:10–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import { config, checkForSpecialCharacters, checkIfFileExists, delay, createTempDir, getCurrentWorkspaceFolder } from './util';
9
10export async function previewEnvironment(): Promise<void> {
11 if (config().get('sessionWatcher')) {
12 await runTextInTerm('View(globalenv())');
13 } else {
14 if (!checkcsv()) {
15 return;
16 }
17 const currentWorkspaceFolder = getCurrentWorkspaceFolder()?.uri.fsPath;
18 if (!currentWorkspaceFolder) {
19 return;
20 }
21 const tmpDir = createTempDir(currentWorkspaceFolder, true);
22 const pathToTmpCsv = `${tmpDir}/environment.csv`;
23 const envName = 'name=ls()';
24 const envClass = 'class=sapply(ls(), function(x) {class(get(x, envir = parent.env(environment())))[1]})';
25 const envOut = 'out=sapply(ls(), function(x) {capture.output(str(get(x, envir = parent.env(environment()))), silent = T)[1]})';
26 const rWriteCsvCommand = 'write.csv(data.frame('
27 + `${envName},`
28 + `${envClass},`
29 + `${envOut}), '`
30 + `${pathToTmpCsv}', row.names=FALSE, quote = TRUE)`;
31 await runTextInTerm(rWriteCsvCommand);
32 await openTmpCSV(pathToTmpCsv, tmpDir);
33 }
34}
35
36export async function previewDataframe(): Promise<boolean | undefined> {
37 if (config().get('sessionWatcher')) {

Callers

nothing calls this directly

Calls 7

configFunction · 0.90
runTextInTermFunction · 0.90
createTempDirFunction · 0.90
checkcsvFunction · 0.85
openTmpCSVFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected