@@ -101,7 +101,14 @@ export class ComponentsPacksWebviewMain {
101101 await this . webviewManager . activate ( context ) ;
102102 }
103103
104- private async dispose ( ) : Promise < void > {
104+ private dispose ( ) : void {
105+ this . disposeInternal ( ) . catch ( ( error ) => {
106+ // Ensure any errors during dispose do not become unhandled promise rejections.
107+ console . error ( 'Error during ComponentsPacksWebviewMain.dispose:' , error ) ;
108+ } ) ;
109+ }
110+
111+ private async disposeInternal ( ) : Promise < void > {
105112 const discardView = ( ) => {
106113 this . currentProject = undefined ;
107114 this . componentTree = { success : false , classes : [ ] } ;
@@ -114,7 +121,9 @@ export class ComponentsPacksWebviewMain {
114121 this . scope = ComponentScope . Solution ;
115122 } ;
116123
117- if ( await this . isDirty ( ) ) {
124+ const hasBaseline = this . usedItems !== undefined ;
125+
126+ if ( hasBaseline && await this . isDirty ( ) ) {
118127 const buttonOptions = [
119128 { title : 'Save' } ,
120129 { title : 'Don\'t Save' } ,
@@ -343,7 +352,11 @@ export class ComponentsPacksWebviewMain {
343352 }
344353 await this . webviewManager . sendMessage ( { type : 'SET_UNLINKREQUESTS_STACK' , unlinkRequests : Array . from ( this . unlinkRequests ) } ) ;
345354 await this . sendSolutionData ( ) ;
346- await this . sendDirtyState ( ) ;
355+ if ( reload ) {
356+ await this . sendDirtyState ( ) ;
357+ } else {
358+ await this . sendDirtyState ( { skipApply : true } ) ;
359+ }
347360 } catch ( error ) {
348361 const messages = await this . csolutionService . getLogMessages ( ) ;
349362
0 commit comments