@@ -191,6 +191,7 @@ export class FileTreeRenderer extends DirListing.Renderer {
191191/**
192192 * A widget which hosts a filetree.
193193 */
194+ // @ts -ignore: _onPathChanged is private upstream, need to change this
194195export class DirTreeListing extends DirListing {
195196 constructor ( options : DirTreeListing . IOptions ) {
196197 super ( { ...options , renderer : new FileTreeRenderer ( options . model ) } ) ;
@@ -229,6 +230,11 @@ export class DirTreeListing extends DirListing {
229230 }
230231 }
231232
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+
232238 private _eventDragEnter ( event : IDragEvent ) : void {
233239 if ( event . mimeData . hasData ( CONTENTS_MIME ) ) {
234240 // @ts -ignore
@@ -428,16 +434,26 @@ export class FilterFileTreeBrowserModel extends FilterFileBrowserModel {
428434 }
429435
430436 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+ }
433442
434443 this . _path = value ;
435444
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+ }
441457 }
442458
443459 /**
@@ -665,6 +681,7 @@ export class FileTreeBrowser extends FileBrowser {
665681 }
666682
667683 protected createDirListing ( options : DirListing . IOptions ) : DirListing {
684+ // @ts -ignore: _onPathChanged is private upstream, need to change this
668685 return new DirTreeListing ( {
669686 model : this . model ,
670687 translator : this . translator
@@ -677,5 +694,6 @@ export class FileTreeBrowser extends FileBrowser {
677694
678695 model : FilterFileTreeBrowserModel ;
679696
697+ // @ts -ignore: _onPathChanged is private upstream, need to change this
680698 listing : DirTreeListing ;
681699}
0 commit comments