Skip to content

Commit 332d36e

Browse files
authored
Remove show plot history command (#706)
* Remove show plot history command * Remove from webpack config * Remove command
1 parent e7101d9 commit 332d36e

File tree

6 files changed

+1
-91
lines changed

6 files changed

+1
-91
lines changed

R/vsc.R

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,10 @@ if (use_httpgd && "httpgd" %in% .packages(all.available = TRUE)) {
176176
} else if (use_httpgd) {
177177
message("Install package `httpgd` to use vscode-R with httpgd!")
178178
} else if (show_plot) {
179-
dir_plot_history <- file.path(dir_session, "images")
180-
dir.create(dir_plot_history, showWarnings = FALSE, recursive = TRUE)
181179
plot_file <- file.path(dir_session, "plot.png")
182180
plot_lock_file <- file.path(dir_session, "plot.lock")
183181
file.create(plot_file, plot_lock_file, showWarnings = FALSE)
184182

185-
plot_history_file <- NULL
186183
plot_updated <- FALSE
187184
null_dev_id <- c(pdf = 2L)
188185
null_dev_size <- c(7 + pi, 7 + pi)
@@ -194,8 +191,6 @@ if (use_httpgd && "httpgd" %in% .packages(all.available = TRUE)) {
194191

195192
new_plot <- function() {
196193
if (check_null_dev()) {
197-
plot_history_file <<- file.path(dir_plot_history,
198-
format(Sys.time(), "%Y%m%d-%H%M%OS6.png"))
199194
plot_updated <<- TRUE
200195
}
201196
}
@@ -221,9 +216,6 @@ if (use_httpgd && "httpgd" %in% .packages(all.available = TRUE)) {
221216
on.exit({
222217
dev.off()
223218
cat(get_timestamp(), file = plot_lock_file)
224-
if (!is.null(plot_history_file)) {
225-
file.copy(plot_file, plot_history_file, overwrite = TRUE)
226-
}
227219
})
228220
replayPlot(record)
229221
}

package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,6 @@
441441
"category": "R",
442442
"command": "r.attachActive"
443443
},
444-
{
445-
"title": "Show Plot History",
446-
"category": "R",
447-
"command": "r.showPlotHistory"
448-
},
449444
{
450445
"title": "Run Command With Selection or Word in Terminal",
451446
"category": "R",
@@ -1430,7 +1425,6 @@
14301425
"datatables.net-bs4": "^1.10.25",
14311426
"datatables.net-fixedheader-jqui": "^3.1.9",
14321427
"ejs": "^3.1.6",
1433-
"fotorama": "^4.6.4",
14341428
"fs-extra": "^10.0.0",
14351429
"highlight.js": "^10.7.2",
14361430
"jquery": "^3.6.0",

src/extension.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<apiImp
105105
'r.previewDataframe': preview.previewDataframe,
106106
'r.previewEnvironment': preview.previewEnvironment,
107107
'r.attachActive': session.attachActive,
108-
'r.showPlotHistory': session.showPlotHistory,
109108
'r.launchAddinPicker': rstudioapi.launchAddinPicker,
110109

111110
// workspace viewer

src/session.ts

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ let plotView: string;
3333
let plotFile: string;
3434
let plotLockFile: string;
3535
let plotTimeStamp: number;
36-
let plotDir: string;
3736
let globalEnvWatcher: FSWatcher;
3837
let plotWatcher: FSWatcher;
3938
let activeBrowserPanel: WebviewPanel;
@@ -440,68 +439,6 @@ export async function getListHtml(webview: Webview, file: string): Promise<strin
440439
`;
441440
}
442441

443-
export async function showPlotHistory(): Promise<void> {
444-
if (config().get<boolean>('sessionWatcher')) {
445-
if (plotDir === undefined) {
446-
void window.showErrorMessage('No session is attached.');
447-
} else {
448-
const files = await fs.readdir(plotDir);
449-
if (files.length > 0) {
450-
const panel = window.createWebviewPanel('plotHistory', 'Plot History',
451-
{
452-
preserveFocus: true,
453-
viewColumn: ViewColumn.Active,
454-
},
455-
{
456-
retainContextWhenHidden: true,
457-
enableScripts: true,
458-
localResourceRoots: [Uri.file(resDir), Uri.file(plotDir)],
459-
});
460-
const html = getPlotHistoryHtml(panel.webview, files);
461-
panel.webview.html = html;
462-
} else {
463-
void window.showInformationMessage('There is no plot to show yet.');
464-
}
465-
}
466-
} else {
467-
void window.showInformationMessage('This command requires that r.sessionWatcher be enabled.');
468-
}
469-
}
470-
471-
function getPlotHistoryHtml(webview: Webview, files: string[]) {
472-
const imgs = files
473-
.map((file) => `<img src="${String(webview.asWebviewUri(Uri.file(path.join(plotDir, file))))}" />`)
474-
.join('\n');
475-
476-
return `
477-
<!doctype HTML>
478-
<html>
479-
<head>
480-
<meta charset="utf-8" />
481-
<meta name="viewport" content="width=device-width, initial-scale=1">
482-
<link href="${String(webview.asWebviewUri(Uri.file(path.join(resDir, 'bootstrap.min.css'))))}" rel="stylesheet">
483-
<link href="${String(webview.asWebviewUri(Uri.file(path.join(resDir, 'fotorama.css'))))}" rel="stylesheet">
484-
<style type="text/css">
485-
body {
486-
background-color: white;
487-
}
488-
</style>
489-
</head>
490-
<body>
491-
<div class="container">
492-
<div class="text-center">
493-
<div class="fotorama" data-width="100%" data-maxheight="100%" data-nav="thumbs" data-keyboard="true">
494-
${imgs}
495-
</div>
496-
</div>
497-
</div>
498-
<script src="${String(webview.asWebviewUri(Uri.file(path.join(resDir, 'jquery.min.js'))))}"></script>
499-
<script src="${String(webview.asWebviewUri(Uri.file(path.join(resDir, 'fotorama.js'))))}"></script>
500-
</body>
501-
</html>
502-
`;
503-
}
504-
505442
function isFromWorkspace(dir: string) {
506443
if (workspace.workspaceFolders === undefined) {
507444
const rel = path.relative(os.homedir(), dir);
@@ -572,7 +509,6 @@ async function updateRequest(sessionStatusBarItem: StatusBarItem) {
572509
pid = String(request.pid);
573510
sessionDir = path.join(request.tempdir, 'vscode-R');
574511
workingDir = request.wd;
575-
plotDir = path.join(sessionDir, 'images');
576512
plotView = String(request.plot);
577513
console.info(`[updateRequest] attach PID: ${pid}`);
578514
sessionStatusBarItem.text = `R: ${pid}`;

webpack.config.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ module.exports = {
5050
{ from: './node_modules/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js', to: 'resources' },
5151
{ from: './node_modules/datatables.net-fixedheader-jqui/js/fixedHeader.jqueryui.min.js', to: 'resources' },
5252
{ from: './node_modules/datatables.net-fixedheader-jqui/css/fixedHeader.jqueryui.min.css', to: 'resources' },
53-
{ from: './node_modules/fotorama/fotorama.js', to: 'resources' },
54-
{ from: './node_modules/fotorama/fotorama.css', to: 'resources' },
55-
{ from: './node_modules/fotorama/fotorama.png', to: 'resources' },
56-
{ from: './node_modules/fotorama/[email protected]', to: 'resources' },
5753
]
5854
}),
5955
],

yarn.lock

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,13 +1405,6 @@ form-data@^3.0.0:
14051405
combined-stream "^1.0.8"
14061406
mime-types "^2.1.12"
14071407

1408-
fotorama@^4.6.4:
1409-
version "4.6.4"
1410-
resolved "https://registry.yarnpkg.com/fotorama/-/fotorama-4.6.4.tgz#7376961b6c7eeccb6c76411aceba7795ffe22eae"
1411-
integrity sha1-c3aWG2x+7MtsdkEazrp3lf/iLq4=
1412-
dependencies:
1413-
jquery ">=1.8"
1414-
14151408
fs-extra@^10.0.0:
14161409
version "10.0.0"
14171410
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.0.tgz#9ff61b655dde53fb34a82df84bb214ce802e17c1"
@@ -1753,7 +1746,7 @@ jquery.json-viewer@^1.4.0:
17531746
resolved "https://registry.yarnpkg.com/jquery.json-viewer/-/jquery.json-viewer-1.4.0.tgz#6e0ede8ae3239cb20ac359f663b9aae4ec8a9d94"
17541747
integrity sha512-6H1U/w+/8vMwDH5Im0OveuKPZ1fZWy7hgvR3Cn+HeamQIoWrVqBuRaE2TF/xEc6Hmi3vhQVRqZBmYGKTdOo2tw==
17551748

1756-
jquery@>=1.7, jquery@>=1.8, jquery@^3.6.0:
1749+
jquery@>=1.7, jquery@^3.6.0:
17571750
version "3.6.0"
17581751
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470"
17591752
integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==

0 commit comments

Comments
 (0)