Skip to content

Commit 738d7a6

Browse files
committed
feat(vscode): add configuration for output file display options
Add "robotcode.run.openOutputTarget" setting to control how Robot Framework output files are displayed: - simpleBrowser: in VSCode's built-in browser - externalHttp: in default browser via HTTP protocol - externalFile: in default browser via file system The externalFile options may not run in remote development environments. Closes #391 Closes #227
1 parent a496714 commit 738d7a6

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

package.json

+17-1
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,22 @@
757757
"default": "none",
758758
"description": "Defines if the report or log file should be opened after a run.",
759759
"scope": "resource"
760+
},
761+
"robotcode.run.openOutputTarget": {
762+
"type": "string",
763+
"enum": [
764+
"simpleBrowser",
765+
"externalHttp",
766+
"externalFile"
767+
],
768+
"enumDescriptions": [
769+
"Display the output file in a simple VSCode browser window.",
770+
"Display the output file in your default web browser via HTTP.",
771+
"Display the output file in your default browser via the file system."
772+
],
773+
"default": "simpleBrowser",
774+
"description": "Specifies how Robot Framework output files should be displayed when opened.",
775+
"scope": "resource"
760776
}
761777
}
762778
},
@@ -1943,4 +1959,4 @@
19431959
"workspaces": [
19441960
"docs"
19451961
]
1946-
}
1962+
}

vscode-client/extension/debugmanager.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,11 @@ export class DebugManager {
612612
logFile?: string,
613613
reportFile?: string,
614614
): Promise<void> {
615-
if (session.configuration?.openOutputAfterRun === "report" && reportFile) {
616-
await this.languageClientsManager.openUriInDocumentationView(vscode.Uri.file(reportFile));
617-
} else if (session.configuration?.openOutputAfterRun === "log" && logFile) {
618-
await this.languageClientsManager.openUriInDocumentationView(vscode.Uri.file(logFile));
615+
const openMode = session.configuration?.openOutputAfterRun as string;
616+
const fileToOpen = openMode === "report" ? reportFile : openMode === "log" ? logFile : undefined;
617+
618+
if (fileToOpen) {
619+
await this.languageClientsManager.openOutputFile(vscode.Uri.file(fileToOpen));
619620
}
620621
}
621622
}

vscode-client/extension/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export async function activateAsync(context: vscode.ExtensionContext): Promise<v
116116
return [];
117117
},
118118
async handleTerminalLink(link: TerminalLink) {
119-
await languageClientManger.openUriInDocumentationView(vscode.Uri.file(link.path));
119+
await languageClientManger.openOutputFile(vscode.Uri.file(link.path));
120120
},
121121
}),
122122

vscode-client/extension/languageclientsmanger.ts

+19
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,25 @@ export class LanguageClientsManager {
794794
}
795795
}
796796

797+
public async openOutputFile(file: vscode.Uri): Promise<void> {
798+
const workspace = vscode.workspace.getWorkspaceFolder(file);
799+
const result = vscode.workspace.getConfiguration(CONFIG_SECTION, workspace).get<string>("run.openOutputTarget");
800+
801+
switch (result) {
802+
case "simpleBrowser":
803+
await this.openUriInDocumentationView(file);
804+
break;
805+
case "externalHttp":
806+
await vscode.env.openExternal(
807+
await vscode.env.asExternalUri((await this.convertToDocumentationUri(file)) ?? file),
808+
);
809+
break;
810+
case "externalFile":
811+
await vscode.env.openExternal(file);
812+
break;
813+
}
814+
}
815+
797816
public async convertToDocumentationUri(
798817
uri: vscode.Uri,
799818
token?: vscode.CancellationToken | undefined,

0 commit comments

Comments
 (0)