@@ -5,6 +5,9 @@ import { EXTENSION_NAMESPACE } from '../constants/constants';
5
5
import type { ProjectFile } from '../types/ProjectFile' ;
6
6
import { ProjectTreeItem } from './ProjectTreeItem' ;
7
7
import type { CLI } from '../cli/CLI' ;
8
+ import { MigrationTreeItem } from './MigrationTreeItem' ;
9
+ import { CommandProvider } from '../commands/CommandProvider' ;
10
+ import { OpenMigrationFileCommand } from '../commands/OpenMigrationFileCommand' ;
8
11
9
12
export class TreeDataProvider
10
13
extends Disposable
@@ -23,12 +26,25 @@ export class TreeDataProvider
23
26
private readonly cli : CLI ,
24
27
) {
25
28
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
+ }
32
48
}
33
49
34
50
public refresh ( ) : void {
0 commit comments