@@ -8,6 +8,29 @@ import { CONFIG_SECTION } from "./config";
88import { LanguageClientsManager , toVsCodeRange } from "./languageclientsmanger" ;
99import { WeakValueSet } from "./utils" ;
1010
11+ async function openPreviewOrExternal ( uri : vscode . Uri ) {
12+ let livePreviewResult = false ;
13+ try {
14+ const ex = vscode . extensions . getExtension ( "ms-vscode.live-server" ) ;
15+ if ( ex ) {
16+ await ex . activate ( ) ;
17+ if ( ( await vscode . commands . getCommands ( ) ) . includes ( "livePreview.start.preview.atFile" ) ) {
18+ await vscode . commands . executeCommand ( "livePreview.start.preview.atFile" , uri ) ;
19+ livePreviewResult = true ;
20+ }
21+ }
22+ } catch {
23+ livePreviewResult = false ;
24+ }
25+
26+ if ( ! livePreviewResult ) {
27+ vscode . env . openExternal ( uri ) . then (
28+ ( ) => undefined ,
29+ ( ) => undefined
30+ ) ;
31+ }
32+ }
33+
1134const DEBUG_ADAPTER_DEFAULT_TCP_PORT = 6611 ;
1235const DEBUG_ADAPTER_DEFAULT_HOST = "127.0.0.1" ;
1336
@@ -85,8 +108,6 @@ class RobotCodeDebugConfigurationProvider implements vscode.DebugConfigurationPr
85108 ( v ?. purpose === "default" || ( Array . isArray ( v ?. purpose ) && v ?. purpose ?. indexOf ( "default" ) > - 1 ) )
86109 ) ?? { } ;
87110
88- console . log ( defaultLaunchConfig ) ;
89-
90111 debugConfiguration = { ...template , ...defaultLaunchConfig , ...debugConfiguration } ;
91112
92113 try {
@@ -125,6 +146,9 @@ class RobotCodeDebugConfigurationProvider implements vscode.DebugConfigurationPr
125146 ...( debugConfiguration . env ?? { } ) ,
126147 } ;
127148
149+ debugConfiguration . openOutputAfterRun =
150+ debugConfiguration ?. openOutputAfterRun ?? config . get < string | undefined > ( "run.openOutputAfterRun" , undefined ) ;
151+
128152 debugConfiguration . outputDir =
129153 debugConfiguration ?. outputDir ?? config . get < string | undefined > ( "robot.outputDir" , undefined ) ;
130154
@@ -425,15 +449,13 @@ export class DebugManager {
425449 private static async OnRobotExited (
426450 session : vscode . DebugSession ,
427451 _outputFile ?: string ,
428- _logFile ?: string ,
452+ logFile ?: string ,
429453 reportFile ?: string
430454 ) : Promise < void > {
431- if ( reportFile ) {
432- const config = vscode . workspace . getConfiguration ( CONFIG_SECTION , session . workspaceFolder ) ;
433-
434- if ( config . get < boolean > ( "run.openReportAfterRun" ) ) {
435- await vscode . env . openExternal ( vscode . Uri . file ( reportFile ) ) ;
436- }
455+ if ( session . configuration ?. openOutputAfterRun === "report" && reportFile ) {
456+ await openPreviewOrExternal ( vscode . Uri . file ( reportFile ) ) ;
457+ } else if ( session . configuration ?. openOutputAfterRun === "log" && logFile ) {
458+ await openPreviewOrExternal ( vscode . Uri . file ( logFile ) ) ;
437459 }
438460 }
439461}
0 commit comments