@@ -116,11 +116,6 @@ const diffableProps: { [K in keyof ITestItem]?: (a: ITestItem[K], b: ITestItem[K
116
116
description : strictEqualComparator ,
117
117
error : strictEqualComparator ,
118
118
sortText : strictEqualComparator ,
119
- uri : ( a , b ) => {
120
- if ( a === b ) { return true ; }
121
- if ( ! a || ! b ) { return false ; }
122
- return a . toString ( ) === b . toString ( ) ;
123
- } ,
124
119
tags : ( a , b ) => {
125
120
if ( a . length !== b . length ) {
126
121
return false ;
@@ -134,9 +129,11 @@ const diffableProps: { [K in keyof ITestItem]?: (a: ITestItem[K], b: ITestItem[K
134
129
} ,
135
130
} ;
136
131
132
+ const diffableEntries = Object . entries ( diffableProps ) as readonly [ keyof ITestItem , ( a : any , b : any ) => boolean ] [ ] ;
133
+
137
134
const diffTestItems = ( a : ITestItem , b : ITestItem ) => {
138
135
let output : Record < string , unknown > | undefined ;
139
- for ( const [ key , cmp ] of Object . entries ( diffableProps ) as [ keyof ITestItem , ( a : any , b : any ) => boolean ] [ ] ) {
136
+ for ( const [ key , cmp ] of diffableEntries ) {
140
137
if ( ! cmp ( a [ key ] , b [ key ] ) ) {
141
138
if ( output ) {
142
139
output [ key ] = b [ key ] ;
@@ -340,7 +337,7 @@ export class TestItemCollection<T extends ITestItemLike> extends Disposable {
340
337
}
341
338
}
342
339
343
- private upsertItem ( actual : T , parent : CollectionItem < T > | undefined ) {
340
+ private upsertItem ( actual : T , parent : CollectionItem < T > | undefined ) : void {
344
341
const fullId = TestId . fromExtHostTestItem ( actual , this . root . id , parent ?. actual ) ;
345
342
346
343
// If this test item exists elsewhere in the tree already (exists at an
@@ -383,6 +380,12 @@ export class TestItemCollection<T extends ITestItemLike> extends Disposable {
383
380
}
384
381
385
382
// Case 3: upsert of an existing item by ID, with a new instance
383
+ if ( internal . actual . uri ?. toString ( ) !== actual . uri ?. toString ( ) ) {
384
+ // If the item has a new URI, re-insert it; we don't support updating
385
+ // URIs on existing test items.
386
+ this . removeItem ( fullId . toString ( ) ) ;
387
+ return this . upsertItem ( actual , parent ) ;
388
+ }
386
389
const oldChildren = this . options . getChildren ( internal . actual ) ;
387
390
const oldActual = internal . actual ;
388
391
const update = diffTestItems ( this . options . toITestItem ( oldActual ) , this . options . toITestItem ( actual ) ) ;
0 commit comments