@@ -57,7 +57,12 @@ class ClientErrorHandler implements ErrorHandler {
5757 if ( diff <= 3 * 60 * 1000 ) {
5858 const message = `The ${ this . name } server crashed 5 times in the last 3 minutes. The server will not be restarted.` ;
5959 logger . error ( message ) ;
60- window . showErrorMessage ( message ) ;
60+ const action = "Show logs" ;
61+ window . showErrorMessage ( message , action ) . then ( selection => {
62+ if ( selection === action ) {
63+ commands . executeCommand ( Commands . OPEN_LOGS ) ;
64+ }
65+ } ) ;
6166 return CloseAction . DoNotRestart ;
6267 }
6368
@@ -376,9 +381,11 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
376381
377382 context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_OUTPUT , ( ) => languageClient . outputChannel . show ( ViewColumn . Three ) ) ) ;
378383
379- context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_SERVER_LOG , ( ) => openServerLogFile ( workspacePath ) ) ) ;
384+ context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_SERVER_LOG , ( column : ViewColumn ) => openServerLogFile ( workspacePath , column ) ) ) ;
380385
381- context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_CLIENT_LOG , ( ) => openClientLogFile ( clientLogFile ) ) ) ;
386+ context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_CLIENT_LOG , ( column : ViewColumn ) => openClientLogFile ( clientLogFile , column ) ) ) ;
387+
388+ context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_LOGS , ( ) => openLogs ( ) ) ) ;
382389
383390 const extensionPath = context . extensionPath ;
384391 context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_FORMATTER , async ( ) => openFormatter ( extensionPath ) ) ) ;
@@ -538,12 +545,12 @@ function deleteDirectory(dir) {
538545 }
539546}
540547
541- function openServerLogFile ( workspacePath ) : Thenable < boolean > {
548+ function openServerLogFile ( workspacePath , column : ViewColumn = ViewColumn . Active ) : Thenable < boolean > {
542549 const serverLogFile = path . join ( workspacePath , '.metadata' , '.log' ) ;
543- return openLogFile ( serverLogFile , 'Could not open Java Language Server log file' ) ;
550+ return openLogFile ( serverLogFile , 'Could not open Java Language Server log file' , column ) ;
544551}
545552
546- function openClientLogFile ( logFile : string ) : Thenable < boolean > {
553+ function openClientLogFile ( logFile : string , column : ViewColumn = ViewColumn . Active ) : Thenable < boolean > {
547554 return new Promise ( ( resolve ) => {
548555 const filename = path . basename ( logFile ) ;
549556 const dirname = path . dirname ( logFile ) ;
@@ -555,12 +562,17 @@ function openClientLogFile(logFile: string): Thenable<boolean> {
555562 logFile = path . join ( dirname , files [ files . length - 1 ] ) ;
556563 }
557564
558- openLogFile ( logFile , 'Could not open Java extension log file' ) . then ( ( result ) => resolve ( result ) ) ;
565+ openLogFile ( logFile , 'Could not open Java extension log file' , column ) . then ( ( result ) => resolve ( result ) ) ;
559566 } ) ;
560567 } ) ;
561568}
562569
563- function openLogFile ( logFile , openingFailureWarning : string ) : Thenable < boolean > {
570+ async function openLogs ( ) {
571+ await commands . executeCommand ( Commands . OPEN_CLIENT_LOG , ViewColumn . One ) ;
572+ await commands . executeCommand ( Commands . OPEN_SERVER_LOG , ViewColumn . Two ) ;
573+ }
574+
575+ function openLogFile ( logFile , openingFailureWarning : string , column : ViewColumn = ViewColumn . Active ) : Thenable < boolean > {
564576 if ( ! fs . existsSync ( logFile ) ) {
565577 return window . showWarningMessage ( 'No log file available' ) . then ( ( ) => false ) ;
566578 }
@@ -570,8 +582,7 @@ function openLogFile(logFile, openingFailureWarning: string): Thenable<boolean>
570582 if ( ! doc ) {
571583 return false ;
572584 }
573- return window . showTextDocument ( doc , window . activeTextEditor ?
574- window . activeTextEditor . viewColumn : undefined )
585+ return window . showTextDocument ( doc , column )
575586 . then ( editor => ! ! editor ) ;
576587 } , ( ) => false )
577588 . then ( didOpen => {
0 commit comments