@@ -5,6 +5,9 @@ import { EXTENSION_NAMESPACE } from '../constants/constants';
55import type { ProjectFile } from '../types/ProjectFile' ;
66import { ProjectTreeItem } from './ProjectTreeItem' ;
77import type { CLI } from '../cli/CLI' ;
8+ import { MigrationTreeItem } from './MigrationTreeItem' ;
9+ import { CommandProvider } from '../commands/CommandProvider' ;
10+ import { OpenMigrationFileCommand } from '../commands/OpenMigrationFileCommand' ;
811
912export class TreeDataProvider
1013 extends Disposable
@@ -23,12 +26,25 @@ export class TreeDataProvider
2326 private readonly cli : CLI ,
2427 ) {
2528 super ( ) ;
26- this . subscriptions . push (
27- vscode . window . registerTreeDataProvider (
28- `${ EXTENSION_NAMESPACE } Tree` ,
29- this ,
30- ) ,
31- ) ;
29+ const view = vscode . window . createTreeView ( `${ EXTENSION_NAMESPACE } Tree` , {
30+ treeDataProvider : this ,
31+ } ) ;
32+ view . onDidChangeSelection ( this . handleTreeItemSelection . bind ( this ) ) ;
33+ this . subscriptions . push ( view ) ;
34+ }
35+
36+ private async handleTreeItemSelection (
37+ e : vscode . TreeViewSelectionChangeEvent < vscode . TreeItem > ,
38+ ) {
39+ if (
40+ e . selection . length === 1 &&
41+ e . selection [ 0 ] instanceof MigrationTreeItem
42+ ) {
43+ await vscode . commands . executeCommand (
44+ CommandProvider . getCommandName ( OpenMigrationFileCommand . commandName ) ,
45+ e . selection [ 0 ] ,
46+ ) ;
47+ }
3248 }
3349
3450 public refresh ( ) : void {
0 commit comments