@@ -154,43 +154,24 @@ export class SolutionProblemsImpl implements SolutionProblems {
154154 }
155155
156156 private async handleConvertCompleted ( data : ConvertResultData ) : Promise < void > {
157- await enrichLogMessagesFromToolOutput ( data . logMessages , data . toolsOutputMessages ) ;
158- await this . updateDiagnostics ( data . logMessages ) ;
157+ // Intentionally clear only on convert: convert is the canonical refresh point.
158+ // cbuild follows convert and should add diagnostics without wiping convert findings.
159+ this . clearDiagnostics ( ) ;
160+ await this . enrichAndUpdateDiagnostics ( data . logMessages , data . toolsOutputMessages ) ;
159161 }
160162
161163 private async handleCbuildCompleted ( data : CbuildResultData ) : Promise < void > {
162- // Enrich diagnostics with cbuild-specific output messages
164+ // Do not clear diagnostics here. cbuild diagnostics are additive after convert.
165+ // This preserves existing convert diagnostics and avoids churn from redundant clears.
163166 const logMessages : LogMessages = { success : true , errors : [ ] , warnings : [ ] , info : [ ] } ;
164- await enrichLogMessagesFromToolOutput ( logMessages , data . toolsOutputMessages ) ;
165- // Merge cbuild errors/warnings into existing diagnostics
166- const csolution = this . solutionManager . getCsolution ( ) ;
167- if ( csolution && ( logMessages . errors ?. length || logMessages . warnings ?. length ) ) {
168- await this . mergeDiagnostics ( logMessages ) ;
169- }
167+ await this . enrichAndUpdateDiagnostics ( logMessages , data . toolsOutputMessages ) ;
170168 }
171169
172- private async mergeDiagnostics ( logMessages : LogMessages ) : Promise < void > {
173- const existingDiagnostics = new Map < string , { uri : vscode . Uri ; diagnostics : vscode . Diagnostic [ ] } > ( ) ;
174- this . diagnosticCollection . forEach ( ( uri , diagnostics ) => {
175- existingDiagnostics . set ( uri . toString ( ) , { uri, diagnostics : [ ...diagnostics ] } ) ;
176- } ) ;
177-
170+ private async enrichAndUpdateDiagnostics ( logMessages : LogMessages , toolsOutputMessages ?: string [ ] ) : Promise < void > {
171+ await enrichLogMessagesFromToolOutput ( logMessages , toolsOutputMessages ) ;
178172 await this . updateDiagnostics ( logMessages ) ;
179-
180- const mergedDiagnostics = new Map < string , { uri : vscode . Uri ; diagnostics : vscode . Diagnostic [ ] } > ( existingDiagnostics ) ;
181- this . diagnosticCollection . forEach ( ( uri , diagnostics ) => {
182- const key = uri . toString ( ) ;
183- const existing = mergedDiagnostics . get ( key ) ;
184- mergedDiagnostics . set ( key , {
185- uri,
186- diagnostics : existing ? [ ...existing . diagnostics , ...diagnostics ] : [ ...diagnostics ] ,
187- } ) ;
188- } ) ;
189-
190- this . diagnosticCollection . set (
191- Array . from ( mergedDiagnostics . values ( ) , ( { uri, diagnostics } ) => [ uri , diagnostics ] as [ vscode . Uri , vscode . Diagnostic [ ] ] ) ,
192- ) ;
193173 }
174+
194175 private handleLoadStateChanged ( data : SolutionLoadStateChangeEvent ) : void {
195176 if ( data . previousState . solutionPath !== data . newState . solutionPath ) {
196177 this . clearDiagnostics ( ) ;
@@ -269,8 +250,8 @@ export class SolutionProblemsImpl implements SolutionProblems {
269250 }
270251
271252 private async updateDiagnostics ( messages : LogMessages ) : Promise < void > {
272- // clear previous diagnostics
273- this . clearDiagnostics ( ) ;
253+ // Diagnostics lifecycle is controlled by event handlers.
254+ // handleConvertCompleted clears; handleCbuildCompleted appends.
274255 let diagnostics = false ;
275256
276257 // iterate through log messages and set diagnostics
0 commit comments