@@ -35,8 +35,9 @@ let lspOutputChannel: OutputChannel;
3535function getBriocheBinaryPath ( ) : string {
3636 const configPath = workspace
3737 . getConfiguration ( "brioche" )
38- . get < string > ( "binaryPath" ) ;
39- return configPath && configPath . trim ( ) ? configPath . trim ( ) : "brioche" ;
38+ . get < string > ( "binaryPath" )
39+ ?. trim ( ) ;
40+ return configPath || "brioche" ;
4041}
4142
4243/**
@@ -67,22 +68,7 @@ function getBriocheLogLevel(): string | undefined {
6768 const logLevel =
6869 workspace . getConfiguration ( "brioche" ) . get < string > ( "log.level" ) || "off" ;
6970
70- switch ( logLevel ) {
71- case "off" :
72- return "brioche=off" ;
73- case "error" :
74- return "brioche=error" ;
75- case "warn" :
76- return "brioche=warn" ;
77- case "info" :
78- return "brioche=info" ;
79- case "debug" :
80- return "brioche=debug" ;
81- case "trace" :
82- return "brioche=trace" ;
83- default :
84- return undefined ;
85- }
71+ return `brioche=${ logLevel } ` ;
8672}
8773
8874async function startClient ( ) : Promise < void > {
@@ -98,17 +84,12 @@ async function startClient(): Promise<void> {
9884 const rustLogLevel = getBriocheLogLevel ( ) ;
9985
10086 // Build environment variables for LSP
101- let env = {
87+ const env = {
10288 ...process . env ,
89+ ...( rustLogLevel ? { RUST_LOG : rustLogLevel } : { } ) ,
90+ ...lspEnvVars ,
10391 } ;
10492
105- // Add RUST_LOG if specified
106- if ( rustLogLevel ) {
107- env [ "RUST_LOG" ] = rustLogLevel ;
108- }
109-
110- env = { ...env , ...lspEnvVars } ;
111-
11293 // Configure server options
11394 const serverOptions : ServerOptions = {
11495 command : briochePath ,
@@ -288,13 +269,12 @@ async function runBriocheBuild(): Promise<void> {
288269 process . stdout ?. on ( "data" , ( data : Buffer ) => {
289270 const output = data . toString ( ) ;
290271 outputChannel . append ( output ) ;
291- outputChannel . show ( true ) ; // Force the output channel to remain visible
292272 progress . report ( { message : "Building project..." } ) ;
293273 } ) ;
294274
295275 process . stderr ?. on ( "data" , ( data : Buffer ) => {
296276 outputChannel . append ( data . toString ( ) ) ;
297- outputChannel . show ( true ) ; // Show output immediately for errors
277+ progress . report ( { message : "Building project..." } ) ;
298278 } ) ;
299279
300280 token . onCancellationRequested ( ( ) => {
@@ -304,15 +284,39 @@ async function runBriocheBuild(): Promise<void> {
304284 } ) ;
305285
306286 process . on ( "close" , ( code : number | null ) => {
287+ const showOutputButton = "Show output" ;
288+
307289 if ( code === 0 ) {
308290 outputChannel . appendLine ( "\nBuild completed successfully!" ) ;
309- window . showInformationMessage ( "Build completed successfully!" ) ;
291+ window . showInformationMessage ( "Build completed successfully!" , showOutputButton ) . then ( ( item ) => {
292+ // Show the output if the user clicks "Show output"
293+ if ( item === showOutputButton ) {
294+ outputChannel . show ( true ) ;
295+ }
296+ } ) ;
297+ resolve ( ) ;
298+ } else if ( code != null ) {
299+ const message = `Build failed with exit code ${ code } ` ;
300+ outputChannel . appendLine ( `\n${ message } ` ) ;
301+
302+ window . showErrorMessage ( message , showOutputButton ) . then ( ( item ) => {
303+ // Show the output if the user clicks "Show output"
304+ if ( item === showOutputButton ) {
305+ outputChannel . show ( true ) ;
306+ }
307+ } ) ;
310308 resolve ( ) ;
311309 } else {
312- const message = ` Build failed with code ${ code } ` ;
310+ const message = " Build stopped" ;
313311 outputChannel . appendLine ( `\n${ message } ` ) ;
314- window . showErrorMessage ( message ) ;
315- reject ( new Error ( message ) ) ;
312+
313+ window . showErrorMessage ( message , showOutputButton ) . then ( ( item ) => {
314+ // Show the output if the user clicks "Show output"
315+ if ( item === showOutputButton ) {
316+ outputChannel . show ( true ) ;
317+ }
318+ } ) ;
319+ resolve ( ) ;
316320 }
317321 } ) ;
318322
0 commit comments