File tree Expand file tree Collapse file tree 4 files changed +38
-6
lines changed Expand file tree Collapse file tree 4 files changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -96,8 +96,6 @@ export class Repository extends DeferredDisposable {
9696 this . treeDataChanged . fire ( )
9797 this . sourceControlManagement . setState ( sourceControlManagementState )
9898 this . scmDecorationProvider . setState ( scmDecorationState )
99- if ( errorDecorationState ) {
100- this . errorDecorationProvider . setState ( errorDecorationState )
101- }
99+ this . errorDecorationProvider . setState ( errorDecorationState )
102100 }
103101}
Original file line number Diff line number Diff line change 11import { EventEmitter , FileDecoration , Uri } from 'vscode'
22import { DecoratableTreeItemScheme , getDecoratableUri } from '../../tree'
33import { ErrorDecorationProvider } from '../../tree/errorDecorationProvider'
4+ import { uniqueValues } from '../../util/array'
45
56export class DecorationProvider extends ErrorDecorationProvider {
67 private errors = new Set < string > ( )
@@ -15,10 +16,10 @@ export class DecorationProvider extends ErrorDecorationProvider {
1516 }
1617 }
1718
18- public setState ( errors : Set < string > ) {
19+ public setState ( errors : Set < string > = new Set ( ) ) {
1920 const urisToUpdate : Uri [ ] = [ ]
2021
21- for ( const label of errors ) {
22+ for ( const label of uniqueValues ( [ ... errors , ... this . errors ] ) ) {
2223 urisToUpdate . push ( getDecoratableUri ( label , this . scheme ) )
2324 }
2425 this . errors = errors
Original file line number Diff line number Diff line change @@ -231,5 +231,34 @@ describe('RepositoryModel', () => {
231231 untracked : [ ]
232232 } )
233233 } )
234+
235+ it ( 'should clear an error when there is no data in the tree and the error is fixed' , ( ) => {
236+ const emptyRepoData = {
237+ dataStatus : { } ,
238+ hasGitChanges : true ,
239+ untracked : new Set < string > ( )
240+ }
241+
242+ const msg = "'./dvc.yaml' validation failed.\n\nwith some other text"
243+
244+ const error = {
245+ msg,
246+ type : 'caught error'
247+ }
248+
249+ const emptyRepoError = { ...emptyRepoData , dataStatus : { error } }
250+ const model = new RepositoryModel ( dvcDemoPath )
251+
252+ model . transformAndSet ( emptyRepoData )
253+ expect ( model . getChildren ( dvcDemoPath ) ) . toStrictEqual ( [ ] )
254+
255+ model . transformAndSet ( emptyRepoError )
256+ expect ( model . getChildren ( dvcDemoPath ) ) . toStrictEqual ( [
257+ { error : { label : './dvc.yaml validation failed.' , msg } }
258+ ] )
259+
260+ model . transformAndSet ( emptyRepoData )
261+ expect ( model . getChildren ( dvcDemoPath ) ) . toStrictEqual ( [ ] )
262+ } )
234263 } )
235264} )
Original file line number Diff line number Diff line change @@ -87,7 +87,11 @@ export class RepositoryModel extends Disposable {
8787 }
8888
8989 private collectTree ( tracked : Set < string > ) : void {
90- if ( ! sameContents ( [ ...tracked ] , [ ...this . getTracked ( ) ] ) ) {
90+ const errorNeedsCleared = this . tree . get ( this . dvcRoot ) ?. [ 0 ] ?. error
91+ if (
92+ errorNeedsCleared ||
93+ ! sameContents ( [ ...tracked ] , [ ...this . getTracked ( ) ] )
94+ ) {
9195 this . tracked = tracked
9296 this . tree = collectTree ( this . dvcRoot , this . tracked )
9397 }
You can’t perform that action at this time.
0 commit comments