@@ -28,7 +28,7 @@ import { URI } from 'vs/base/common/uri';
2828import { dirname , basename } from 'vs/base/common/resources' ;
2929import { LIGHT , FileThemeIcon , FolderThemeIcon , registerThemingParticipant } from 'vs/platform/theme/common/themeService' ;
3030import { FileKind } from 'vs/platform/files/common/files' ;
31- import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService' ;
31+ import { WorkbenchAsyncDataTree , TreeResourceNavigator2 } from 'vs/platform/list/browser/listService' ;
3232import { ViewletPanel , IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet' ;
3333import { localize } from 'vs/nls' ;
3434import { timeout } from 'vs/base/common/async' ;
@@ -42,7 +42,7 @@ import { IMarkdownRenderResult } from 'vs/editor/contrib/markdown/markdownRender
4242import { ILabelService } from 'vs/platform/label/common/label' ;
4343import { Registry } from 'vs/platform/registry/common/platform' ;
4444import { IListVirtualDelegate , IIdentityProvider } from 'vs/base/browser/ui/list/list' ;
45- import { ITreeRenderer , ITreeNode , IAsyncDataSource , ITreeContextMenuEvent , ITreeEvent } from 'vs/base/browser/ui/tree/tree' ;
45+ import { ITreeRenderer , ITreeNode , IAsyncDataSource , ITreeContextMenuEvent } from 'vs/base/browser/ui/tree/tree' ;
4646import { FuzzyScore , createMatches } from 'vs/base/common/filters' ;
4747import { CollapseAllAction } from 'vs/base/browser/ui/tree/treeDefaults' ;
4848
@@ -389,7 +389,6 @@ export class CustomTreeView extends Disposable implements ITreeView {
389389 aligner . tree = this . tree ;
390390
391391 this . tree . contextKeyService . createKey < boolean > ( this . id , true ) ;
392- this . _register ( this . tree . onDidChangeSelection ( e => this . onSelection ( e ) ) ) ;
393392 this . _register ( this . tree . onContextMenu ( e => this . onContextMenu ( treeMenus , e ) ) ) ;
394393 this . _register ( this . tree . onDidChangeSelection ( e => this . _onDidChangeSelection . fire ( e . elements ) ) ) ;
395394 this . _register ( this . tree . onDidChangeCollapseState ( e => {
@@ -401,6 +400,18 @@ export class CustomTreeView extends Disposable implements ITreeView {
401400 }
402401 } ) ) ;
403402 this . tree . setInput ( this . root ) . then ( ( ) => this . updateContentAreas ( ) ) ;
403+
404+ const customTreeNavigator = new TreeResourceNavigator2 ( this . tree ) ;
405+ this . _register ( customTreeNavigator ) ;
406+ this . _register ( customTreeNavigator . onDidOpenResource ( e => {
407+ if ( ! e . browserEvent ) {
408+ return ;
409+ }
410+ const selection = this . tree . getSelection ( ) ;
411+ if ( ( selection . length === 1 ) && selection [ 0 ] . command ) {
412+ this . commandService . executeCommand ( selection [ 0 ] . command . id , ...( selection [ 0 ] . command . arguments || [ ] ) ) ;
413+ }
414+ } ) ) ;
404415 }
405416
406417 private onContextMenu ( treeMenus : TreeMenus , treeEvent : ITreeContextMenuEvent < ITreeItem > ) : void {
@@ -599,20 +610,6 @@ export class CustomTreeView extends Disposable implements ITreeView {
599610 this . domNode . removeAttribute ( 'tabindex' ) ;
600611 }
601612 }
602-
603- private onSelection ( e : ITreeEvent < ITreeItem > ) : void {
604- if ( ! e . browserEvent ) {
605- return ;
606- }
607- const selection : ITreeItem = this . tree . getSelection ( ) [ 0 ] ;
608- if ( selection ) {
609- if ( selection . command ) {
610- if ( this . tree . openOnSingleClick ) {
611- this . commandService . executeCommand ( selection . command . id , ...( selection . command . arguments || [ ] ) ) ;
612- }
613- }
614- }
615- }
616613}
617614
618615class CustomViewIdentityProvider implements IIdentityProvider < ITreeItem > {
0 commit comments