@@ -26,13 +26,15 @@ export class LogView {
2626 static async createView (
2727 wsPath : string ,
2828 context : Context ,
29- logPath : string ,
3029 beforeSendLog ?: Promise < void > ,
30+ logPath ?: string ,
31+ logData ?: string ,
3132 ) : Promise < WebviewPanel > {
32- const panel = WebView . apply ( 'logFile' , 'Log: ' + basename ( logPath ) , [
33- Uri . file ( join ( context . context . extensionPath , 'out' ) ) ,
34- Uri . file ( dirname ( logPath ) ) ,
35- ] ) ;
33+ const panel = WebView . apply (
34+ 'logFile' ,
35+ 'Log: ' + logPath ? basename ( logPath || '' ) : 'Untitled' ,
36+ [ Uri . file ( join ( context . context . extensionPath , 'out' ) ) , Uri . file ( dirname ( logPath || '' ) ) ] ,
37+ ) ;
3638
3739 const logViewerRoot = join ( context . context . extensionPath , 'out' ) ;
3840 const index = join ( logViewerRoot , 'index.html' ) ;
@@ -55,7 +57,7 @@ export class LogView {
5557 switch ( request . cmd ) {
5658 case 'fetchLog' : {
5759 await beforeSendLog ;
58- LogView . sendLog ( panel , context , logPath ) ;
60+ LogView . sendLog ( panel , context , logPath , logData ) ;
5961 break ;
6062 }
6163
@@ -141,20 +143,26 @@ export class LogView {
141143 } ) ;
142144 }
143145
144- private static sendLog ( panel : WebviewPanel , context : Context , logFilePath : string ) {
145- if ( ! existsSync ( logFilePath ) ) {
146+ private static sendLog (
147+ panel : WebviewPanel ,
148+ context : Context ,
149+ logFilePath ?: string ,
150+ logData ?: string ,
151+ ) {
152+ if ( ! logData && ! existsSync ( logFilePath || '' ) ) {
146153 context . display . showErrorMessage ( 'Log file could not be found.' , {
147154 modal : true ,
148155 } ) ;
149156 }
150157
151- const filePath = parse ( logFilePath ) ;
158+ const filePath = parse ( logFilePath || '' ) ;
152159 panel . webview . postMessage ( {
153160 command : 'fetchLog' ,
154161 data : {
155162 logName : filePath . name ,
156- logUri : panel . webview . asWebviewUri ( Uri . file ( logFilePath ) ) . toString ( true ) ,
163+ logUri : logFilePath ? panel . webview . asWebviewUri ( Uri . file ( logFilePath ) ) . toString ( true ) : '' ,
157164 logPath : logFilePath ,
165+ logData : logData ,
158166 } ,
159167 } ) ;
160168 }
0 commit comments