Skip to content

Commit ac4729b

Browse files
Hasim KaramanHasim Karaman
authored andcommitted
- added screenshot dir setting
1 parent 22c4d8d commit ac4729b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,6 +2688,11 @@
26882688
"description": "File where the 'BrightScript Extension' output panel (i.e. debug logs for the extension) will be appended. If omitted, no file logging will be done. ${workspaceFolder} is supported and will point to the first workspace found.",
26892689
"scope": "resource"
26902690
}
2691+
},
2692+
"brightscript.screenshotDir": {
2693+
"type": "string",
2694+
"description": "Directory path where screenshots will be saved. If omitted, screenshots will be saved to the OS's temporary directory. Relative paths (e.g., \"debug/screenshots\") are resolved relative to the workspace folder. ${workspaceFolder} is also supported and will point to the first workspace found.",
2695+
"scope": "resource"
26912696
}
26922697
}
26932698
],

src/commands/CaptureScreenshotCommand.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from 'vscode';
2+
import * as path from 'path';
23
import * as rokuDeploy from 'roku-deploy';
34
import type { BrightScriptCommands } from '../BrightScriptCommands';
45

@@ -35,9 +36,25 @@ export class CaptureScreenshotCommand {
3536
location: vscode.ProgressLocation.Notification
3637
}, async () => {
3738
try {
39+
let screenshotDir = vscode.workspace.getConfiguration('brightscript').get<string>('screenshotDir');
40+
if (screenshotDir) {
41+
let workspacePath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
42+
if (vscode.workspace.workspaceFolders?.length > 1) {
43+
const workspaceFolder = await vscode.window.showWorkspaceFolderPick();
44+
if (workspaceFolder) {
45+
workspacePath = workspaceFolder.uri.fsPath;
46+
}
47+
}
48+
49+
screenshotDir = screenshotDir.replace("${workspaceFolder}", workspacePath);
50+
screenshotDir = path.resolve(workspacePath ?? process.cwd(), screenshotDir);
51+
}
52+
53+
3854
let screenshotPath = await rokuDeploy.takeScreenshot({
3955
host: host,
40-
password: password
56+
password: password,
57+
...(screenshotDir && { outDir: screenshotDir })
4158
});
4259
if (screenshotPath) {
4360
void vscode.window.showInformationMessage(`Screenshot saved at: ` + screenshotPath);

0 commit comments

Comments
 (0)