@@ -191,6 +191,7 @@ export class FileTreeRenderer extends DirListing.Renderer {
191
191
/**
192
192
* A widget which hosts a filetree.
193
193
*/
194
+ // @ts -ignore: _onPathChanged is private upstream, need to change this
194
195
export class DirTreeListing extends DirListing {
195
196
constructor ( options : DirTreeListing . IOptions ) {
196
197
super ( { ...options , renderer : new FileTreeRenderer ( options . model ) } ) ;
@@ -229,6 +230,11 @@ export class DirTreeListing extends DirListing {
229
230
}
230
231
}
231
232
233
+ _onPathChanged ( ) : void {
234
+ // It's a no-op to overwrite the base class behavior
235
+ // We don't want to deselect everything when the path changes
236
+ }
237
+
232
238
private _eventDragEnter ( event : IDragEvent ) : void {
233
239
if ( event . mimeData . hasData ( CONTENTS_MIME ) ) {
234
240
// @ts -ignore
@@ -428,16 +434,26 @@ export class FilterFileTreeBrowserModel extends FilterFileBrowserModel {
428
434
}
429
435
430
436
set path ( value : string ) {
431
- const pathChanged = this . pathChanged as Signal < this, IChangedArgs < string > > ;
432
- const oldValue = this . _path ;
437
+ let needsToEmit = false ;
438
+
439
+ if ( this . _path !== value ) {
440
+ needsToEmit = true ;
441
+ }
433
442
434
443
this . _path = value ;
435
444
436
- pathChanged . emit ( {
437
- name : 'path' ,
438
- oldValue,
439
- newValue : value
440
- } ) ;
445
+ if ( needsToEmit ) {
446
+ const pathChanged = this . pathChanged as Signal <
447
+ this,
448
+ IChangedArgs < string >
449
+ > ;
450
+
451
+ pathChanged . emit ( {
452
+ name : 'path' ,
453
+ oldValue : this . _path ,
454
+ newValue : PathExt . dirname ( this . _path )
455
+ } ) ;
456
+ }
441
457
}
442
458
443
459
/**
@@ -665,6 +681,7 @@ export class FileTreeBrowser extends FileBrowser {
665
681
}
666
682
667
683
protected createDirListing ( options : DirListing . IOptions ) : DirListing {
684
+ // @ts -ignore: _onPathChanged is private upstream, need to change this
668
685
return new DirTreeListing ( {
669
686
model : this . model ,
670
687
translator : this . translator
@@ -677,5 +694,6 @@ export class FileTreeBrowser extends FileBrowser {
677
694
678
695
model : FilterFileTreeBrowserModel ;
679
696
697
+ // @ts -ignore: _onPathChanged is private upstream, need to change this
680
698
listing : DirTreeListing ;
681
699
}
0 commit comments